Skip to content

[SYCL][CUDA] Remove obsolete ScopedContext workaround #8265

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 1 commit into from
Feb 9, 2023
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
21 changes: 3 additions & 18 deletions sycl/plugins/cuda/pi_cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,17 @@ pi_result check_error(CUresult result, const char *function, int line,
/// contexts to be restored by SYCL.
class ScopedContext {
public:
ScopedContext(pi_context ctxt) : device(nullptr) {
ScopedContext(pi_context ctxt) {
if (!ctxt) {
throw PI_ERROR_INVALID_CONTEXT;
}

set_context(ctxt->get());
}

ScopedContext(CUcontext ctxt) : device(nullptr) { set_context(ctxt); }
ScopedContext(CUcontext ctxt) { set_context(ctxt); }

// Creating a scoped context from a device will simply use the primary
// context, this should be used when there is no other appropriate context,
// such as for the device infos.
ScopedContext(pi_device device) : device(device) {
CUcontext ctxt;
cuDevicePrimaryCtxRetain(&ctxt, device->get());

set_context(ctxt);
}

~ScopedContext() {
if (device)
cuDevicePrimaryCtxRelease(device->get());
}
~ScopedContext() {}

private:
void set_context(CUcontext desired) {
Expand All @@ -225,8 +212,6 @@ class ScopedContext {
PI_CHECK_ERROR(cuCtxSetCurrent(desired));
}
}

pi_device device;
};

/// \cond NODOXY
Expand Down