@@ -158,6 +158,14 @@ event_impl::event_impl(ur_event_handle_t Event, const context &SyclContext)
158158 }
159159}
160160
161+ void event_impl::allocateHostProfilingInfo () {
162+ MHostProfilingInfo.reset (new HostProfilingInfo ());
163+ if (!MHostProfilingInfo)
164+ throw sycl::exception (sycl::make_error_code (sycl::errc::runtime),
165+ " Out of host memory " +
166+ codeToString (UR_RESULT_ERROR_OUT_OF_HOST_MEMORY));
167+ }
168+
161169event_impl::event_impl (const QueueImplPtr &Queue)
162170 : MQueue{Queue}, MIsProfilingEnabled{!Queue || Queue->MIsProfilingEnabled },
163171 MFallbackProfiling{MIsProfilingEnabled && Queue &&
@@ -166,12 +174,7 @@ event_impl::event_impl(const QueueImplPtr &Queue)
166174 this ->setContextImpl (Queue->getContextImplPtr ());
167175 else {
168176 MState.store (HES_NotComplete);
169- MHostProfilingInfo.reset (new HostProfilingInfo ());
170- if (!MHostProfilingInfo)
171- throw sycl::exception (
172- sycl::make_error_code (sycl::errc::runtime),
173- " Out of host memory " +
174- codeToString (UR_RESULT_ERROR_OUT_OF_HOST_MEMORY));
177+ allocateHostProfilingInfo ();
175178 return ;
176179 }
177180 MState.store (HES_Complete);
@@ -628,8 +631,14 @@ bool event_impl::isCompleted() {
628631void event_impl::setCommand (void *Cmd) {
629632 MCommand = Cmd;
630633 auto TypedCommand = static_cast <Command *>(Cmd);
631- if (TypedCommand)
632- MIsHostEvent = TypedCommand->getWorkerContext () == nullptr ;
634+ if (TypedCommand && TypedCommand->getWorkerContext () == nullptr )
635+ markAsHost ();
636+ }
637+
638+ void event_impl::markAsHost () {
639+ MIsHostEvent = true ;
640+ if (!MHostProfilingInfo)
641+ allocateHostProfilingInfo ();
633642}
634643
635644} // namespace detail
0 commit comments