@@ -625,6 +625,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
625
625
626
626
ur_lock MemoryMigrationLock{hBuffer->MemoryMigrationMutex };
627
627
auto Device = hQueue->getDevice ();
628
+ ScopedContext Active (Device);
628
629
CUstream Stream = hQueue->getNextTransferStream ();
629
630
630
631
try {
@@ -644,8 +645,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
644
645
&hBuffer->LastEventWritingToMemObj ));
645
646
}
646
647
647
- ScopedContext Active (Device);
648
-
649
648
UR_CHECK_ERROR (enqueueEventsWait (hQueue, Stream, numEventsInWaitList,
650
649
phEventWaitList));
651
650
@@ -1640,6 +1639,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
1640
1639
std::unique_ptr<ur_event_handle_t_> RetImplEvent{nullptr };
1641
1640
ur_lock MemoryMigrationLock{hBuffer->MemoryMigrationMutex };
1642
1641
auto Device = hQueue->getDevice ();
1642
+ ScopedContext Active (Device);
1643
1643
CUstream Stream = hQueue->getNextTransferStream ();
1644
1644
1645
1645
try {
@@ -1659,8 +1659,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
1659
1659
&hBuffer->LastEventWritingToMemObj ));
1660
1660
}
1661
1661
1662
- ScopedContext Active (Device);
1663
-
1664
1662
UR_CHECK_ERROR (enqueueEventsWait (hQueue, Stream, numEventsInWaitList,
1665
1663
phEventWaitList));
1666
1664
0 commit comments