diff --git a/sycl/source/detail/cg.hpp b/sycl/source/detail/cg.hpp index 42bd088427dd9..c4ae7d87f4403 100644 --- a/sycl/source/detail/cg.hpp +++ b/sycl/source/detail/cg.hpp @@ -624,6 +624,8 @@ class CGSemaphoreWait : public CG { MExternalSemaphore(ExternalSemaphore), MWaitValue(WaitValue) {} ur_exp_external_semaphore_handle_t getExternalSemaphore() const { + assert(MExternalSemaphore != nullptr && + "MExternalSemaphore has not been defined yet."); return MExternalSemaphore; } std::optional getWaitValue() const { return MWaitValue; } @@ -643,6 +645,10 @@ class CGSemaphoreSignal : public CG { MExternalSemaphore(ExternalSemaphore), MSignalValue(SignalValue) {} ur_exp_external_semaphore_handle_t getExternalSemaphore() const { + if (MExternalSemaphore == nullptr) + throw exception(make_error_code(errc::runtime), + "getExternalSemaphore(): MExternalSemaphore has not been " + "defined yet."); return MExternalSemaphore; } std::optional getSignalValue() const { return MSignalValue; } diff --git a/sycl/source/detail/handler_impl.hpp b/sycl/source/detail/handler_impl.hpp index a306d3c69b498..37a697a57bc2b 100644 --- a/sycl/source/detail/handler_impl.hpp +++ b/sycl/source/detail/handler_impl.hpp @@ -90,13 +90,13 @@ class handler_impl { std::shared_ptr MKernelBundle; - ur_usm_advice_flags_t MAdvice; + ur_usm_advice_flags_t MAdvice = 0; // 2D memory operation information. - size_t MSrcPitch; - size_t MDstPitch; - size_t MWidth; - size_t MHeight; + size_t MSrcPitch = 0; + size_t MDstPitch = 0; + size_t MWidth = 0; + size_t MHeight = 0; /// Offset into a device_global for copy operations. size_t MOffset = 0; @@ -134,7 +134,7 @@ class handler_impl { ur_rect_region_t MCopyExtent = {}; // Extra information for semaphore interoperability - ur_exp_external_semaphore_handle_t MExternalSemaphore; + ur_exp_external_semaphore_handle_t MExternalSemaphore = nullptr; std::optional MWaitValue; std::optional MSignalValue;