Skip to content

Commit 61f0039

Browse files
author
Hugh Delaney
committed
Always wait on interop events
We can't make assumptions about interop events being on the same stream as other interop events, since in UR we don't track the streams that native events are recorded on.
1 parent 2c4303c commit 61f0039

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

source/adapters/cuda/event.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ ur_event_handle_t_::ur_event_handle_t_(ur_context_handle_t Context,
3636
CUevent EventNative)
3737
: CommandType{UR_COMMAND_EVENTS_WAIT}, RefCount{1}, HasOwnership{false},
3838
HasBeenWaitedOn{false}, IsRecorded{false}, IsStarted{false},
39-
StreamToken{std::numeric_limits<uint32_t>::max()}, EventID{0},
40-
EvEnd{EventNative}, EvStart{nullptr}, EvQueued{nullptr}, Queue{nullptr},
41-
Stream{nullptr}, Context{Context} {
39+
IsInterop{true}, StreamToken{std::numeric_limits<uint32_t>::max()},
40+
EventID{0}, EvEnd{EventNative}, EvStart{nullptr}, EvQueued{nullptr},
41+
Queue{nullptr}, Stream{nullptr}, Context{Context} {
4242
urContextRetain(Context);
4343
}
4444

source/adapters/cuda/event.hpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct ur_event_handle_t_ {
4545

4646
bool isCompleted() const noexcept;
4747

48+
bool isInterop() const noexcept { return IsInterop; };
49+
4850
uint32_t getExecutionStatus() const noexcept {
4951

5052
if (!isRecorded()) {
@@ -141,6 +143,8 @@ struct ur_event_handle_t_ {
141143
bool IsStarted; // Signifies wether the operation associated with the
142144
// UR event has started or not
143145

146+
const bool IsInterop{false}; // Made with urEventCreateWithNativeHandle
147+
144148
uint32_t StreamToken;
145149
uint32_t EventID; // Queue identifier of the event.
146150

@@ -195,7 +199,8 @@ ur_result_t forLatestEvents(const ur_event_handle_t *EventWaitList,
195199
CUstream LastSeenStream = 0;
196200
for (size_t i = 0; i < Events.size(); i++) {
197201
auto Event = Events[i];
198-
if (!Event || (i != 0 && Event->getStream() == LastSeenStream)) {
202+
if (!Event || (i != 0 && !Event->isInterop() &&
203+
Event->getStream() == LastSeenStream)) {
199204
continue;
200205
}
201206

source/adapters/hip/event.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ ur_event_handle_t_::ur_event_handle_t_(ur_context_handle_t Context,
3131
hipEvent_t EventNative)
3232
: CommandType{UR_COMMAND_EVENTS_WAIT}, RefCount{1}, HasOwnership{false},
3333
HasBeenWaitedOn{false}, IsRecorded{false}, IsStarted{false},
34-
StreamToken{std::numeric_limits<uint32_t>::max()}, EventId{0},
35-
EvEnd{EventNative}, EvStart{nullptr}, EvQueued{nullptr}, Queue{nullptr},
36-
Stream{nullptr}, Context{Context} {
34+
IsInterop{true}, StreamToken{std::numeric_limits<uint32_t>::max()},
35+
EventId{0}, EvEnd{EventNative}, EvStart{nullptr}, EvQueued{nullptr},
36+
Queue{nullptr}, Stream{nullptr}, Context{Context} {
3737
urContextRetain(Context);
3838
}
3939

source/adapters/hip/event.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ struct ur_event_handle_t_ {
4242

4343
bool isCompleted() const;
4444

45+
bool isInterop() const noexcept { return IsInterop; };
46+
4547
uint32_t getExecutionStatus() const {
4648
if (!isRecorded()) {
4749
return UR_EVENT_STATUS_SUBMITTED;
@@ -134,7 +136,8 @@ struct ur_event_handle_t_ {
134136
// yet.
135137
bool IsStarted; // Signifies wether the operation associated with the
136138
// UR event has started or not
137-
//
139+
140+
const bool IsInterop{false}; // Made with urEventCreateWithNativeHandle
138141

139142
uint32_t StreamToken;
140143
uint32_t EventId; // Queue identifier of the event.
@@ -190,7 +193,8 @@ ur_result_t forLatestEvents(const ur_event_handle_t *EventWaitList,
190193
hipStream_t LastSeenStream = 0;
191194
for (size_t i = 0; i < Events.size(); i++) {
192195
auto Event = Events[i];
193-
if (!Event || (i != 0 && Event->getStream() == LastSeenStream)) {
196+
if (!Event || (i != 0 && !Event->isInterop() &&
197+
Event->getStream() == LastSeenStream)) {
194198
continue;
195199
}
196200

0 commit comments

Comments
 (0)