Skip to content

Commit 0fe322c

Browse files
authored
[SYCL][CUDA] Add managed mem check to enqueue prefetch (#5446)
This PR adds a managed memory check in cuda_piextUSMEnqueuePrefetch. cuMemPrefetchAsync only works on managed memory and returns an error if host or device memory is passed. This check ignores the prefetch hint if the memory provided is not managed. A warning is emitted to the user if the prefetch is ignored. This is a partial fix to: #5209
1 parent 4a794df commit 0fe322c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4762,6 +4762,15 @@ pi_result cuda_piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr,
47624762
return PI_PLUGIN_SPECIFIC_ERROR;
47634763
}
47644764

4765+
unsigned int is_managed;
4766+
PI_CHECK_ERROR(cuPointerGetAttribute(
4767+
&is_managed, CU_POINTER_ATTRIBUTE_IS_MANAGED, (CUdeviceptr)ptr));
4768+
if (!is_managed) {
4769+
setErrorMessage("Prefetch hint ignored as prefetch only works with USM",
4770+
PI_SUCCESS);
4771+
return PI_PLUGIN_SPECIFIC_ERROR;
4772+
}
4773+
47654774
// flags is currently unused so fail if set
47664775
if (flags != 0)
47674776
return PI_INVALID_VALUE;

0 commit comments

Comments
 (0)