diff --git a/sycl/include/sycl/detail/pi.h b/sycl/include/sycl/detail/pi.h index 30e65a9310a3d..67094702273d6 100644 --- a/sycl/include/sycl/detail/pi.h +++ b/sycl/include/sycl/detail/pi.h @@ -47,9 +47,11 @@ // 8.10 Added new optional device argument to piextQueueCreateWithNativeHandle // 9.11 Use values of OpenCL enums directly, rather than including ``; // NOTE that this results in a changed API for `piProgramGetBuildInfo`. +// 10.12 Change enum value PI_MEM_ADVICE_UNKNOWN from 0 to 999, and set enum +// PI_MEM_ADVISE_RESET to 0. -#define _PI_H_VERSION_MAJOR 9 -#define _PI_H_VERSION_MINOR 11 +#define _PI_H_VERSION_MAJOR 10 +#define _PI_H_VERSION_MINOR 12 #define _PI_STRING_HELPER(a) #a #define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b) @@ -404,7 +406,7 @@ typedef enum { typedef enum { // Device-specific value opaque in PI API. - PI_MEM_ADVICE_UNKNOWN, + PI_MEM_ADVICE_RESET = 0, PI_MEM_ADVICE_CUDA_SET_READ_MOSTLY = 101, PI_MEM_ADVICE_CUDA_UNSET_READ_MOSTLY = 102, PI_MEM_ADVICE_CUDA_SET_PREFERRED_LOCATION = 103, @@ -415,6 +417,7 @@ typedef enum { PI_MEM_ADVICE_CUDA_UNSET_PREFERRED_LOCATION_HOST = 108, PI_MEM_ADVICE_CUDA_SET_ACCESSED_BY_HOST = 109, PI_MEM_ADVICE_CUDA_UNSET_ACCESSED_BY_HOST = 110, + PI_MEM_ADVICE_UNKNOWN = 999, } _pi_mem_advice; typedef enum { diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 03052ccd2b94c..bce09721e5b1f 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -5099,7 +5099,8 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, if (advice == PI_MEM_ADVICE_CUDA_SET_PREFERRED_LOCATION || advice == PI_MEM_ADVICE_CUDA_UNSET_PREFERRED_LOCATION || advice == PI_MEM_ADVICE_CUDA_SET_ACCESSED_BY || - advice == PI_MEM_ADVICE_CUDA_UNSET_ACCESSED_BY) { + advice == PI_MEM_ADVICE_CUDA_UNSET_ACCESSED_BY || + advice == PI_MEM_ADVICE_RESET) { pi_device device = queue->get_context()->get_device(); if (!getAttribute(device, CU_DEVICE_ATTRIBUTE_CONCURRENT_MANAGED_ACCESS)) { setErrorMessage("Mem advise ignored as device does not support " @@ -5148,6 +5149,17 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr, PI_MEM_ADVICE_CUDA_SET_PREFERRED_LOCATION)), CU_DEVICE_CPU)); break; + case PI_MEM_ADVICE_RESET: + PI_CHECK_ERROR(cuMemAdvise((CUdeviceptr)ptr, length, + CU_MEM_ADVISE_UNSET_READ_MOSTLY, + queue->get_context()->get_device()->get())); + PI_CHECK_ERROR(cuMemAdvise((CUdeviceptr)ptr, length, + CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION, + queue->get_context()->get_device()->get())); + PI_CHECK_ERROR(cuMemAdvise((CUdeviceptr)ptr, length, + CU_MEM_ADVISE_UNSET_ACCESSED_BY, + queue->get_context()->get_device()->get())); + break; default: cl::sycl::detail::pi::die("Unknown advice"); }