@@ -161,45 +161,50 @@ void EventCompletionClbk(RT::PiEvent, pi_int32, void *data) {
161
161
EventImplPtr *Event = (reinterpret_cast <EventImplPtr *>(data));
162
162
RT::PiEvent &EventHandle = (*Event)->getHandleRef ();
163
163
const detail::plugin &Plugin = (*Event)->getPlugin ();
164
- Plugin.call <PiApiKind::piEventSetStatus>(EventHandle, CL_COMPLETE );
164
+ Plugin.call <PiApiKind::piEventSetStatus>(EventHandle, PI_EVENT_COMPLETE );
165
165
delete (Event);
166
166
}
167
167
168
168
// Method prepares PI event's from list sycl::event's
169
169
std::vector<EventImplPtr> Command::prepareEvents (ContextImplPtr Context) {
170
170
std::vector<EventImplPtr> Result;
171
171
std::vector<EventImplPtr> GlueEvents;
172
- for (EventImplPtr &Event : MDepsEvents) {
172
+ for (EventImplPtr &DepEvent : MDepsEvents) {
173
173
// Async work is not supported for host device.
174
- if (Event ->is_host ()) {
175
- Event ->waitInternal ();
174
+ if (DepEvent ->is_host ()) {
175
+ DepEvent ->waitInternal ();
176
176
continue ;
177
177
}
178
178
// The event handle can be null in case of, for example, alloca command,
179
179
// which is currently synchrounious, so don't generate OpenCL event.
180
- if (Event ->getHandleRef () == nullptr ) {
180
+ if (DepEvent ->getHandleRef () == nullptr ) {
181
181
continue ;
182
182
}
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 ();
187
184
185
+ // If contexts don't match - connect them using user event
186
+ if (DepEventContext != Context && !Context->is_host ()) {
188
187
EventImplPtr GlueEvent (new detail::event_impl ());
189
188
GlueEvent->setContextImpl (Context);
189
+ EventImplPtr *GlueEventCopy =
190
+ new EventImplPtr (GlueEvent); // To increase the reference count by 1.
191
+
190
192
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
191
197
Plugin.call <PiApiKind::piEventCreate>(Context->getHandleRef (),
192
198
&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,
197
202
/* void *data=*/ (GlueEventCopy));
198
203
GlueEvents.push_back (GlueEvent);
199
204
Result.push_back (std::move (GlueEvent));
200
205
continue ;
201
206
}
202
- Result.push_back (Event );
207
+ Result.push_back (DepEvent );
203
208
}
204
209
MDepsEvents.insert (MDepsEvents.end (), GlueEvents.begin (), GlueEvents.end ());
205
210
return Result;
0 commit comments