@@ -127,7 +127,9 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
127
127
getPlugin ().call <PiApiKind::piEventRetain>(MEvent);
128
128
}
129
129
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 } {
131
133
if (Queue->is_host ()) {
132
134
MState.store (HES_NotComplete);
133
135
@@ -136,10 +138,8 @@ event_impl::event_impl(const QueueImplPtr &Queue) : MQueue{Queue} {
136
138
if (!MHostProfilingInfo)
137
139
throw runtime_error (" Out of host memory" , PI_OUT_OF_HOST_MEMORY);
138
140
}
139
-
140
141
return ;
141
142
}
142
-
143
143
MState.store (HES_Complete);
144
144
}
145
145
@@ -250,16 +250,23 @@ void event_impl::cleanupCommand(
250
250
detail::Scheduler::getInstance ().cleanupFinishedCommands (std::move (Self));
251
251
}
252
252
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
+
253
261
template <>
254
262
cl_ulong
255
263
event_impl::get_profiling_info<info::event_profiling::command_submit>() const {
264
+ checkProfilingPreconditions ();
256
265
if (!MHostEvent) {
257
266
if (MEvent)
258
267
return get_event_profiling_info<
259
268
info::event_profiling::command_submit>::get (this ->getHandleRef (),
260
269
this ->getPlugin ());
261
- // TODO this should throw an exception if the queue the dummy event is
262
- // bound to does not support profiling info.
263
270
return 0 ;
264
271
}
265
272
if (!MHostProfilingInfo)
@@ -271,13 +278,12 @@ event_impl::get_profiling_info<info::event_profiling::command_submit>() const {
271
278
template <>
272
279
cl_ulong
273
280
event_impl::get_profiling_info<info::event_profiling::command_start>() const {
281
+ checkProfilingPreconditions ();
274
282
if (!MHostEvent) {
275
283
if (MEvent)
276
284
return get_event_profiling_info<
277
285
info::event_profiling::command_start>::get (this ->getHandleRef (),
278
286
this ->getPlugin ());
279
- // TODO this should throw an exception if the queue the dummy event is
280
- // bound to does not support profiling info.
281
287
return 0 ;
282
288
}
283
289
if (!MHostProfilingInfo)
@@ -289,12 +295,11 @@ event_impl::get_profiling_info<info::event_profiling::command_start>() const {
289
295
template <>
290
296
cl_ulong
291
297
event_impl::get_profiling_info<info::event_profiling::command_end>() const {
298
+ checkProfilingPreconditions ();
292
299
if (!MHostEvent) {
293
300
if (MEvent)
294
301
return get_event_profiling_info<info::event_profiling::command_end>::get (
295
302
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.
298
303
return 0 ;
299
304
}
300
305
if (!MHostProfilingInfo)
0 commit comments