Skip to content

Commit cd9b90e

Browse files
RuykSteffen Larsen
authored and
Steffen Larsen
committed
[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 <ruyman@codeplay.com>
1 parent b5fd007 commit cd9b90e

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
@@ -161,45 +161,50 @@ void EventCompletionClbk(RT::PiEvent, pi_int32, void *data) {
161161
EventImplPtr *Event = (reinterpret_cast<EventImplPtr *>(data));
162162
RT::PiEvent &EventHandle = (*Event)->getHandleRef();
163163
const detail::plugin &Plugin = (*Event)->getPlugin();
164-
Plugin.call<PiApiKind::piEventSetStatus>(EventHandle, CL_COMPLETE);
164+
Plugin.call<PiApiKind::piEventSetStatus>(EventHandle, PI_EVENT_COMPLETE);
165165
delete (Event);
166166
}
167167

168168
// Method prepares PI event's from list sycl::event's
169169
std::vector<EventImplPtr> Command::prepareEvents(ContextImplPtr Context) {
170170
std::vector<EventImplPtr> Result;
171171
std::vector<EventImplPtr> GlueEvents;
172-
for (EventImplPtr &Event : MDepsEvents) {
172+
for (EventImplPtr &DepEvent : MDepsEvents) {
173173
// Async work is not supported for host device.
174-
if (Event->is_host()) {
175-
Event->waitInternal();
174+
if (DepEvent->is_host()) {
175+
DepEvent->waitInternal();
176176
continue;
177177
}
178178
// The event handle can be null in case of, for example, alloca command,
179179
// which is currently synchrounious, so don't generate OpenCL event.
180-
if (Event->getHandleRef() == nullptr) {
180+
if (DepEvent->getHandleRef() == nullptr) {
181181
continue;
182182
}
183-
ContextImplPtr EventContext = Event->getContextImpl();
184-
const detail::plugin &Plugin = Event->getPlugin();
185-
// If contexts don't match - connect them using user event
186-
if (EventContext != Context && !Context->is_host()) {
183+
ContextImplPtr DepEventContext = DepEvent->getContextImpl();
187184

185+
// If contexts don't match - connect them using user event
186+
if (DepEventContext != Context && !Context->is_host()) {
188187
EventImplPtr GlueEvent(new detail::event_impl());
189188
GlueEvent->setContextImpl(Context);
189+
EventImplPtr *GlueEventCopy =
190+
new EventImplPtr(GlueEvent); // To increase the reference count by 1.
191+
190192
RT::PiEvent &GlueEventHandle = GlueEvent->getHandleRef();
193+
auto Plugin = Context->getPlugin();
194+
auto DepPlugin = DepEventContext->getPlugin();
195+
// Add an event on the current context that
196+
// is triggered when the DepEvent is complete
191197
Plugin.call<PiApiKind::piEventCreate>(Context->getHandleRef(),
192198
&GlueEventHandle);
193-
EventImplPtr *GlueEventCopy =
194-
new EventImplPtr(GlueEvent); // To increase the reference count by 1.
195-
Plugin.call<PiApiKind::piEventSetCallback>(
196-
Event->getHandleRef(), CL_COMPLETE, EventCompletionClbk,
199+
200+
DepPlugin.call<PiApiKind::piEventSetCallback>(
201+
DepEvent->getHandleRef(), PI_EVENT_COMPLETE, EventCompletionClbk,
197202
/*void *data=*/(GlueEventCopy));
198203
GlueEvents.push_back(GlueEvent);
199204
Result.push_back(std::move(GlueEvent));
200205
continue;
201206
}
202-
Result.push_back(Event);
207+
Result.push_back(DepEvent);
203208
}
204209
MDepsEvents.insert(MDepsEvents.end(), GlueEvents.begin(), GlueEvents.end());
205210
return Result;

0 commit comments

Comments
 (0)