From 7be5f2c7b35363ced1b81356e6342142aa13ee68 Mon Sep 17 00:00:00 2001 From: Tim Dettmers Date: Sun, 16 Jul 2023 21:12:03 -0700 Subject: [PATCH] Guard for prefetchAsync GPU capability. #470 #451 #477 --- csrc/pythonInterface.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/csrc/pythonInterface.c b/csrc/pythonInterface.c index 0aa82fe..865e4b6 100644 --- a/csrc/pythonInterface.c +++ b/csrc/pythonInterface.c @@ -385,6 +385,11 @@ extern "C" 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(cudaPeekAtLastError()); }