From d6459412a45744679d4372579fea69e7ba2139b8 Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Fri, 26 Mar 2021 14:48:16 +0300 Subject: [PATCH 1/2] [SYCL] Fix event info queries for dummy non-host events 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. --- sycl/source/detail/event_impl.cpp | 33 +++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 6689c779eefff..508e9408104bc 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -226,8 +226,14 @@ template <> cl_ulong event_impl::get_profiling_info() const { if (!MHostEvent) { - return get_event_profiling_info::get( - this->getHandleRef(), this->getPlugin()); + if (MEvent) + return get_event_profiling_info< + info::event_profiling::command_submit>::get(this->getHandleRef(), + this->getPlugin()); + else + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", @@ -239,8 +245,14 @@ template <> cl_ulong event_impl::get_profiling_info() const { if (!MHostEvent) { - return get_event_profiling_info::get( - this->getHandleRef(), this->getPlugin()); + if (MEvent) + return get_event_profiling_info< + info::event_profiling::command_start>::get(this->getHandleRef(), + this->getPlugin()); + else + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", @@ -252,8 +264,13 @@ template <> cl_ulong event_impl::get_profiling_info() const { if (!MHostEvent) { - return get_event_profiling_info::get( - this->getHandleRef(), this->getPlugin()); + if (MEvent) + return get_event_profiling_info::get( + this->getHandleRef(), this->getPlugin()); + else + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", @@ -262,7 +279,7 @@ event_impl::get_profiling_info() const { } template <> cl_uint event_impl::get_info() const { - if (!MHostEvent) { + if (!MHostEvent && MEvent) { return get_event_info::get( this->getHandleRef(), this->getPlugin()); } @@ -272,7 +289,7 @@ template <> cl_uint event_impl::get_info() const { template <> info::event_command_status event_impl::get_info() const { - if (!MHostEvent) { + if (!MHostEvent && MEvent) { return get_event_info::get( this->getHandleRef(), this->getPlugin()); } From b03862c44ae159bde470dd2c1015ccc5e8f0aeba Mon Sep 17 00:00:00 2001 From: Sergey Semenov Date: Fri, 26 Mar 2021 15:00:58 +0300 Subject: [PATCH 2/2] Remove else after return --- sycl/source/detail/event_impl.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 508e9408104bc..f6d41c3878584 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -230,10 +230,9 @@ event_impl::get_profiling_info() const { return get_event_profiling_info< info::event_profiling::command_submit>::get(this->getHandleRef(), this->getPlugin()); - else - // TODO this should throw an exception if the queue the dummy event is - // bound to does not support profiling info. - return 0; + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", @@ -249,10 +248,9 @@ event_impl::get_profiling_info() const { return get_event_profiling_info< info::event_profiling::command_start>::get(this->getHandleRef(), this->getPlugin()); - else - // TODO this should throw an exception if the queue the dummy event is - // bound to does not support profiling info. - return 0; + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", @@ -267,10 +265,9 @@ event_impl::get_profiling_info() const { if (MEvent) return get_event_profiling_info::get( this->getHandleRef(), this->getPlugin()); - else - // TODO this should throw an exception if the queue the dummy event is - // bound to does not support profiling info. - return 0; + // TODO this should throw an exception if the queue the dummy event is + // bound to does not support profiling info. + return 0; } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.",