diff --git a/sycl/include/sycl/exception.hpp b/sycl/include/sycl/exception.hpp index 95f49a1d5b1b1..971d682ea9443 100644 --- a/sycl/include/sycl/exception.hpp +++ b/sycl/include/sycl/exception.hpp @@ -51,11 +51,14 @@ __SYCL_EXPORT std::error_code make_error_code(sycl::errc E) noexcept; __SYCL_EXPORT const std::error_category &sycl_category() noexcept; namespace detail { +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES __SYCL_EXPORT const char *stringifyErrorCode(int32_t error); inline std::string codeToString(int32_t code) { - return std::to_string(code) + " (" + std::string(stringifyErrorCode(code)) + ")"; + return std::to_string(code) + " (" + std::string(stringifyErrorCode(code)) + + ")"; } +#endif class __SYCL_EXPORT SYCLCategory : public std::error_category { public: @@ -78,17 +81,35 @@ class __SYCL_EXPORT exception : public virtual std::exception { exception() = default; virtual ~exception(); - exception(std::error_code, const char *Msg); + exception(std::error_code Ec, const char *Msg) +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : exception(Ec, nullptr, Msg) {} +#endif + ; exception(std::error_code Ec, const std::string &Msg) : exception(Ec, nullptr, Msg.c_str()) {} - // new SYCL 2020 constructors - exception(std::error_code); + exception(std::error_code Ec) +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : exception(Ec, nullptr, "") {} +#endif + ; + exception(int EV, const std::error_category &ECat, const std::string &WhatArg) - : exception(EV, ECat, WhatArg.c_str()) {} - exception(int, const std::error_category &, const char *); - exception(int, const std::error_category &); + : exception(std::error_code(EV, ECat), nullptr, WhatArg.c_str()) {} + + exception(int EV, const std::error_category &ECat, const char *WhatArg) +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : exception(std::error_code(EV, ECat), nullptr, WhatArg) {} +#endif + ; + + exception(int EV, const std::error_category &ECat) +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES + : exception(std::error_code(EV, ECat), nullptr, "") {} +#endif + ; // context.hpp depends on exception.hpp but we can't define these ctors in // exception.hpp while context is still an incomplete type. @@ -119,6 +140,7 @@ class __SYCL_EXPORT exception : public virtual std::exception { std::error_code MErrC = make_error_code(sycl::errc::invalid); protected: +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES // base constructors used by SYCL 1.2.1 exception subclasses exception(std::error_code Ec, const char *Msg, const int32_t PIErr) : exception(Ec, std::string(Msg), PIErr) {} @@ -127,6 +149,7 @@ class __SYCL_EXPORT exception : public virtual std::exception { : exception(Ec, nullptr, Msg + " " + detail::codeToString(URErr)) { MErr = URErr; } +#endif // base constructor for all SYCL 2020 constructors // exception(context *, std::error_code, const std::string); diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index ae40e16fbe36c..7d83d4ecf68cc 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include diff --git a/sycl/source/detail/ur.cpp b/sycl/source/detail/ur.cpp index 28591df36d19e..42acb792d99d2 100644 --- a/sycl/source/detail/ur.cpp +++ b/sycl/source/detail/ur.cpp @@ -439,6 +439,98 @@ ur_program_metadata_t mapDeviceBinaryPropertyToProgramMetadata( } } // namespace ur + +const char *stringifyErrorCode(int32_t error) { + switch (error) { +#define _UR_ERRC(NAME) \ + case NAME: \ + return #NAME; + // TODO: bring back old code specific messages? +#define _UR_ERRC_WITH_MSG(NAME, MSG) \ + case NAME: \ + return MSG; + _UR_ERRC(UR_RESULT_SUCCESS) + _UR_ERRC(UR_RESULT_ERROR_INVALID_OPERATION) + _UR_ERRC(UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES) + _UR_ERRC(UR_RESULT_ERROR_INVALID_QUEUE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_VALUE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_CONTEXT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_PLATFORM) + _UR_ERRC(UR_RESULT_ERROR_INVALID_BINARY) + _UR_ERRC(UR_RESULT_ERROR_INVALID_PROGRAM) + _UR_ERRC(UR_RESULT_ERROR_INVALID_SAMPLER) + _UR_ERRC(UR_RESULT_ERROR_INVALID_BUFFER_SIZE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_MEM_OBJECT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_EVENT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST) + _UR_ERRC(UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) + _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE) + _UR_ERRC(UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE) + _UR_ERRC(UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_NOT_FOUND) + _UR_ERRC(UR_RESULT_ERROR_INVALID_DEVICE) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_LOST) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_REQUIRES_RESET) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_PARTITION_FAILED) + _UR_ERRC(UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_DIMENSION) + _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL) + _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_NAME) + _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX) + _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_IMAGE_SIZE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR) + _UR_ERRC(UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE) + _UR_ERRC(UR_RESULT_ERROR_UNINITIALIZED) + _UR_ERRC(UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) + _UR_ERRC(UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY) + _UR_ERRC(UR_RESULT_ERROR_OUT_OF_RESOURCES) + _UR_ERRC(UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE) + _UR_ERRC(UR_RESULT_ERROR_PROGRAM_LINK_FAILURE) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_VERSION) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_FEATURE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_ARGUMENT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_NULL_HANDLE) + _UR_ERRC(UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_NULL_POINTER) + _UR_ERRC(UR_RESULT_ERROR_INVALID_SIZE) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_SIZE) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_ENUMERATION) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) + _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT) + _UR_ERRC(UR_RESULT_ERROR_INVALID_NATIVE_BINARY) + _UR_ERRC(UR_RESULT_ERROR_INVALID_GLOBAL_NAME) + _UR_ERRC(UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION) + _UR_ERRC(UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION) + _UR_ERRC(UR_RESULT_ERROR_PROGRAM_UNLINKED) + _UR_ERRC(UR_RESULT_ERROR_OVERLAPPING_REGIONS) + _UR_ERRC(UR_RESULT_ERROR_INVALID_HOST_PTR) + _UR_ERRC(UR_RESULT_ERROR_INVALID_USM_SIZE) + _UR_ERRC(UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE) + _UR_ERRC(UR_RESULT_ERROR_ADAPTER_SPECIFIC) + _UR_ERRC(UR_RESULT_ERROR_LAYER_NOT_PRESENT) + _UR_ERRC(UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS) + _UR_ERRC(UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE) + _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP) + _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP) + _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP) + _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_COMMAND_HANDLE_EXP) + _UR_ERRC(UR_RESULT_ERROR_UNKNOWN) +#undef _UR_ERRC +#undef _UR_ERRC_WITH_MSG + + default: + return "Unknown error code"; + } +} + } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/detail/ur.hpp b/sycl/source/detail/ur.hpp index 0262c24718204..3c2e2612d0616 100644 --- a/sycl/source/detail/ur.hpp +++ b/sycl/source/detail/ur.hpp @@ -16,6 +16,8 @@ #include +#include + #include #include #include @@ -26,6 +28,18 @@ enum class backend : char; namespace detail { class adapter_impl; +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES +__SYCL_EXPORT +#endif +const char *stringifyErrorCode(int32_t error); + +#ifdef __INTEL_PREVIEW_BREAKING_CHANGES +inline std::string codeToString(int32_t code) { + return std::to_string(code) + " (" + std::string(stringifyErrorCode(code)) + + ")"; +} +#endif + namespace ur { void *getURLoaderLibrary(); diff --git a/sycl/source/exception.cpp b/sycl/source/exception.cpp index 19c48886655a0..d16f924818403 100644 --- a/sycl/source/exception.cpp +++ b/sycl/source/exception.cpp @@ -17,6 +17,7 @@ namespace sycl { inline namespace _V1 { +#ifndef __INTEL_PREVIEW_BREAKING_CHANGES exception::exception(std::error_code EC, const char *Msg) : exception(EC, nullptr, Msg) {} @@ -29,6 +30,7 @@ exception::exception(int EV, const std::error_category &ECat, exception::exception(int EV, const std::error_category &ECat) : exception({EV, ECat}, nullptr, "") {} +#endif // protected base constructor for all SYCL 2020 constructors exception::exception(std::error_code EC, std::shared_ptr SharedPtrCtx, @@ -66,98 +68,5 @@ std::error_code make_error_code(sycl::errc Err) noexcept { return {static_cast(Err), sycl_category()}; } -namespace detail { -__SYCL_EXPORT const char *stringifyErrorCode(int32_t error) { - switch (error) { -#define _UR_ERRC(NAME) \ - case NAME: \ - return #NAME; - // TODO: bring back old code specific messages? -#define _UR_ERRC_WITH_MSG(NAME, MSG) \ - case NAME: \ - return MSG; - _UR_ERRC(UR_RESULT_SUCCESS) - _UR_ERRC(UR_RESULT_ERROR_INVALID_OPERATION) - _UR_ERRC(UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES) - _UR_ERRC(UR_RESULT_ERROR_INVALID_QUEUE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_VALUE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_CONTEXT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_PLATFORM) - _UR_ERRC(UR_RESULT_ERROR_INVALID_BINARY) - _UR_ERRC(UR_RESULT_ERROR_INVALID_PROGRAM) - _UR_ERRC(UR_RESULT_ERROR_INVALID_SAMPLER) - _UR_ERRC(UR_RESULT_ERROR_INVALID_BUFFER_SIZE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_MEM_OBJECT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_EVENT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST) - _UR_ERRC(UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET) - _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE) - _UR_ERRC(UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE) - _UR_ERRC(UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_NOT_FOUND) - _UR_ERRC(UR_RESULT_ERROR_INVALID_DEVICE) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_LOST) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_REQUIRES_RESET) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_PARTITION_FAILED) - _UR_ERRC(UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_WORK_DIMENSION) - _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL) - _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_NAME) - _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX) - _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_IMAGE_SIZE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR) - _UR_ERRC(UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE) - _UR_ERRC(UR_RESULT_ERROR_UNINITIALIZED) - _UR_ERRC(UR_RESULT_ERROR_OUT_OF_HOST_MEMORY) - _UR_ERRC(UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY) - _UR_ERRC(UR_RESULT_ERROR_OUT_OF_RESOURCES) - _UR_ERRC(UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE) - _UR_ERRC(UR_RESULT_ERROR_PROGRAM_LINK_FAILURE) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_VERSION) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_FEATURE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_ARGUMENT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_NULL_HANDLE) - _UR_ERRC(UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_NULL_POINTER) - _UR_ERRC(UR_RESULT_ERROR_INVALID_SIZE) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_SIZE) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_ENUMERATION) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) - _UR_ERRC(UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT) - _UR_ERRC(UR_RESULT_ERROR_INVALID_NATIVE_BINARY) - _UR_ERRC(UR_RESULT_ERROR_INVALID_GLOBAL_NAME) - _UR_ERRC(UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION) - _UR_ERRC(UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION) - _UR_ERRC(UR_RESULT_ERROR_PROGRAM_UNLINKED) - _UR_ERRC(UR_RESULT_ERROR_OVERLAPPING_REGIONS) - _UR_ERRC(UR_RESULT_ERROR_INVALID_HOST_PTR) - _UR_ERRC(UR_RESULT_ERROR_INVALID_USM_SIZE) - _UR_ERRC(UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE) - _UR_ERRC(UR_RESULT_ERROR_ADAPTER_SPECIFIC) - _UR_ERRC(UR_RESULT_ERROR_LAYER_NOT_PRESENT) - _UR_ERRC(UR_RESULT_ERROR_IN_EVENT_LIST_EXEC_STATUS) - _UR_ERRC(UR_RESULT_ERROR_DEVICE_NOT_AVAILABLE) - _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_EXP) - _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_EXP) - _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_SYNC_POINT_WAIT_LIST_EXP) - _UR_ERRC(UR_RESULT_ERROR_INVALID_COMMAND_BUFFER_COMMAND_HANDLE_EXP) - _UR_ERRC(UR_RESULT_ERROR_UNKNOWN) -#undef _UR_ERRC -#undef _UR_ERRC_WITH_MSG - - default: - return "Unknown error code"; - } -} -} // namespace detail - } // namespace _V1 } // namespace sycl