Skip to content

Commit 562340c

Browse files
committed
unconditionally set primary context to current
1 parent c4afd33 commit 562340c

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

cuda_core/cuda/core/experimental/_device.py

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,20 +1198,9 @@ def set_current(self, ctx: Context = None) -> Union[Context, None]:
11981198
if int(prev_ctx) != 0:
11991199
return Context._from_ctx(prev_ctx, self._id)
12001200
else:
1201-
ctx = handle_return(driver.cuCtxGetCurrent())
1202-
if int(ctx) == 0:
1203-
# use primary ctx
1204-
ctx = self._get_primary_context()
1205-
handle_return(driver.cuCtxSetCurrent(ctx))
1206-
else:
1207-
ctx_id = handle_return(driver.cuCtxGetDevice())
1208-
if ctx_id != self._id:
1209-
# use primary ctx
1210-
ctx = self._get_primary_context()
1211-
handle_return(driver.cuCtxSetCurrent(ctx))
1212-
else:
1213-
# no-op, a valid context already exists and is set current
1214-
pass
1201+
# use primary ctx
1202+
ctx = self._get_primary_context()
1203+
handle_return(driver.cuCtxSetCurrent(ctx))
12151204
self._has_inited = True
12161205

12171206
def create_context(self, options: ContextOptions = None) -> Context:

0 commit comments

Comments
 (0)