Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions sycl/include/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@
// 8.10 Added new optional device argument to piextQueueCreateWithNativeHandle
// 9.11 Use values of OpenCL enums directly, rather than including `<CL/cl.h>`;
// 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)
Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down
14 changes: 13 additions & 1 deletion sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand Down Expand Up @@ -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");
}
Expand Down