@@ -218,8 +218,9 @@ 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->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
222- Device = hBuffer->LastDeviceWritingToMemObj ;
221+ hBuffer->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
222+ hQueue->getDevice ()) {
223+ Device = hBuffer->LastEventWritingToMemObj ->getQueue ()->getDevice ();
223224 ScopedContext Active (Device);
224225 HIPStream = hipStream_t{0 }; // Default stream for different device
225226 // We may have to wait for an event on another queue if it is the last
@@ -367,8 +368,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueKernelLaunch(
367368 // if it has been written to
368369 if (phEvent && (MemArg.AccessFlags &
369370 (UR_MEM_FLAG_READ_WRITE | UR_MEM_FLAG_WRITE_ONLY))) {
370- MemArg.Mem ->setLastEventWritingToMemObj (RetImplEvent.get (),
371- hQueue->getDevice ());
371+ MemArg.Mem ->setLastEventWritingToMemObj (RetImplEvent.get ());
372372 }
373373 }
374374 // We can release the MemoryMigrationMutexes now
@@ -585,8 +585,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
585585 // last queue to write to the MemBuffer, meaning we must perform the copy
586586 // from a different device
587587 if (hBuffer->LastEventWritingToMemObj &&
588- hBuffer->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
589- Device = hBuffer->LastDeviceWritingToMemObj ;
588+ hBuffer->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
589+ hQueue->getDevice ()) {
590+ Device = hBuffer->LastEventWritingToMemObj ->getQueue ()->getDevice ();
590591 ScopedContext Active (Device);
591592 HIPStream = hipStream_t{0 }; // Default stream for different device
592593 // We may have to wait for an event on another queue if it is the last
@@ -1018,8 +1019,9 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
10181019 // last queue to write to the MemBuffer, meaning we must perform the copy
10191020 // from a different device
10201021 if (hImage->LastEventWritingToMemObj &&
1021- hImage->LastDeviceWritingToMemObj != hQueue->getDevice ()) {
1022- Device = hImage->LastDeviceWritingToMemObj ;
1022+ hImage->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
1023+ hQueue->getDevice ()) {
1024+ Device = hImage->LastEventWritingToMemObj ->getQueue ()->getDevice ();
10231025 ScopedContext Active (Device);
10241026 HIPStream = hipStream_t{0 }; // Default stream for different device
10251027 // We may have to wait for an event on another queue if it is the last
0 commit comments