@@ -4803,6 +4803,13 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
4803
4803
pi_result result = PI_SUCCESS;
4804
4804
std::unique_ptr<_pi_event> event_ptr{nullptr };
4805
4805
4806
+ // Ignore mem advice if memory is not managed
4807
+ unsigned int is_managed;
4808
+ PI_CHECK_ERROR (cuPointerGetAttribute (
4809
+ &is_managed, CU_POINTER_ATTRIBUTE_IS_MANAGED, (CUdeviceptr)ptr));
4810
+ if (!is_managed)
4811
+ return PI_SUCCESS;
4812
+
4806
4813
try {
4807
4814
ScopedContext active (queue->get_context ());
4808
4815
@@ -4835,6 +4842,17 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
4835
4842
PI_MEM_ADVICE_CUDA_SET_PREFERRED_LOCATION)),
4836
4843
CU_DEVICE_CPU));
4837
4844
break ;
4845
+ case PI_MEM_ADVISE_RESET:
4846
+ PI_CHECK_ERROR (cuMemAdvise ((CUdeviceptr)ptr, length,
4847
+ CU_MEM_ADVISE_UNSET_READ_MOSTLY,
4848
+ queue->get_context ()->get_device ()->get ()));
4849
+ PI_CHECK_ERROR (cuMemAdvise ((CUdeviceptr)ptr, length,
4850
+ CU_MEM_ADVISE_UNSET_PREFERRED_LOCATION,
4851
+ queue->get_context ()->get_device ()->get ()));
4852
+ PI_CHECK_ERROR (cuMemAdvise ((CUdeviceptr)ptr, length,
4853
+ CU_MEM_ADVISE_UNSET_ACCESSED_BY,
4854
+ queue->get_context ()->get_device ()->get ()));
4855
+ break ;
4838
4856
default :
4839
4857
cl::sycl::detail::pi::die (" Unknown advice" );
4840
4858
}
0 commit comments