Skip to content

Commit ae74ef4

Browse files
author
Hugh Delaney
committed
Make sure context is set before getting stream
Context was not set before getting stream, leading to invalid context in multi threaded application.
1 parent c0da06e commit ae74ef4

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

source/adapters/cuda/enqueue.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
625625

626626
ur_lock MemoryMigrationLock{hBuffer->MemoryMigrationMutex};
627627
auto Device = hQueue->getDevice();
628+
ScopedContext Active(Device);
628629
CUstream Stream = hQueue->getNextTransferStream();
629630

630631
try {
@@ -644,8 +645,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
644645
&hBuffer->LastEventWritingToMemObj));
645646
}
646647

647-
ScopedContext Active(Device);
648-
649648
UR_CHECK_ERROR(enqueueEventsWait(hQueue, Stream, numEventsInWaitList,
650649
phEventWaitList));
651650

@@ -1640,6 +1639,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
16401639
std::unique_ptr<ur_event_handle_t_> RetImplEvent{nullptr};
16411640
ur_lock MemoryMigrationLock{hBuffer->MemoryMigrationMutex};
16421641
auto Device = hQueue->getDevice();
1642+
ScopedContext Active(Device);
16431643
CUstream Stream = hQueue->getNextTransferStream();
16441644

16451645
try {
@@ -1659,8 +1659,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
16591659
&hBuffer->LastEventWritingToMemObj));
16601660
}
16611661

1662-
ScopedContext Active(Device);
1663-
16641662
UR_CHECK_ERROR(enqueueEventsWait(hQueue, Stream, numEventsInWaitList,
16651663
phEventWaitList));
16661664

0 commit comments

Comments
 (0)