From 014004cf0f7cc21195a4a0ed4f16a003ecb7be72 Mon Sep 17 00:00:00 2001 From: Chris Perkins Date: Fri, 19 Apr 2024 12:46:47 -0700 Subject: [PATCH] [SYCL] event() fail fast (#13419) making event() constructor fail fast if ONEAPI_DEVICE_SELECTOR is malformed. The config::get() call checks/parses env var exactly once, so there should not be any performance penalty for any event but the first. --- sycl/source/detail/event_impl.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 38609e82ed14c..db275248578da 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -50,7 +50,13 @@ class event_impl { /// a device event. event_impl(std::optional State = HES_Complete) : MIsInitialized(false), MHostEvent(State), MIsFlushed(true), - MState(State.value_or(HES_Complete)) {} + MState(State.value_or(HES_Complete)) { + // Need to fail in event() constructor if there are problems with the + // ONEAPI_DEVICE_SELECTOR. Deferring may lead to conficts with noexcept + // event methods. This ::get() call uses static vars to read and parse the + // ODS env var exactly once. + SYCLConfig::get(); + } /// Constructs an event instance from a plug-in event handle. ///