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,11 @@ 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->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
222+ hQueue->getDevice ()) {
223+ // This event is never created with interop so getQueue is never null
224+ hQueue = hBuffer->LastEventWritingToMemObj ->getQueue ();
225+ Device = hQueue->getDevice ();
223226 ScopedContext Active (Device);
224227 HIPStream = hipStream_t{0 }; // Default stream for different device
225228 // We may have to wait for an event on another queue if it is the last
@@ -584,8 +587,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferReadRect(
584587 // last queue to write to the MemBuffer, meaning we must perform the copy
585588 // from a different device
586589 if (hBuffer->LastEventWritingToMemObj &&
587- hBuffer->LastEventWritingToMemObj ->getDevice () != hQueue->getDevice ()) {
588- Device = hBuffer->LastEventWritingToMemObj ->getDevice ();
590+ hBuffer->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
591+ hQueue->getDevice ()) {
592+ // This event is never created with interop so getQueue is never null
593+ hQueue = hBuffer->LastEventWritingToMemObj ->getQueue ();
594+ Device = hQueue->getDevice ();
589595 ScopedContext Active (Device);
590596 HIPStream = hipStream_t{0 }; // Default stream for different device
591597 // We may have to wait for an event on another queue if it is the last
@@ -1017,8 +1023,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemImageRead(
10171023 // last queue to write to the MemBuffer, meaning we must perform the copy
10181024 // from a different device
10191025 if (hImage->LastEventWritingToMemObj &&
1020- hImage->LastEventWritingToMemObj ->getDevice () != hQueue->getDevice ()) {
1021- Device = hImage->LastEventWritingToMemObj ->getDevice ();
1026+ hImage->LastEventWritingToMemObj ->getQueue ()->getDevice () !=
1027+ hQueue->getDevice ()) {
1028+ hQueue = hImage->LastEventWritingToMemObj ->getQueue ();
1029+ Device = hQueue->getDevice ();
10221030 ScopedContext Active (Device);
10231031 HIPStream = hipStream_t{0 }; // Default stream for different device
10241032 // We may have to wait for an event on another queue if it is the last
0 commit comments