Skip to content

[SYCL][CUDA] Implemented cuda_piextUSMEnqueueMemAdvise #3365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 13, 2021
Merged
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
29 changes: 26 additions & 3 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4449,9 +4449,32 @@ 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_USER, 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;
} catch (...) {
result = PI_ERROR_UNKNOWN;
}
return result;
}

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