Skip to content

Commit dbf1c80

Browse files
RuykSteffen Larsen
authored andcommitted
[SYCL] GlueEvent uses now the correct plugins
The SYCL RT code for GlueEvent calls now the right plugin to create the event that triggers the dependency chain. Renamed variables to clarify the source code and avoid confusions between Context and Plugin Signed-off-by: Ruyman Reyes <[email protected]>
1 parent ba29585 commit dbf1c80

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

sycl/source/detail/scheduler/commands.cpp

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,45 +95,50 @@ void EventCompletionClbk(RT::PiEvent, pi_int32, void *data) {
9595
EventImplPtr *Event = (reinterpret_cast<EventImplPtr *>(data));
9696
RT::PiEvent &EventHandle = (*Event)->getHandleRef();
9797
const detail::plugin &Plugin = (*Event)->getPlugin();
98-
Plugin.call<PiApiKind::piEventSetStatus>(EventHandle, CL_COMPLETE);
98+
Plugin.call<PiApiKind::piEventSetStatus>(EventHandle, PI_EVENT_COMPLETE);
9999
delete (Event);
100100
}
101101

102102
// Method prepares PI event's from list sycl::event's
103103
std::vector<EventImplPtr> Command::prepareEvents(ContextImplPtr Context) {
104104
std::vector<EventImplPtr> Result;
105105
std::vector<EventImplPtr> GlueEvents;
106-
for (EventImplPtr &Event : MDepsEvents) {
106+
for (EventImplPtr &DepEvent : MDepsEvents) {
107107
// Async work is not supported for host device.
108-
if (Event->is_host()) {
109-
Event->waitInternal();
108+
if (DepEvent->is_host()) {
109+
DepEvent->waitInternal();
110110
continue;
111111
}
112112
// The event handle can be null in case of, for example, alloca command,
113113
// which is currently synchrounious, so don't generate OpenCL event.
114-
if (Event->getHandleRef() == nullptr) {
114+
if (DepEvent->getHandleRef() == nullptr) {
115115
continue;
116116
}
117-
ContextImplPtr EventContext = Event->getContextImpl();
118-
const detail::plugin &Plugin = Event->getPlugin();
119-
// If contexts don't match - connect them using user event
120-
if (EventContext != Context && !Context->is_host()) {
117+
ContextImplPtr DepEventContext = DepEvent->getContextImpl();
121118

119+
// If contexts don't match - connect them using user event
120+
if (DepEventContext != Context && !Context->is_host()) {
122121
EventImplPtr GlueEvent(new detail::event_impl());
123122
GlueEvent->setContextImpl(Context);
123+
EventImplPtr *GlueEventCopy =
124+
new EventImplPtr(GlueEvent); // To increase the reference count by 1.
125+
124126
RT::PiEvent &GlueEventHandle = GlueEvent->getHandleRef();
127+
auto Plugin = Context->getPlugin();
128+
auto DepPlugin = DepEventContext->getPlugin();
129+
// Add an event on the current context that
130+
// is triggered when the DepEvent is complete
125131
Plugin.call<PiApiKind::piEventCreate>(Context->getHandleRef(),
126132
&GlueEventHandle);
127-
EventImplPtr *GlueEventCopy =
128-
new EventImplPtr(GlueEvent); // To increase the reference count by 1.
129-
Plugin.call<PiApiKind::piEventSetCallback>(
130-
Event->getHandleRef(), CL_COMPLETE, EventCompletionClbk,
133+
134+
DepPlugin.call<PiApiKind::piEventSetCallback>(
135+
DepEvent->getHandleRef(), PI_EVENT_COMPLETE, EventCompletionClbk,
131136
/*void *data=*/(GlueEventCopy));
132137
GlueEvents.push_back(GlueEvent);
133138
Result.push_back(std::move(GlueEvent));
134139
continue;
135140
}
136-
Result.push_back(Event);
141+
Result.push_back(DepEvent);
137142
}
138143
MDepsEvents.insert(MDepsEvents.end(), GlueEvents.begin(), GlueEvents.end());
139144
return Result;

0 commit comments

Comments
 (0)