From 902b5acfd9369cdeee623427be99020729d1f036 Mon Sep 17 00:00:00 2001 From: aelovikov-intel Date: Tue, 9 Jul 2024 11:16:22 -0700 Subject: [PATCH] [SYCL] Remove `device_error` exception and its subclasses (#14486) Remove both `compile_program_error` and `invalid_object_error` in a single PR because `getOrBuild` interface uses both and cannot be updated for one without another. --- ...cl_ext_oneapi_accessor_properties.asciidoc | 2 +- ...i_use_pinned_host_memory_property.asciidoc | 2 +- sycl/include/sycl/accessor.hpp | 33 ++++++-------- sycl/include/sycl/buffer.hpp | 37 +++++++-------- sycl/include/sycl/context.hpp | 4 +- .../sycl/detail/property_list_base.hpp | 10 ++--- sycl/include/sycl/event.hpp | 4 +- sycl/include/sycl/exception.hpp | 45 ------------------- .../ext/oneapi/accessor_property_list.hpp | 6 +-- sycl/include/sycl/handler.hpp | 6 +-- sycl/include/sycl/interop_handle.hpp | 22 ++++----- sycl/include/sycl/property_list.hpp | 6 +-- sycl/include/sycl/queue.hpp | 2 +- sycl/include/sycl/sampler.hpp | 4 +- sycl/include/sycl/usm/usm_pointer_info.hpp | 3 +- sycl/source/detail/buffer_impl.hpp | 30 ++++++------- sycl/source/detail/context_impl.cpp | 4 +- sycl/source/detail/context_impl.hpp | 4 +- sycl/source/detail/device_info.hpp | 11 +++-- sycl/source/detail/event_impl.hpp | 4 +- sycl/source/detail/kernel_impl.hpp | 2 +- sycl/source/detail/kernel_program_cache.hpp | 8 ++-- sycl/source/detail/memory_manager.cpp | 9 ++-- .../program_manager/program_manager.cpp | 45 ++++++++++--------- sycl/source/detail/queue_impl.hpp | 14 +++--- sycl/source/detail/sampler_impl.hpp | 4 +- sycl/source/device.cpp | 5 +-- sycl/source/interop_handle.cpp | 4 +- sycl/test-e2e/Basic/event_creation.cpp | 2 +- sycl/test-e2e/Basic/fpga_tests/fpga_queue.cpp | 2 +- sycl/test-e2e/Config/env_vars.cpp | 5 ++- .../DeprecatedFeatures/queue_old_interop.cpp | 2 +- sycl/test-e2e/InlineAsm/include/asmhelper.h | 6 +-- sycl/test-e2e/KernelAndProgram/build-log.cpp | 7 +-- sycl/test/warnings/sycl_2020_deprecations.cpp | 6 --- sycl/unittests/queue/DeviceCheck.cpp | 20 +++++---- 36 files changed, 163 insertions(+), 217 deletions(-) diff --git a/sycl/doc/extensions/supported/sycl_ext_oneapi_accessor_properties.asciidoc b/sycl/doc/extensions/supported/sycl_ext_oneapi_accessor_properties.asciidoc index 72b90ad3bf4f..57be57150514 100644 --- a/sycl/doc/extensions/supported/sycl_ext_oneapi_accessor_properties.asciidoc +++ b/sycl/doc/extensions/supported/sycl_ext_oneapi_accessor_properties.asciidoc @@ -242,7 +242,7 @@ a| template propertyT get_property() const; ``` | Returns a copy of the property of type propertyT that T was constructed with. -Must throw an exception with the errc::invalid_object_error error code if T was not constructed with the propertyT property. +Must throw an exception with the errc::invalid error code if T was not constructed with the propertyT property. Available only if propertyT is not a compile-time-constant property. a| ```c++ diff --git a/sycl/doc/extensions/supported/sycl_ext_oneapi_use_pinned_host_memory_property.asciidoc b/sycl/doc/extensions/supported/sycl_ext_oneapi_use_pinned_host_memory_property.asciidoc index 2371b6d82464..1fa40174a274 100644 --- a/sycl/doc/extensions/supported/sycl_ext_oneapi_use_pinned_host_memory_property.asciidoc +++ b/sycl/doc/extensions/supported/sycl_ext_oneapi_use_pinned_host_memory_property.asciidoc @@ -18,7 +18,7 @@ This document describes an extension that introduces a +sycl::ext::oneapi::prope |Property |Description |`syc::ext::oneapi::property::buffer::use_pinned_host_memory` -| The `use_pinned_host_memory` property adds the requirement that the SYCL runtime must allocate host pinned memory for the `sycl::buffer`. The property cannot be used with the `sycl::buffer` constructors that take hostData parameter, an invalid_object_error SYCL exception must be thrown in this case. +| The `use_pinned_host_memory` property adds the requirement that the SYCL runtime must allocate host pinned memory for the `sycl::buffer`. The property cannot be used with the `sycl::buffer` constructors that take hostData parameter, a SYCL exception with errc::invalid error code must be thrown in this case. |=== == Feature test macro diff --git a/sycl/include/sycl/accessor.hpp b/sycl/include/sycl/accessor.hpp index 1b9371769d82..9d431533a0d1 100644 --- a/sycl/include/sycl/accessor.hpp +++ b/sycl/include/sycl/accessor.hpp @@ -1434,10 +1434,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : addHostAccessorAndWait(AccessorBaseHost::impl.get()); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, BufferRef.get_range())) - throw sycl::invalid_object_error( - "accessor with requested offset and range would exceed the bounds of " - "the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "accessor with requested offset and range would " + "exceed the bounds of the buffer"); initHostAcc(); detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), @@ -1478,10 +1477,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : addHostAccessorAndWait(AccessorBaseHost::impl.get()); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, BufferRef.get_range())) - throw sycl::invalid_object_error( - "accessor with requested offset and range would exceed the bounds of " - "the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "accessor with requested offset and range would " + "exceed the bounds of the buffer"); initHostAcc(); detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), @@ -1549,10 +1547,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : preScreenAccessor(PropertyList); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, BufferRef.get_range())) - throw sycl::invalid_object_error( - "accessor with requested offset and range would exceed the bounds of " - "the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "accessor with requested offset and range would " + "exceed the bounds of the buffer"); initHostAcc(); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); @@ -1593,10 +1590,9 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : preScreenAccessor(PropertyList); if (BufferRef.isOutOfBounds(AccessOffset, AccessRange, BufferRef.get_range())) - throw sycl::invalid_object_error( - "accessor with requested offset and range would exceed the bounds of " - "the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "accessor with requested offset and range would " + "exceed the bounds of the buffer"); initHostAcc(); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); @@ -1946,9 +1942,8 @@ class __SYCL_EBO __SYCL_SPECIAL_CLASS __SYCL_TYPE(accessor) accessor : // check that no_init property is compatible with access mode if (PropertyList.template has_property() && AccessMode == access::mode::read) { - throw sycl::invalid_object_error( - "accessor would cannot be both read_only and no_init", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "accessor cannot be both read_only and no_init"); } } diff --git a/sycl/include/sycl/buffer.hpp b/sycl/include/sycl/buffer.hpp index fe5a17c13a4a..1cfc3581fe0d 100644 --- a/sycl/include/sycl/buffer.hpp +++ b/sycl/include/sycl/buffer.hpp @@ -438,16 +438,14 @@ class buffer : public detail::buffer_plain, dimensions, sizeof(T), detail::rangeToArray(Range).data()); if (b.is_sub_buffer()) - throw sycl::invalid_object_error( - "Cannot create sub buffer from sub buffer.", PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Cannot create sub buffer from sub buffer."); if (isOutOfBounds(baseIndex, subRange, b.Range)) - throw sycl::invalid_object_error( - "Requested sub-buffer size exceeds the size of the parent buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Requested sub-buffer size exceeds the size of the parent buffer"); if (!isContiguousRegion(baseIndex, subRange, b.Range)) - throw sycl::invalid_object_error( - "Requested sub-buffer region is not contiguous", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Requested sub-buffer region is not contiguous"); } buffer(const buffer &rhs, @@ -539,9 +537,8 @@ class buffer : public detail::buffer_plain, id accessOffset = {}, const detail::code_location CodeLoc = detail::code_location::current()) { if (isOutOfBounds(accessOffset, accessRange, this->Range)) - throw sycl::invalid_object_error( - "Requested accessor would exceed the bounds of the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Requested accessor would exceed the bounds of the buffer"); return accessor>( @@ -562,9 +559,8 @@ class buffer : public detail::buffer_plain, detail::code_location:: current()) { if (isOutOfBounds(accessOffset, accessRange, this->Range)) - throw sycl::invalid_object_error( - "Requested accessor would exceed the bounds of the buffer", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Requested accessor would exceed the bounds of the buffer"); return accessor>> reinterpret(range reinterpretRange) const { if (sizeof(ReinterpretT) * reinterpretRange.size() != byte_size()) - throw sycl::invalid_object_error( + throw sycl::exception( + make_error_code(errc::invalid), "Total size in bytes represented by the type and range of the " "reinterpreted SYCL buffer does not equal the total size in bytes " - "represented by the type and range of this SYCL buffer", - PI_ERROR_INVALID_VALUE); + "represented by the type and range of this SYCL buffer"); return buffer:: @@ -692,10 +688,9 @@ class buffer : public detail::buffer_plain, reinterpret() const { long sz = byte_size(); if (sz % sizeof(ReinterpretT) != 0) - throw sycl::invalid_object_error( - "Total byte size of buffer is not evenly divisible by the size of " - "the reinterpreted type", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "Total byte size of buffer is not evenly divisible " + "by the size of the reinterpreted type"); return buffer( impl, range<1>{sz / sizeof(ReinterpretT)}, OffsetInBytes, IsSubBuffer); diff --git a/sycl/include/sycl/context.hpp b/sycl/include/sycl/context.hpp index 2b874cbfca9d..eb4838128fd1 100644 --- a/sycl/include/sycl/context.hpp +++ b/sycl/include/sycl/context.hpp @@ -200,8 +200,8 @@ class __SYCL_EXPORT context : public detail::OwnerLessBase { /// Gets the specified property of this context. /// - /// Throws invalid_object_error if this context does not have a property - /// of type propertyT. + /// Throws an exception with errc::invalid error code if this context does not + /// have a property of type propertyT. /// /// \return a copy of the property of type propertyT. template propertyT get_property() const; diff --git a/sycl/include/sycl/detail/property_list_base.hpp b/sycl/include/sycl/detail/property_list_base.hpp index 042e3044020d..042649a629fe 100644 --- a/sycl/include/sycl/detail/property_list_base.hpp +++ b/sycl/include/sycl/detail/property_list_base.hpp @@ -10,7 +10,7 @@ #include // for PI_ERROR_INVALID_VALUE #include // for DataLessPropKind, Propert... -#include // for invalid_object_error +#include #include // for iter_swap #include // for bitset @@ -92,15 +92,15 @@ class PropertyListBase { get_property_helper() const { const int PropKind = static_cast(PropT::getKind()); if (PropKind >= PropWithDataKind::PropWithDataKindSize) - throw sycl::invalid_object_error("The property is not found", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "The property is not found"); for (const std::shared_ptr &Prop : MPropsWithData) if (Prop->isSame(PropKind)) return *static_cast(Prop.get()); - throw sycl::invalid_object_error("The property is not found", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "The property is not found"); } void add_or_replace_accessor_properties_helper( diff --git a/sycl/include/sycl/event.hpp b/sycl/include/sycl/event.hpp index c4ed0c045aa9..a37a798d1086 100644 --- a/sycl/include/sycl/event.hpp +++ b/sycl/include/sycl/event.hpp @@ -122,8 +122,8 @@ class __SYCL_EXPORT event : public detail::OwnerLessBase { /// call to this member function will block until the requested info is /// available. If the queue which submitted the command group this event is /// associated with was not constructed with the - /// property::queue::enable_profiling property, an invalid_object_error SYCL - /// exception is thrown. + /// property::queue::enable_profiling property, an a SYCL exception with + /// errc::invalid error code is thrown. /// /// \return depends on template parameter. template diff --git a/sycl/include/sycl/exception.hpp b/sycl/include/sycl/exception.hpp index 051eface5364..bfcfeecaacec 100644 --- a/sycl/include/sycl/exception.hpp +++ b/sycl/include/sycl/exception.hpp @@ -203,51 +203,6 @@ class __SYCL2020_DEPRECATED( : runtime_error(make_error_code(errc::kernel_argument), Msg, Err) {} }; -class __SYCL2020_DEPRECATED( - "use sycl::exception with a sycl::errc enum value instead.") device_error - : public exception { -public: - device_error() : exception(make_error_code(errc::invalid)) {} - - device_error(const char *Msg, pi_int32 Err) - : device_error(std::string(Msg), Err) {} - - device_error(const std::string &Msg, pi_int32 Err) - : exception(make_error_code(errc::invalid), Msg, Err) {} - -protected: - device_error(std::error_code Ec) : exception(Ec) {} - - device_error(std::error_code Ec, const std::string &Msg, const pi_int32 PIErr) - : exception(Ec, Msg, PIErr) {} -}; - -class __SYCL2020_DEPRECATED( - "use sycl::exception with a sycl::errc enum value instead.") - compile_program_error : public device_error { -public: - compile_program_error() : device_error(make_error_code(errc::build)) {} - - compile_program_error(const char *Msg, pi_int32 Err) - : compile_program_error(std::string(Msg), Err) {} - - compile_program_error(const std::string &Msg, pi_int32 Err) - : device_error(make_error_code(errc::build), Msg, Err) {} -}; - -class __SYCL2020_DEPRECATED( - "use sycl::exception with a sycl::errc enum value instead.") - invalid_object_error : public device_error { -public: - invalid_object_error() : device_error(make_error_code(errc::invalid)) {} - - invalid_object_error(const char *Msg, pi_int32 Err) - : invalid_object_error(std::string(Msg), Err) {} - - invalid_object_error(const std::string &Msg, pi_int32 Err) - : device_error(make_error_code(errc::invalid), Msg, Err) {} -}; - } // namespace _V1 } // namespace sycl diff --git a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp index 88310eea2e96..413d2b1a867a 100644 --- a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp +++ b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp @@ -13,7 +13,7 @@ #include // for PI_ERROR_INVALID_VALUE #include // for DataLessPropKind, Prop... #include // for PropertyListBase -#include // for invalid_object_error +#include #include // for property_list #include // for bitset @@ -184,8 +184,8 @@ class __SYCL_TYPE(accessor_property_list) accessor_property_list !is_compile_time_property::value>> PropT get_property() const { if (!has_property()) - throw sycl::invalid_object_error("The property is not found", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "The property is not found"); return get_property_helper(); } diff --git a/sycl/include/sycl/handler.hpp b/sycl/include/sycl/handler.hpp index 1a19f26883c7..ee796cb78464 100644 --- a/sycl/include/sycl/handler.hpp +++ b/sycl/include/sycl/handler.hpp @@ -2732,9 +2732,9 @@ class __SYCL_EXPORT handler { static_assert(isValidModeForDestinationAccessor(AccessMode_Dst), "Invalid destination accessor mode for the copy method."); if (Dst.get_size() < Src.get_size()) - throw sycl::invalid_object_error( - "The destination accessor size is too small to copy the memory into.", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception(make_error_code(errc::invalid), + "The destination accessor size is too small to " + "copy the memory into."); if (copyAccToAccHelper(Src, Dst)) return; diff --git a/sycl/include/sycl/interop_handle.hpp b/sycl/include/sycl/interop_handle.hpp index 9839ffd58a6c..b76e27980aa2 100644 --- a/sycl/include/sycl/interop_handle.hpp +++ b/sycl/include/sycl/interop_handle.hpp @@ -17,7 +17,7 @@ #include // for getSyclObjImpl #include // for _pi_mem, pi_native_... #include // for device, device_impl -#include // for invalid_object_error +#include #include // for queue_impl #include // for accessor_property_list #include // for image @@ -71,8 +71,8 @@ class interop_handle { "The method is available only for target::device accessors"); #ifndef __SYCL_DEVICE_ONLY__ if (Backend != get_backend()) - throw invalid_object_error("Incorrect backend argument was passed", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Incorrect backend argument was passed"); const auto *AccBase = static_cast(&Acc); return getMemImpl( detail::getSyclObjImpl(*AccBase).get()); @@ -97,8 +97,8 @@ class interop_handle { IsPlh /*, PropertyListT */> &Acc) const { #ifndef __SYCL_DEVICE_ONLY__ if (Backend != get_backend()) - throw invalid_object_error("Incorrect backend argument was passed", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Incorrect backend argument was passed"); const auto *AccBase = static_cast(&Acc); return getMemImpl(detail::getSyclObjImpl(*AccBase).get()); #else @@ -127,8 +127,8 @@ class interop_handle { // with the error code 'errc::backend_mismatch' when those new exceptions // are ready to be used. if (Backend != get_backend()) - throw invalid_object_error("Incorrect backend argument was passed", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Incorrect backend argument was passed"); int32_t NativeHandleDesc; return reinterpret_cast>( getNativeQueue(NativeHandleDesc)); @@ -150,8 +150,8 @@ class interop_handle { // with the error code 'errc::backend_mismatch' when those new exceptions // are ready to be used. if (Backend != get_backend()) - throw invalid_object_error("Incorrect backend argument was passed", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Incorrect backend argument was passed"); // C-style cast required to allow various native types return (backend_return_t)getNativeDevice(); #else @@ -172,8 +172,8 @@ class interop_handle { // with the error code 'errc::backend_mismatch' when those new exceptions // are ready to be used. if (Backend != get_backend()) - throw invalid_object_error("Incorrect backend argument was passed", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Incorrect backend argument was passed"); return reinterpret_cast>( getNativeContext()); #else diff --git a/sycl/include/sycl/property_list.hpp b/sycl/include/sycl/property_list.hpp index 9fa47fcd0b44..eb0bea63587c 100644 --- a/sycl/include/sycl/property_list.hpp +++ b/sycl/include/sycl/property_list.hpp @@ -11,7 +11,7 @@ #include // for PI_ERROR_INVALID_VALUE #include // for DataLessPropKind, Pro... #include // for PropertyListBase -#include // for invalid_object_error +#include #include // for is_property #include // for bitset @@ -46,8 +46,8 @@ class property_list : protected detail::PropertyListBase { template PropT get_property() const { if (!has_property()) - throw sycl::invalid_object_error("The property is not found", - PI_ERROR_INVALID_VALUE); + throw sycl::exception(make_error_code(errc::invalid), + "The property is not found"); return get_property_helper(); } diff --git a/sycl/include/sycl/queue.hpp b/sycl/include/sycl/queue.hpp index fbcf563ddfaa..5e92ef9aab27 100644 --- a/sycl/include/sycl/queue.hpp +++ b/sycl/include/sycl/queue.hpp @@ -473,7 +473,7 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase { /// \return a copy of the property of type PropertyT that the queue was /// constructed with. If the queue was not constructed with the PropertyT - /// property, an invalid_object_error SYCL exception. + /// property, an SYCL exception with errc::invalid error code. template PropertyT get_property() const; /// Fills the specified memory with the specified pattern. diff --git a/sycl/include/sycl/sampler.hpp b/sycl/include/sycl/sampler.hpp index 13f28b34363b..3d75f271e694 100644 --- a/sycl/include/sycl/sampler.hpp +++ b/sycl/include/sycl/sampler.hpp @@ -96,8 +96,8 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS __SYCL_TYPE(sampler) sampler { /// Gets the specified property of this sampler. /// - /// Throws invalid_object_error if this sampler does not have a property - /// of type propertyT. + /// Throws an exception with errc::invalid if this sampler does not have a + /// property of type propertyT. /// /// \return a copy of the property of type propertyT. template propertyT get_property() const; diff --git a/sycl/include/sycl/usm/usm_pointer_info.hpp b/sycl/include/sycl/usm/usm_pointer_info.hpp index ba45e85d5909..a00e125c019b 100644 --- a/sycl/include/sycl/usm/usm_pointer_info.hpp +++ b/sycl/include/sycl/usm/usm_pointer_info.hpp @@ -24,7 +24,8 @@ class context; __SYCL_EXPORT usm::alloc get_pointer_type(const void *ptr, const context &ctxt); /// Queries the device against which the pointer was allocated -/// Throws an invalid_object_error if ptr is a host allocation. +/// Throws an exception with errc::invalid error code if ptr is a host +/// allocation. /// /// \param ptr is the USM pointer to query /// \param ctxt is the sycl context the ptr was allocated in diff --git a/sycl/source/detail/buffer_impl.hpp b/sycl/source/detail/buffer_impl.hpp index 8408cb0da38a..85a370439cf4 100644 --- a/sycl/source/detail/buffer_impl.hpp +++ b/sycl/source/detail/buffer_impl.hpp @@ -48,9 +48,9 @@ class buffer_impl final : public SYCLMemObjT { : BaseT(SizeInBytes, Props, std::move(Allocator)) { if (Props.has_property()) - throw sycl::invalid_object_error( - "The use_host_ptr property requires host pointer to be provided", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception( + make_error_code(errc::invalid), + "The use_host_ptr property requires host pointer to be provided"); } buffer_impl(void *HostData, size_t SizeInBytes, size_t RequiredAlign, @@ -60,9 +60,9 @@ class buffer_impl final : public SYCLMemObjT { if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) - throw sycl::invalid_object_error( - "The use_pinned_host_memory cannot be used with host pointer", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception( + make_error_code(errc::invalid), + "The use_pinned_host_memory cannot be used with host pointer"); BaseT::handleHostData(HostData, RequiredAlign); } @@ -74,9 +74,9 @@ class buffer_impl final : public SYCLMemObjT { if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) - throw sycl::invalid_object_error( - "The use_pinned_host_memory cannot be used with host pointer", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception( + make_error_code(errc::invalid), + "The use_pinned_host_memory cannot be used with host pointer"); BaseT::handleHostData(HostData, RequiredAlign); } @@ -89,9 +89,9 @@ class buffer_impl final : public SYCLMemObjT { if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) - throw sycl::invalid_object_error( - "The use_pinned_host_memory cannot be used with host pointer", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception( + make_error_code(errc::invalid), + "The use_pinned_host_memory cannot be used with host pointer"); BaseT::handleHostData(std::const_pointer_cast(HostData), RequiredAlign, IsConstPtr); @@ -105,9 +105,9 @@ class buffer_impl final : public SYCLMemObjT { : BaseT(SizeInBytes, Props, std::move(Allocator)) { if (Props.has_property< sycl::ext::oneapi::property::buffer::use_pinned_host_memory>()) - throw sycl::invalid_object_error( - "The use_pinned_host_memory cannot be used with host pointer", - PI_ERROR_INVALID_OPERATION); + throw sycl::exception( + make_error_code(errc::invalid), + "The use_pinned_host_memory cannot be used with host pointer"); BaseT::handleHostData(CopyFromInput, RequiredAlign, IsConstPtr); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index f9e27beb0055..876ca1b2899f 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -511,7 +511,9 @@ std::optional context_impl::getProgramForDevImgs( using BuildState = KernelProgramCache::BuildState; BuildState NewState = BuildRes->waitUntilTransition(); if (NewState == BuildState::BS_Failed) - throw compile_program_error(BuildRes->Error.Msg, BuildRes->Error.Code); + throw detail::set_pi_error( + exception(make_error_code(errc::build), BuildRes->Error.Msg), + BuildRes->Error.Code); assert(NewState == BuildState::BS_Done); return BuildRes->Val; diff --git a/sycl/source/detail/context_impl.hpp b/sycl/source/detail/context_impl.hpp index 9e3beffd4dee..581772521809 100644 --- a/sycl/source/detail/context_impl.hpp +++ b/sycl/source/detail/context_impl.hpp @@ -84,8 +84,8 @@ class context_impl { /// Gets the specified property of this context_impl. /// - /// Throws invalid_object_error if this context_impl does not have a property - /// of type propertyT. + /// Throws an exception with errc::invalid error code if this context_impl + /// does not have a property of type propertyT. /// /// \return a copy of the property of type propertyT. template propertyT get_property() const { diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 5be5a76e68e6..1d10d8864a09 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1050,9 +1050,8 @@ template <> struct get_device_info_impl { Dev->getHandleRef(), PiInfoCode::value, sizeof(result), &result, nullptr); if (result == nullptr) - throw invalid_object_error( - "No parent for device because it is not a subdevice", - PI_ERROR_INVALID_DEVICE); + throw exception(make_error_code(errc::invalid), + "No parent for device because it is not a subdevice"); const auto &Platform = Dev->getPlatformImpl(); return createSyclObjFromImpl( @@ -1260,9 +1259,9 @@ typename Param::return_type get_device_info(const DeviceImplPtr &Dev) { if (std::is_same::value) { if (!Dev->has(aspect::ext_intel_free_memory)) - throw invalid_object_error( - "The device does not have the ext_intel_free_memory aspect", - PI_ERROR_INVALID_DEVICE); + throw exception( + make_error_code(errc::invalid), + "The device does not have the ext_intel_free_memory aspect"); } return get_device_info_impl::get(Dev); } diff --git a/sycl/source/detail/event_impl.hpp b/sycl/source/detail/event_impl.hpp index 02b3dc7831d8..88ba1248771b 100644 --- a/sycl/source/detail/event_impl.hpp +++ b/sycl/source/detail/event_impl.hpp @@ -97,8 +97,8 @@ class event_impl { /// then the call to this member function will block until the requested /// info is available. If the queue which submitted the command group this /// event is associated with was not constructed with the - /// property::queue::enable_profiling property, an invalid_object_error SYCL - /// exception is thrown. + /// property::queue::enable_profiling property, a SYCL exception with + /// errc::invalid error code is thrown. /// /// \return depends on template parameter. template typename Param::return_type get_profiling_info(); diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 29f716806f8c..13627d62ba88 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -72,7 +72,7 @@ class kernel_impl { /// /// If this kernel encapsulates an instance of OpenCL kernel, a valid /// cl_kernel will be returned. If this kernel is a host kernel, - /// an invalid_object_error exception will be thrown. + /// an exception with errc::invalid error code will be thrown. /// /// \return a valid cl_kernel instance cl_kernel get() const { diff --git a/sycl/source/detail/kernel_program_cache.hpp b/sycl/source/detail/kernel_program_cache.hpp index 9daf047502a7..8e17c8bde7d9 100644 --- a/sycl/source/detail/kernel_program_cache.hpp +++ b/sycl/source/detail/kernel_program_cache.hpp @@ -233,7 +233,7 @@ class KernelProgramCache { /// Exception thrown by build procedure are rethrown. /// /// \tparam RetT type of entity to get - /// \tparam ExceptionT type of exception to throw on awaiting thread if the + /// \tparam Errc error code of exception to throw on awaiting thread if the /// building thread fails build step. /// \tparam KeyT key (in cache) to fetch built entity with /// \tparam AcquireFT type of function which will acquire the locked version @@ -247,7 +247,7 @@ class KernelProgramCache { /// /// \return a pointer to cached build result, return value must not be /// nullptr. - template + template auto getOrBuild(GetCachedBuildFT &&GetCachedBuild, BuildFT &&Build) { using BuildState = KernelProgramCache::BuildState; constexpr size_t MaxAttempts = 2; @@ -269,7 +269,9 @@ class KernelProgramCache { if (NewState == BuildState::BS_Failed || AttemptCounter + 1 == MaxAttempts) { if (BuildResult->Error.isFilledIn()) - throw ExceptionT(BuildResult->Error.Msg, BuildResult->Error.Code); + throw detail::set_pi_error( + exception(make_error_code(Errc), BuildResult->Error.Msg), + BuildResult->Error.Code); else throw exception(); } diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 8a6f027dd8e2..c5a24793a342 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -452,10 +452,11 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, pi::cast(ParentMemObj), PI_MEM_FLAGS_ACCESS_RW, PI_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); if (Error == PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) - throw invalid_object_error( - "Specified offset of the sub-buffer being constructed is not a " - "multiple of the memory base address alignment", - PI_ERROR_INVALID_VALUE); + throw detail::set_pi_error( + exception(make_error_code(errc::invalid), + "Specified offset of the sub-buffer being constructed is not " + "a multiple of the memory base address alignment"), + Error); if (Error != PI_SUCCESS) { Plugin->reportPiError(Error, "allocateMemSubBuffer()"); diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index dfec4a811382..d89944699652 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -622,8 +622,7 @@ sycl::detail::pi::PiProgram ProgramManager::getBuiltPIProgram( if (!SYCLConfig::get()) return BuildF(); - auto BuildResult = - Cache.getOrBuild(GetCachedBuildF, BuildF); + auto BuildResult = Cache.getOrBuild(GetCachedBuildF, BuildF); // getOrBuild is not supposed to return nullptr assert(BuildResult != nullptr && "Invalid build result"); @@ -713,8 +712,7 @@ ProgramManager::getOrCreateKernel(const ContextImplPtr &ContextImpl, return make_tuple(Kernel, nullptr, ArgMask, Program); } - auto BuildResult = - Cache.getOrBuild(GetCachedBuildF, BuildF); + auto BuildResult = Cache.getOrBuild(GetCachedBuildF, BuildF); // getOrBuild is not supposed to return nullptr assert(BuildResult != nullptr && "Invalid build result"); const KernelArgMaskPairT &KernelArgMaskPair = BuildResult->Val; @@ -842,8 +840,8 @@ static const char *getDeviceLibFilename(DeviceLibExt Extension, bool Native) { if (LibPair != DeviceLibNames.end()) Lib = Native ? LibPair->second.first : LibPair->second.second; if (Lib == nullptr) - throw compile_program_error("Unhandled (new?) device library extension", - PI_ERROR_INVALID_OPERATION); + throw exception(make_error_code(errc::build), + "Unhandled (new?) device library extension"); return Lib; } @@ -868,8 +866,8 @@ static const std::map DeviceLibExtensionStrs = { static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { auto Ext = DeviceLibExtensionStrs.find(Extension); if (Ext == DeviceLibExtensionStrs.end()) - throw compile_program_error("Unhandled (new?) device library extension", - PI_ERROR_INVALID_OPERATION); + throw exception(make_error_code(errc::build), + "Unhandled (new?) device library extension"); return Ext->second; } @@ -893,8 +891,8 @@ loadDeviceLibFallback(const ContextImplPtr Context, DeviceLibExt Extension, if (!loadDeviceLib(Context, LibFileName, LibProg)) { CachedLibPrograms.erase(LibProgIt); - throw compile_program_error(std::string("Failed to load ") + LibFileName, - PI_ERROR_INVALID_VALUE); + throw exception(make_error_code(errc::build), + std::string("Failed to load ") + LibFileName); } const PluginPtr &Plugin = Context->getPlugin(); @@ -910,8 +908,10 @@ loadDeviceLibFallback(const ContextImplPtr Context, DeviceLibExt Extension, "", 0, nullptr, nullptr, nullptr, nullptr); if (Error != PI_SUCCESS) { CachedLibPrograms.erase(LibProgIt); - throw compile_program_error( - ProgramManager::getProgramBuildLog(LibProg, Context), Error); + throw detail::set_pi_error( + exception(make_error_code(errc::build), + ProgramManager::getProgramBuildLog(LibProg, Context)), + Error); } return LibProg; @@ -1203,8 +1203,10 @@ ProgramManager::ProgramPtr ProgramManager::build( Program.get(), /*num devices =*/1, &Device, Options.c_str(), nullptr, nullptr); if (Error != PI_SUCCESS) - throw compile_program_error(getProgramBuildLog(Program.get(), Context), - Error); + throw detail::set_pi_error( + exception(make_error_code(errc::build), + getProgramBuildLog(Program.get(), Context)), + Error); return Program; } @@ -1235,8 +1237,10 @@ ProgramManager::ProgramPtr ProgramManager::build( if (LinkedProg) { // A non-trivial error occurred during linkage: get a build log, release // an incomplete (but valid) LinkedProg, and throw. - throw compile_program_error(getProgramBuildLog(LinkedProg, Context), - Error); + throw detail::set_pi_error( + exception(make_error_code(errc::build), + getProgramBuildLog(LinkedProg, Context)), + Error); } Plugin->checkPiResult(Error); } @@ -2260,9 +2264,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, return Cache.getOrInsertProgram(CacheKey); }; - // TODO: Throw SYCL2020 style exception - auto BuildResult = - Cache.getOrBuild(GetCachedBuildF, BuildF); + auto BuildResult = Cache.getOrBuild(GetCachedBuildF, BuildF); // getOrBuild is not supposed to return nullptr assert(BuildResult != nullptr && "Invalid build result"); @@ -2285,7 +2287,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, // Change device in the cache key to reduce copying of spec const data. CacheKey.second = PiDeviceAdd; - Cache.getOrBuild(GetCachedBuildF, CacheOtherDevices); + Cache.getOrBuild(GetCachedBuildF, CacheOtherDevices); // getOrBuild is not supposed to return nullptr assert(BuildResult != nullptr && "Invalid build result"); } @@ -2350,8 +2352,7 @@ ProgramManager::getOrCreateKernel(const context &Context, return make_tuple(Kernel, nullptr, ArgMask); } - auto BuildResult = - Cache.getOrBuild(GetCachedBuildF, BuildF); + auto BuildResult = Cache.getOrBuild(GetCachedBuildF, BuildF); // getOrBuild is not supposed to return nullptr assert(BuildResult != nullptr && "Invalid build result"); // If caching is enabled, one copy of the kernel handle will be diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 6e803aae2bcc..bebce75e06be 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -153,16 +153,16 @@ class queue_impl { } if (!Context->isDeviceValid(Device)) { if (Context->getBackend() == backend::opencl) - throw sycl::invalid_object_error( + throw sycl::exception( + make_error_code(errc::invalid), "Queue cannot be constructed with the given context and device " "since the device is not a member of the context (descendants of " - "devices from the context are not supported on OpenCL yet).", - PI_ERROR_INVALID_DEVICE); - throw sycl::invalid_object_error( + "devices from the context are not supported on OpenCL yet)."); + throw sycl::exception( + make_error_code(errc::invalid), "Queue cannot be constructed with the given context and device " "since the device is neither a member of the context nor a " - "descendant of its member.", - PI_ERROR_INVALID_DEVICE); + "descendant of its member."); } const QueueOrder QOrder = @@ -630,7 +630,7 @@ class queue_impl { /// \return a copy of the property of type PropertyT that the queue was /// constructed with. If the queue was not constructed with the PropertyT - /// property, an invalid_object_error SYCL exception. + /// property, a SYCL exception with errc::invalid error code will be thrown. template propertyT get_property() const { return MPropList.get_property(); } diff --git a/sycl/source/detail/sampler_impl.hpp b/sycl/source/detail/sampler_impl.hpp index 4ae318c29ffb..e152e126894e 100644 --- a/sycl/source/detail/sampler_impl.hpp +++ b/sycl/source/detail/sampler_impl.hpp @@ -50,8 +50,8 @@ class sampler_impl { /// Gets the specified property of this sampler_impl. /// - /// Throws invalid_object_error if this sampler_impl does not have a property - /// of type propertyT. + /// Throws an exception with errc::invalid error code if this sampler_impl + /// does not have a property of type propertyT. /// /// \return a copy of the property of type propertyT. template propertyT get_property() const { diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index ef6d9c77865f..c8d80a0dd147 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -134,9 +134,8 @@ device::get_info_impl() const { // have parents, but we don't want to return them. They must pretend to be // parentless root devices. if (impl->isRootDevice()) - throw invalid_object_error( - "No parent for device because it is not a subdevice", - PI_ERROR_INVALID_DEVICE); + throw exception(make_error_code(errc::invalid), + "No parent for device because it is not a subdevice"); else return impl->template get_info(); } diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index cd479493bbae..6aa6a0a05d5e 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -28,8 +28,8 @@ pi_native_handle interop_handle::getNativeMem(detail::Requirement *Req) const { [=](ReqToMem Elem) { return (Elem.first == Req); }); if (Iter == std::end(MMemObjs)) { - throw invalid_object_error("Invalid memory object used inside interop", - PI_ERROR_INVALID_MEM_OBJECT); + throw exception(make_error_code(errc::invalid), + "Invalid memory object used inside interop"); } auto Plugin = MQueue->getPlugin(); diff --git a/sycl/test-e2e/Basic/event_creation.cpp b/sycl/test-e2e/Basic/event_creation.cpp index a5d5d445f291..cee86ebf9346 100644 --- a/sycl/test-e2e/Basic/event_creation.cpp +++ b/sycl/test-e2e/Basic/event_creation.cpp @@ -17,7 +17,7 @@ int main() { try { std::cout << "Create default event" << std::endl; sycl::event e; - } catch (sycl::device_error e) { + } catch (const sycl::exception &e) { std::cout << "Failed to create device for event" << std::endl; } } diff --git a/sycl/test-e2e/Basic/fpga_tests/fpga_queue.cpp b/sycl/test-e2e/Basic/fpga_tests/fpga_queue.cpp index 9a0c1868916d..ebcfee64e970 100644 --- a/sycl/test-e2e/Basic/fpga_tests/fpga_queue.cpp +++ b/sycl/test-e2e/Basic/fpga_tests/fpga_queue.cpp @@ -31,7 +31,7 @@ void GetCLQueue(event sycl_event, std::set &cl_queues) { assert(CL_SUCCESS == error && "Failed to obtain queue from OpenCL event"); cl_queues.insert(cl_queue); - } catch (invalid_object_error e) { + } catch (const exception &e) { std::cout << "Failed to get OpenCL queue from SYCL event: " << e.what() << std::endl; } diff --git a/sycl/test-e2e/Config/env_vars.cpp b/sycl/test-e2e/Config/env_vars.cpp index 97ed4ef884d0..5a892965064d 100644 --- a/sycl/test-e2e/Config/env_vars.cpp +++ b/sycl/test-e2e/Config/env_vars.cpp @@ -33,8 +33,9 @@ int main() { // Exit immediately, otherwise the buffer destructor may actually try to // enqueue the command once again, and throw another exception. exit(0); - } catch (sycl::compile_program_error &e) { - exit(0); + } catch (sycl::exception &e) { + if (e.code() == errc::build) + exit(0); } assert(0 && "Expected exception was *not* thrown"); } else { diff --git a/sycl/test-e2e/DeprecatedFeatures/queue_old_interop.cpp b/sycl/test-e2e/DeprecatedFeatures/queue_old_interop.cpp index 79e8e04d2013..98f36dd106ba 100644 --- a/sycl/test-e2e/DeprecatedFeatures/queue_old_interop.cpp +++ b/sycl/test-e2e/DeprecatedFeatures/queue_old_interop.cpp @@ -36,7 +36,7 @@ int main() { queue q; print_queue_info(q); - } catch (device_error e) { + } catch (const exception &e) { std::cout << "Failed to create device for context" << std::endl; } diff --git a/sycl/test-e2e/InlineAsm/include/asmhelper.h b/sycl/test-e2e/InlineAsm/include/asmhelper.h index ac9005afbc6b..bdeec6b2bfba 100644 --- a/sycl/test-e2e/InlineAsm/include/asmhelper.h +++ b/sycl/test-e2e/InlineAsm/include/asmhelper.h @@ -131,10 +131,8 @@ bool launchInlineASMTest(F &f, const std::vector &RequiredSGSizes = {}, try { result = launchInlineASMTestImpl(f, RequiredSGSizes); } catch (sycl::exception &e) { - std::string what = e.what(); - if (exception_expected && - what.find("PI_ERROR_BUILD_PROGRAM_FAILURE") != std::string::npos) { - std::cout << "Caught expected exception: " << what << std::endl; + if (exception_expected && e.code() == sycl::errc::build) { + std::cout << "Caught expected exception." << std::endl; } else { std::cout << "Caught unexpected exception." << std::endl; throw e; diff --git a/sycl/test-e2e/KernelAndProgram/build-log.cpp b/sycl/test-e2e/KernelAndProgram/build-log.cpp index 02dd5dfde893..65c71e1e4697 100644 --- a/sycl/test-e2e/KernelAndProgram/build-log.cpp +++ b/sycl/test-e2e/KernelAndProgram/build-log.cpp @@ -21,8 +21,9 @@ void symbol_that_does_not_exist(); void test() { sycl::queue Queue; - // Submitting this kernel should result in a compile_program_error exception - // with a message indicating "PI_ERROR_BUILD_PROGRAM_FAILURE". + // Submitting this kernel should result in an exception with error code + // `sycl::errc::build` and a message indicating + // "PI_ERROR_BUILD_PROGRAM_FAILURE". auto Kernel = []() { #ifdef __SYCL_DEVICE_ONLY__ #ifdef GPU @@ -45,7 +46,7 @@ void test() { std::cerr << Msg << std::endl; assert(e.code() == sycl::errc::build && "Caught exception was not a compilation error"); - assert(Msg.find("PI_ERROR_BUILD_PROGRAM_FAILURE") != std::string::npos); + assert(sycl::detail::get_pi_error(e) == PI_ERROR_BUILD_PROGRAM_FAILURE); } catch (...) { assert(false && "Caught exception was not a compilation error"); } diff --git a/sycl/test/warnings/sycl_2020_deprecations.cpp b/sycl/test/warnings/sycl_2020_deprecations.cpp index 75fe799ff889..c9df81f8b306 100644 --- a/sycl/test/warnings/sycl_2020_deprecations.cpp +++ b/sycl/test/warnings/sycl_2020_deprecations.cpp @@ -91,12 +91,6 @@ int main() { sycl::nd_range_error ne; // expected-warning@+1 {{'invalid_parameter_error' is deprecated: use sycl::exception with a sycl::errc enum value instead.}} sycl::invalid_parameter_error ipe; - // expected-warning@+1 {{'device_error' is deprecated: use sycl::exception with a sycl::errc enum value instead.}} - sycl::device_error de; - // expected-warning@+1 {{'compile_program_error' is deprecated: use sycl::exception with a sycl::errc enum value instead.}} - sycl::compile_program_error cpe; - // expected-warning@+1 {{'invalid_object_error' is deprecated: use sycl::exception with a sycl::errc enum value instead.}} - sycl::invalid_object_error ioe; // expected-warning@+1{{'exception' is deprecated: The version of an exception constructor which takes no arguments is deprecated.}} sycl::exception ex; diff --git a/sycl/unittests/queue/DeviceCheck.cpp b/sycl/unittests/queue/DeviceCheck.cpp index 68c188e559cd..f934c8ba333e 100644 --- a/sycl/unittests/queue/DeviceCheck.cpp +++ b/sycl/unittests/queue/DeviceCheck.cpp @@ -104,15 +104,16 @@ TEST(QueueDeviceCheck, CheckDeviceRestriction) { try { queue Q2{DefaultCtx, Subdevices[0]}; EXPECT_NE(Q.get_backend(), backend::opencl); - } catch (sycl::invalid_object_error &e) { + } catch (sycl::exception &e) { + EXPECT_TRUE(e.code() == errc::invalid); EXPECT_EQ(Q.get_backend(), backend::opencl); - EXPECT_EQ(std::strcmp( - e.what(), - "Queue cannot be constructed with the given context and " - "device since the device is not a member of the context " - "(descendants of devices from the context are not " - "supported on OpenCL yet). -33 (PI_ERROR_INVALID_DEVICE)"), - 0); + EXPECT_EQ( + std::strcmp(e.what(), + "Queue cannot be constructed with the given context and " + "device since the device is not a member of the context " + "(descendants of devices from the context are not " + "supported on OpenCL yet)."), + 0); } } // Device is neither of the two. @@ -126,7 +127,8 @@ TEST(QueueDeviceCheck, CheckDeviceRestriction) { try { queue Q2{DefaultCtx, Device}; EXPECT_TRUE(false); - } catch (sycl::invalid_object_error &e) { + } catch (sycl::exception &e) { + EXPECT_TRUE(e.code() == errc::invalid); EXPECT_NE( std::strstr(e.what(), "Queue cannot be constructed with the given context and "