Skip to content

Commit 5d5a792

Browse files
[SYCL] Fix event info queries for dummy non-host events (#3424)
It's possible to obtain a non-device event without an encapsulated pi_event, e.g. as a result of a USM operation on 0 bytes. Handle this case in event information queries.
1 parent 4b5ee53 commit 5d5a792

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

sycl/source/detail/event_impl.cpp

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,13 @@ template <>
226226
cl_ulong
227227
event_impl::get_profiling_info<info::event_profiling::command_submit>() const {
228228
if (!MHostEvent) {
229-
return get_event_profiling_info<info::event_profiling::command_submit>::get(
230-
this->getHandleRef(), this->getPlugin());
229+
if (MEvent)
230+
return get_event_profiling_info<
231+
info::event_profiling::command_submit>::get(this->getHandleRef(),
232+
this->getPlugin());
233+
// TODO this should throw an exception if the queue the dummy event is
234+
// bound to does not support profiling info.
235+
return 0;
231236
}
232237
if (!MHostProfilingInfo)
233238
throw invalid_object_error("Profiling info is not available.",
@@ -239,8 +244,13 @@ template <>
239244
cl_ulong
240245
event_impl::get_profiling_info<info::event_profiling::command_start>() const {
241246
if (!MHostEvent) {
242-
return get_event_profiling_info<info::event_profiling::command_start>::get(
243-
this->getHandleRef(), this->getPlugin());
247+
if (MEvent)
248+
return get_event_profiling_info<
249+
info::event_profiling::command_start>::get(this->getHandleRef(),
250+
this->getPlugin());
251+
// TODO this should throw an exception if the queue the dummy event is
252+
// bound to does not support profiling info.
253+
return 0;
244254
}
245255
if (!MHostProfilingInfo)
246256
throw invalid_object_error("Profiling info is not available.",
@@ -252,8 +262,12 @@ template <>
252262
cl_ulong
253263
event_impl::get_profiling_info<info::event_profiling::command_end>() const {
254264
if (!MHostEvent) {
255-
return get_event_profiling_info<info::event_profiling::command_end>::get(
256-
this->getHandleRef(), this->getPlugin());
265+
if (MEvent)
266+
return get_event_profiling_info<info::event_profiling::command_end>::get(
267+
this->getHandleRef(), this->getPlugin());
268+
// TODO this should throw an exception if the queue the dummy event is
269+
// bound to does not support profiling info.
270+
return 0;
257271
}
258272
if (!MHostProfilingInfo)
259273
throw invalid_object_error("Profiling info is not available.",
@@ -262,7 +276,7 @@ event_impl::get_profiling_info<info::event_profiling::command_end>() const {
262276
}
263277

264278
template <> cl_uint event_impl::get_info<info::event::reference_count>() const {
265-
if (!MHostEvent) {
279+
if (!MHostEvent && MEvent) {
266280
return get_event_info<info::event::reference_count>::get(
267281
this->getHandleRef(), this->getPlugin());
268282
}
@@ -272,7 +286,7 @@ template <> cl_uint event_impl::get_info<info::event::reference_count>() const {
272286
template <>
273287
info::event_command_status
274288
event_impl::get_info<info::event::command_execution_status>() const {
275-
if (!MHostEvent) {
289+
if (!MHostEvent && MEvent) {
276290
return get_event_info<info::event::command_execution_status>::get(
277291
this->getHandleRef(), this->getPlugin());
278292
}

0 commit comments

Comments
 (0)