Skip to content

Commit

Permalink
This might be the minimal fix.
Browse files Browse the repository at this point in the history
`cudaMemoryTypeUnregistered` wouldn't be returned on CUDA <11 (that would be an error condition instead).
  • Loading branch information
jaycedowell authored Aug 21, 2023
1 parent 29a3858 commit 4a6a8a1
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions src/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,31 +60,19 @@ BFstatus bfGetSpace(const void* ptr, BFspace* space) {
*space = BF_SPACE_SYSTEM;
// WAR to avoid the ignored failure showing up later
cudaGetLastError();
#if defined(CUDA_VERSION) && CUDA_VERSION >= 11000
#if defined(CUDA_VERSION) && CUDA_VERSION >= 10000
} else {
switch( ptr_attrs.type ) {
case cudaMemoryTypeUnregistered: *space = BF_SPACE_SYSTEM; break
case cudaMemoryTypeHost: *space = BF_SPACE_CUDA_HOST; break;
case cudaMemoryTypeDevice: *space = BF_SPACE_CUDA; break;
case cudaMemoryTypeManaged: *space = BF_SPACE_CUDA_MANAGED; break;
case cudaMemoryTypeUnregistered: *space = BF_SPACE_SYSTEM; break
case cudaMemoryTypeHost: *space = BF_SPACE_CUDA_HOST; break;
case cudaMemoryTypeDevice: *space = BF_SPACE_CUDA; break;
case cudaMemoryTypeManaged: *space = BF_SPACE_CUDA_MANAGED; break;
default: {
// This should never be reached
BF_FAIL("Valid memoryType", BF_STATUS_INTERNAL_ERROR);
}
}
}
#elif defined(CUDA_VERSION) && CUDA_VERSION >= 10000
} else {
switch( ptr_attrs.type ) {
case cudaMemoryTypeHost: *space = BF_SPACE_SYSTEM; break;
case cudaMemoryTypeDevice: *space = BF_SPACE_CUDA; break;
case cudaMemoryTypeManaged: *space = BF_SPACE_CUDA_MANAGED; break;
default: {
// This should never be reached
BF_FAIL("Valid memoryType", BF_STATUS_INTERNAL_ERROR);
}
}
}
#else
} else if( ptr_attrs.isManaged ) {
*space = BF_SPACE_CUDA_MANAGED;
Expand Down

0 comments on commit 4a6a8a1

Please sign in to comment.