20
20
21
21
extern size_t imageElementByteSize (hipArray_Format ArrayFormat);
22
22
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,
24
24
uint32_t NumEventsInWaitList,
25
25
const ur_event_handle_t *EventWaitList) {
26
26
if (!EventWaitList) {
@@ -29,8 +29,8 @@ ur_result_t enqueueEventsWait(ur_queue_handle_t, hipStream_t Stream,
29
29
try {
30
30
auto Result = forLatestEvents (
31
31
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 ());
34
34
if (Event->isCompleted () || Event->getStream () == Stream) {
35
35
return UR_RESULT_SUCCESS;
36
36
} else {
@@ -218,8 +218,11 @@ UR_APIEXPORT ur_result_t UR_APICALL urEnqueueMemBufferRead(
218
218
// last queue to write to the MemBuffer, meaning we must perform the copy
219
219
// from a different device
220
220
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 ();
223
226
ScopedContext Active (Device);
224
227
HIPStream = hipStream_t{0 }; // Default stream for different device
225
228
// 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(
584
587
// last queue to write to the MemBuffer, meaning we must perform the copy
585
588
// from a different device
586
589
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 ();
589
595
ScopedContext Active (Device);
590
596
HIPStream = hipStream_t{0 }; // Default stream for different device
591
597
// 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(
1017
1023
// last queue to write to the MemBuffer, meaning we must perform the copy
1018
1024
// from a different device
1019
1025
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 ();
1022
1030
ScopedContext Active (Device);
1023
1031
HIPStream = hipStream_t{0 }; // Default stream for different device
1024
1032
// We may have to wait for an event on another queue if it is the last
0 commit comments