@@ -127,7 +127,9 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
127127 getPlugin ().call <PiApiKind::piEventRetain>(MEvent);
128128}
129129
130- event_impl::event_impl (const QueueImplPtr &Queue) : MQueue{Queue} {
130+ event_impl::event_impl (const QueueImplPtr &Queue)
131+ : MQueue{Queue}, MIsProfilingEnabled{Queue->is_host () ||
132+ Queue->MIsProfilingEnabled } {
131133 if (Queue->is_host ()) {
132134 MState.store (HES_NotComplete);
133135
@@ -136,10 +138,8 @@ event_impl::event_impl(const QueueImplPtr &Queue) : MQueue{Queue} {
136138 if (!MHostProfilingInfo)
137139 throw runtime_error (" Out of host memory" , PI_OUT_OF_HOST_MEMORY);
138140 }
139-
140141 return ;
141142 }
142-
143143 MState.store (HES_Complete);
144144}
145145
@@ -250,16 +250,23 @@ void event_impl::cleanupCommand(
250250 detail::Scheduler::getInstance ().cleanupFinishedCommands (std::move (Self));
251251}
252252
253+ void event_impl::checkProfilingPreconditions () const {
254+ if (!MIsProfilingEnabled) {
255+ throw sycl::exception (make_error_code (sycl::errc::invalid),
256+ " get_profiling_info() can't be used without set "
257+ " 'enable_profiling' queue property" );
258+ }
259+ }
260+
253261template <>
254262cl_ulong
255263event_impl::get_profiling_info<info::event_profiling::command_submit>() const {
264+ checkProfilingPreconditions ();
256265 if (!MHostEvent) {
257266 if (MEvent)
258267 return get_event_profiling_info<
259268 info::event_profiling::command_submit>::get (this ->getHandleRef (),
260269 this ->getPlugin ());
261- // TODO this should throw an exception if the queue the dummy event is
262- // bound to does not support profiling info.
263270 return 0 ;
264271 }
265272 if (!MHostProfilingInfo)
@@ -271,13 +278,12 @@ event_impl::get_profiling_info<info::event_profiling::command_submit>() const {
271278template <>
272279cl_ulong
273280event_impl::get_profiling_info<info::event_profiling::command_start>() const {
281+ checkProfilingPreconditions ();
274282 if (!MHostEvent) {
275283 if (MEvent)
276284 return get_event_profiling_info<
277285 info::event_profiling::command_start>::get (this ->getHandleRef (),
278286 this ->getPlugin ());
279- // TODO this should throw an exception if the queue the dummy event is
280- // bound to does not support profiling info.
281287 return 0 ;
282288 }
283289 if (!MHostProfilingInfo)
@@ -289,12 +295,11 @@ event_impl::get_profiling_info<info::event_profiling::command_start>() const {
289295template <>
290296cl_ulong
291297event_impl::get_profiling_info<info::event_profiling::command_end>() const {
298+ checkProfilingPreconditions ();
292299 if (!MHostEvent) {
293300 if (MEvent)
294301 return get_event_profiling_info<info::event_profiling::command_end>::get (
295302 this ->getHandleRef (), this ->getPlugin ());
296- // TODO this should throw an exception if the queue the dummy event is
297- // bound to does not support profiling info.
298303 return 0 ;
299304 }
300305 if (!MHostProfilingInfo)
0 commit comments