Skip to content

Commit 49f71b7

Browse files
author
Hugh Delaney
committed
Make sure context is set after enqueueEventsWait
enqueueEventsWait may set a different context, so we need to reset it after returning.
1 parent a2eb1e4 commit 49f71b7

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

source/adapters/hip/enqueue.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,12 +229,13 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
229229
&hBuffer->LastEventWritingToMemObj));
230230
}
231231

232-
ScopedContext Active(Device);
233-
234232
// Use the default stream if copying from another device
235233
UR_CHECK_ERROR(enqueueEventsWait(hQueue, HIPStream, numEventsInWaitList,
236234
phEventWaitList));
237235

236+
// enqueueEventsWait may set a different context
237+
ScopedContext Active(Device);
238+
238239
if (phEvent) {
239240
RetImplEvent =
240241
std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeNative(
@@ -596,11 +597,12 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
596597
&hBuffer->LastEventWritingToMemObj));
597598
}
598599

599-
ScopedContext Active(Device);
600-
601600
UR_CHECK_ERROR(enqueueEventsWait(hQueue, HIPStream, numEventsInWaitList,
602601
phEventWaitList));
603602

603+
// enqueueEventsWait may set a different context
604+
ScopedContext Active(Device);
605+
604606
if (phEvent) {
605607
RetImplEvent =
606608
std::unique_ptr<ur_event_handle_t_>(ur_event_handle_t_::makeNative(

0 commit comments

Comments
 (0)