Skip to content

Commit 06fec7d

Browse files
fix host profiling info
Signed-off-by: Tikhomirova, Kseniya <[email protected]>
1 parent 18f2c18 commit 06fec7d

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed

sycl/source/detail/event_impl.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
161169
event_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() {
628631
void 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

sycl/source/detail/event_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ class event_impl {
349349
return MEvent && MQueue.expired() && !MIsEnqueued && !MCommand;
350350
}
351351

352-
void markAsHost() { MIsHostEvent = true; }
352+
void markAsHost();
353353

354354
protected:
355355
// When instrumentation is enabled emits trace event for event wait begin and
@@ -360,6 +360,7 @@ class event_impl {
360360
void instrumentationEpilog(void *TelementryEvent, const std::string &Name,
361361
int32_t StreamID, uint64_t IId) const;
362362
void checkProfilingPreconditions() const;
363+
void allocateHostProfilingInfo();
363364

364365
std::atomic<ur_event_handle_t> MEvent = nullptr;
365366
// Stores submission time of command associated with event

0 commit comments

Comments
 (0)