Skip to content

Commit 36e7587

Browse files
[SYCL] Move simple event_impl constructor to header (#6611)
On certain systems unittests that uses the event_impl constructor with no arguments may disagree with the event_impl source file on the layout of the default std::optional argument. This can cause unexpected memory accesses when performing operations on the passed argument. This commit works around this issue by moving the body of the constructor to the header. Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 2b50820 commit 36e7587

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

sycl/source/detail/event_impl.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,6 @@ void event_impl::setContextImpl(const ContextImplPtr &Context) {
117117
MIsContextInitialized = true;
118118
}
119119

120-
event_impl::event_impl(std::optional<HostEventState> State)
121-
: MIsInitialized(false), MHostEvent(State), MIsFlushed(true),
122-
MState(State.value_or(HES_Complete)) {}
123-
124120
event_impl::event_impl(RT::PiEvent Event, const context &SyclContext)
125121
: MIsContextInitialized(true), MEvent(Event),
126122
MContext(detail::getSyclObjImpl(SyclContext)), MHostEvent(false),

sycl/source/detail/event_impl.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ class event_impl {
4646
/// If the constructed SYCL event is waited on it will complete immediately.
4747
/// Normally constructs a host event, use std::nullopt to instead instantiate
4848
/// a device event.
49-
event_impl(std::optional<HostEventState> State = HES_Complete);
49+
event_impl(std::optional<HostEventState> State = HES_Complete)
50+
: MIsInitialized(false), MHostEvent(State), MIsFlushed(true),
51+
MState(State.value_or(HES_Complete)) {}
5052

5153
/// Constructs an event instance from a plug-in event handle.
5254
///

0 commit comments

Comments
 (0)