2020
2121extern size_t imageElementByteSize (hipArray_Format ArrayFormat);
2222
23- ur_result_t enqueueEventsWait (ur_queue_handle_t , hipStream_t Stream,
23+ ur_result_t enqueueEventsWait (ur_queue_handle_t Queue , hipStream_t Stream,
2424 uint32_t NumEventsInWaitList,
2525 const ur_event_handle_t *EventWaitList) {
2626 if (!EventWaitList) {
@@ -29,8 +29,8 @@ ur_result_t enqueueEventsWait(ur_queue_handle_t, hipStream_t Stream,
2929 try {
3030 auto Result = forLatestEvents (
3131 EventWaitList, NumEventsInWaitList,
32- [Stream](ur_event_handle_t Event) -> ur_result_t {
33- ScopedContext Active (Event ->getDevice ());
32+ [Stream, Queue ](ur_event_handle_t Event) -> ur_result_t {
33+ ScopedContext Active (Queue ->getDevice ());
3434 if (Event->isCompleted () || Event->getStream () == Stream) {
3535 return UR_RESULT_SUCCESS;
3636 } else {
@@ -218,8 +218,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
218218 // last queue to write to the MemBuffer, meaning we must perform the copy
219219 // from a different device
220220 if (hBuffer->LastEventWritingToMemObj &&
221- hBuffer->LastEventWritingToMemObj -> getDevice () != hQueue->getDevice ()) {
222- Device = hBuffer->LastEventWritingToMemObj -> getDevice () ;
221+ hBuffer->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
222+ Device = hBuffer->LastDeviceWritingToMemObj ;
223223 ScopedContext Active (Device);
224224 HIPStream = hipStream_t{0 }; // Default stream for different device
225225 // We may have to wait for an event on another queue if it is the last
@@ -367,7 +367,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
367367 // if it has been written to
368368 if (phEvent && (MemArg.AccessFlags &
369369 (UR_MEM_FLAG_READ_WRITE | UR_MEM_FLAG_WRITE_ONLY))) {
370- MemArg.Mem ->setLastEventWritingToMemObj (RetImplEvent.get ());
370+ MemArg.Mem ->setLastEventWritingToMemObj (RetImplEvent.get (),
371+ hQueue->getDevice ());
371372 }
372373 }
373374 // We can release the MemoryMigrationMutexes now
@@ -584,8 +585,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
584585 // last queue to write to the MemBuffer, meaning we must perform the copy
585586 // from a different device
586587 if (hBuffer->LastEventWritingToMemObj &&
587- hBuffer->LastEventWritingToMemObj -> getDevice () != hQueue->getDevice ()) {
588- Device = hBuffer->LastEventWritingToMemObj -> getDevice () ;
588+ hBuffer->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
589+ Device = hBuffer->LastDeviceWritingToMemObj ;
589590 ScopedContext Active (Device);
590591 HIPStream = hipStream_t{0 }; // Default stream for different device
591592 // We may have to wait for an event on another queue if it is the last
@@ -1017,8 +1018,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
10171018 // last queue to write to the MemBuffer, meaning we must perform the copy
10181019 // from a different device
10191020 if (hImage->LastEventWritingToMemObj &&
1020- hImage->LastEventWritingToMemObj -> getDevice () != hQueue->getDevice ()) {
1021- Device = hImage->LastEventWritingToMemObj -> getDevice () ;
1021+ hImage->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
1022+ Device = hImage->LastDeviceWritingToMemObj ;
10221023 ScopedContext Active (Device);
10231024 HIPStream = hipStream_t{0 }; // Default stream for different device
10241025 // We may have to wait for an event on another queue if it is the last
0 commit comments