Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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) {}
Expand All @@ -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);
Expand Down
1 change: 1 addition & 0 deletions sycl/source/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <sycl/detail/common.hpp>
#include <sycl/detail/ur.hpp>
#include <sycl/device.hpp>
#include <sycl/exception.hpp>
#include <sycl/ext/oneapi/experimental/root_group.hpp>
#include <sycl/info/info_desc.hpp>
#include <sycl/queue.hpp>
Expand Down
92 changes: 92 additions & 0 deletions sycl/source/detail/ur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions sycl/source/detail/ur.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <ur_api.h>

#include <sycl/detail/export.hpp>

#include <memory>
#include <string>
#include <vector>
Expand All @@ -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();

Expand Down
95 changes: 2 additions & 93 deletions sycl/source/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}

Expand All @@ -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<context> SharedPtrCtx,
Expand Down Expand Up @@ -66,98 +68,5 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
return {static_cast<int>(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
Loading