Skip to content

Commit 296fa1a

Browse files
authored
[SYCL][CUDA] Make active context persitant (#2016)
Whenever there is no CUDA context assigned to a thread, once it is set, this context remains set until destruction of the thread. Previously it was only the primary context the one persistent. Signed-off-by: Ruyman Reyes <[email protected]>
1 parent aee2d6c commit 296fa1a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sycl/plugins/cuda/pi_cuda.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,11 @@ class ScopedContext {
166166
if (original_ != desired) {
167167
// Sets the desired context as the active one for the thread
168168
PI_CHECK_ERROR(cuCtxSetCurrent(desired));
169-
if (original_ == nullptr && ctxt->is_primary()) {
170-
// No context is installed and the suggested context is primary
169+
if (original_ == nullptr) {
170+
// No context is installed on the current thread
171171
// This is the most common case. We can activate the context in the
172172
// thread and leave it there until all the PI context referring to the
173-
// same underlying CUDA primary context are destroyed. This emulates
173+
// same underlying CUDA context are destroyed. This emulates
174174
// the behaviour of the CUDA runtime api, and avoids costly context
175175
// switches. No action is required on this side of the if.
176176
} else {

0 commit comments

Comments
 (0)