Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ typedef enum {
PI_COMMAND_TYPE_SVM_MEMCPY = CL_COMMAND_SVM_MEMCPY,
PI_COMMAND_TYPE_SVM_MEMFILL = CL_COMMAND_SVM_MEMFILL,
PI_COMMAND_TYPE_SVM_MAP = CL_COMMAND_SVM_MAP,
PI_COMMAND_TYPE_SVM_UNMAP = CL_COMMAND_SVM_UNMAP
PI_COMMAND_TYPE_SVM_UNMAP = CL_COMMAND_SVM_UNMAP,
PI_COMMAND_TYPE_MEMADVISE = 0x4207
} _pi_command_type;

typedef enum {
Expand Down
27 changes: 24 additions & 3 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4449,9 +4449,30 @@ pi_result cuda_piextUSMEnqueueMemAdvise(pi_queue queue, const void *ptr,
pi_event *event) {
assert(queue != nullptr);
assert(ptr != nullptr);
// TODO implement a mapping to cuMemAdvise once the expected behaviour
// of piextUSMEnqueueMemAdvise is detailed in the USM extension
return cuda_piEnqueueEventsWait(queue, 0, nullptr, event);

pi_result result = PI_SUCCESS;
std::unique_ptr<_pi_event> event_ptr{nullptr};

try {
ScopedContext active(queue->get_context());

if (event) {
event_ptr = std::unique_ptr<_pi_event>(
_pi_event::make_native(PI_COMMAND_TYPE_MEMADVISE, queue));
event_ptr->start();
}

result = PI_CHECK_ERROR(
cuMemAdvise((CUdeviceptr)ptr, length, (CUmem_advise)advice,
queue->get_context()->get_device()->get()));
if (event) {
result = event_ptr->record();
*event = event_ptr.release();
}
} catch (pi_result err) {
result = err;
}
return result;
}

/// API to query information about USM allocated pointers
Expand Down