From 12bf4cf3c2321aecefe2e1a799768fc266d4126b Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Fri, 19 Aug 2022 02:21:23 -0700 Subject: [PATCH] [SYCL] Move simple event_impl constructor to header 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 --- sycl/source/detail/event_impl.cpp | 4 ---- sycl/source/detail/event_impl.hpp | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index e261d67a21fc5..77856a2a4d9a1 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -117,10 +117,6 @@ void event_impl::setContextImpl(const ContextImplPtr &Context) { MIsContextInitialized = true; } -event_impl::event_impl(std::optional State) - : MIsInitialized(false), MHostEvent(State), MIsFlushed(true), - MState(State.value_or(HES_Complete)) {} - event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) : MIsContextInitialized(true), MEvent(Event), MContext(detail::getSyclObjImpl(SyclContext)), MHostEvent(false), diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index e13fa267d09d7..f542f9d20a25d 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -46,7 +46,9 @@ class event_impl { /// If the constructed SYCL event is waited on it will complete immediately. /// Normally constructs a host event, use std::nullopt to instead instantiate /// a device event. - event_impl(std::optional State = HES_Complete); + event_impl(std::optional State = HES_Complete) + : MIsInitialized(false), MHostEvent(State), MIsFlushed(true), + MState(State.value_or(HES_Complete)) {} /// Constructs an event instance from a plug-in event handle. ///