Guard for prefetchAsync GPU capability. #470 #451 #477

This commit is contained in:
Tim Dettmers 2023-07-16 21:12:03 -07:00
parent f3232d1391
commit 7be5f2c7b3

View File

@ -385,6 +385,11 @@ extern "C"
void cprefetch(void *ptr, size_t bytes, int device) void cprefetch(void *ptr, size_t bytes, int device)
{ {
int hasPrefetch = 0;
CUDA_CHECK_RETURN(cudaDeviceGetAttribute(&hasPrefetch, cudaDevAttrConcurrentManagedAccess, device)); // 40ns overhead
if (hasPrefetch == 0) return;
CUDA_CHECK_RETURN(cudaMemPrefetchAsync(ptr, bytes, device, 0)); CUDA_CHECK_RETURN(cudaMemPrefetchAsync(ptr, bytes, device, 0));
CUDA_CHECK_RETURN(cudaPeekAtLastError()); CUDA_CHECK_RETURN(cudaPeekAtLastError());
} }