diff --git a/unified-runtime/source/adapters/cuda/command_buffer.cpp b/unified-runtime/source/adapters/cuda/command_buffer.cpp index 2e261d2484c48..f494c7b557538 100644 --- a/unified-runtime/source/adapters/cuda/command_buffer.cpp +++ b/unified-runtime/source/adapters/cuda/command_buffer.cpp @@ -68,10 +68,10 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_( /// all the memory objects allocated for command_buffer managment ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() { // Release the memory allocated to the Context stored in the command_buffer - UR_TRACE(urContextRelease(Context)); + UR_CALL_NOCHECK(urContextRelease(Context)); // Release the device - UR_TRACE(urDeviceRelease(Device)); + UR_CALL_NOCHECK(urDeviceRelease(Device)); } // This may throw so it must be called from within a try...catch diff --git a/unified-runtime/source/adapters/cuda/command_buffer.hpp b/unified-runtime/source/adapters/cuda/command_buffer.hpp index 97d809e5a341f..3a5c3aed361e7 100644 --- a/unified-runtime/source/adapters/cuda/command_buffer.hpp +++ b/unified-runtime/source/adapters/cuda/command_buffer.hpp @@ -18,23 +18,6 @@ #include #include -// Trace an internal UR call -#define UR_TRACE(Call) \ - { \ - ur_result_t Result; \ - UR_CALL(Call, Result); \ - } - -// Trace an internal UR call and return the result to the user. -#define UR_CALL(Call, Result) \ - { \ - if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ - Result = (Call); \ - if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, Result); \ - } - enum class CommandType { Kernel, USMMemcpy, diff --git a/unified-runtime/source/adapters/cuda/common.cpp b/unified-runtime/source/adapters/cuda/common.cpp index 89500d1a1c9a4..880fa00c7fff1 100644 --- a/unified-runtime/source/adapters/cuda/common.cpp +++ b/unified-runtime/source/adapters/cuda/common.cpp @@ -92,11 +92,6 @@ std::string getCudaVersionString() { return stream.str(); } -void detail::ur::die(const char *Message) { - logger::always("ur_die:{}", Message); - std::terminate(); -} - void detail::ur::assertion(bool Condition, const char *Message) { if (!Condition) die(Message); diff --git a/unified-runtime/source/adapters/cuda/common.hpp b/unified-runtime/source/adapters/cuda/common.hpp index a1e89bc3a8dfb..dd7c0ce787065 100644 --- a/unified-runtime/source/adapters/cuda/common.hpp +++ b/unified-runtime/source/adapters/cuda/common.hpp @@ -57,12 +57,6 @@ void setPluginSpecificMessage(CUresult cu_res); namespace detail { namespace ur { -// Report error and no return (keeps compiler from printing warnings). -// TODO: Probably change that to throw a catchable exception, -// but for now it is useful to see every failure. -// -[[noreturn]] void die(const char *Message); - // Reports error messages void cuPrint(const char *Message); diff --git a/unified-runtime/source/adapters/cuda/enqueue.cpp b/unified-runtime/source/adapters/cuda/enqueue.cpp index 9dac5fbac4d65..fb3e1952ed1c9 100644 --- a/unified-runtime/source/adapters/cuda/enqueue.cpp +++ b/unified-runtime/source/adapters/cuda/enqueue.cpp @@ -1104,7 +1104,7 @@ static size_t imageElementByteSize(CUDA_ARRAY_DESCRIPTOR ArrayDesc) { case CU_AD_FORMAT_FLOAT: return 4; default: - detail::ur::die("Invalid image format."); + die("Invalid image format."); return 0; } } diff --git a/unified-runtime/source/adapters/cuda/event.cpp b/unified-runtime/source/adapters/cuda/event.cpp index 37792bf5b2384..d440567ffaac6 100644 --- a/unified-runtime/source/adapters/cuda/event.cpp +++ b/unified-runtime/source/adapters/cuda/event.cpp @@ -113,8 +113,7 @@ ur_result_t ur_event_handle_t_::record() { try { EventID = Queue->getNextEventID(); if (EventID == 0) { - detail::ur::die( - "Unrecoverable program state reached in event identifier overflow"); + die("Unrecoverable program state reached in event identifier overflow"); } UR_CHECK_ERROR(cuEventRecord(EvEnd, Stream)); } catch (ur_result_t error) { diff --git a/unified-runtime/source/adapters/cuda/memory.cpp b/unified-runtime/source/adapters/cuda/memory.cpp index 6e68275f3a9b7..570e772673770 100644 --- a/unified-runtime/source/adapters/cuda/memory.cpp +++ b/unified-runtime/source/adapters/cuda/memory.cpp @@ -118,7 +118,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) { // error for which it is unclear if the function that reported it succeeded // or not. Either way, the state of the program is compromised and likely // unrecoverable. - detail::ur::die("Unrecoverable program state reached in urMemRelease"); + die("Unrecoverable program state reached in urMemRelease"); } return UR_RESULT_SUCCESS; diff --git a/unified-runtime/source/adapters/cuda/queue.cpp b/unified-runtime/source/adapters/cuda/queue.cpp index b9779f37be009..115766c7d1c29 100644 --- a/unified-runtime/source/adapters/cuda/queue.cpp +++ b/unified-runtime/source/adapters/cuda/queue.cpp @@ -279,7 +279,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( else if (CuFlags == CU_STREAM_NON_BLOCKING) Flags = UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; else - detail::ur::die("Unknown cuda stream"); + die("Unknown cuda stream"); std::vector ComputeCuStreams(1, CuStream); std::vector TransferCuStreams(0); diff --git a/unified-runtime/source/adapters/hip/command_buffer.cpp b/unified-runtime/source/adapters/hip/command_buffer.cpp index d384a6c147f70..9c17e12530a87 100644 --- a/unified-runtime/source/adapters/hip/command_buffer.cpp +++ b/unified-runtime/source/adapters/hip/command_buffer.cpp @@ -33,10 +33,10 @@ ur_exp_command_buffer_handle_t_::ur_exp_command_buffer_handle_t_( /// all the memory objects allocated for command_buffer managment ur_exp_command_buffer_handle_t_::~ur_exp_command_buffer_handle_t_() { // Release the memory allocated to the Context stored in the command_buffer - UR_TRACE(urContextRelease(Context)); + UR_CALL_NOCHECK(urContextRelease(Context)); // Release the device - UR_TRACE(urDeviceRelease(Device)); + UR_CALL_NOCHECK(urDeviceRelease(Device)); // Release the memory allocated to the HIPGraph (void)hipGraphDestroy(HIPGraph); diff --git a/unified-runtime/source/adapters/hip/command_buffer.hpp b/unified-runtime/source/adapters/hip/command_buffer.hpp index c5f9489767f58..bc5011003c118 100644 --- a/unified-runtime/source/adapters/hip/command_buffer.hpp +++ b/unified-runtime/source/adapters/hip/command_buffer.hpp @@ -17,23 +17,6 @@ #include #include -// Trace an internal UR call -#define UR_TRACE(Call) \ - { \ - ur_result_t Result; \ - UR_CALL(Call, Result); \ - } - -// Trace an internal UR call and return the result to the user. -#define UR_CALL(Call, Result) \ - { \ - if (PrintTrace) \ - std::cerr << "UR ---> " << #Call << "\n"; \ - Result = (Call); \ - if (PrintTrace) \ - std::cerr << "UR <--- " << #Call << "(" << Result << ")\n"; \ - } - // Handle to a kernel command. // // Struct that stores all the information related to a kernel command in a diff --git a/unified-runtime/source/adapters/hip/common.cpp b/unified-runtime/source/adapters/hip/common.cpp index bfe158fced0ba..78dcc1f4d1ff7 100644 --- a/unified-runtime/source/adapters/hip/common.cpp +++ b/unified-runtime/source/adapters/hip/common.cpp @@ -156,11 +156,6 @@ hipError_t getHipVersionString(std::string &Version) { return Result; } -void detail::ur::die(const char *pMessage) { - logger::always("ur_die: {}", pMessage); - std::terminate(); -} - void detail::ur::assertion(bool Condition, const char *pMessage) { if (!Condition) die(pMessage); diff --git a/unified-runtime/source/adapters/hip/common.hpp b/unified-runtime/source/adapters/hip/common.hpp index 98799d58f53e1..48ef1bd8c78c7 100644 --- a/unified-runtime/source/adapters/hip/common.hpp +++ b/unified-runtime/source/adapters/hip/common.hpp @@ -117,12 +117,6 @@ extern thread_local char ErrorMessage[MaxMessageSize]; namespace detail { namespace ur { -// Report error and no return (keeps compiler from printing warnings). -// TODO: Probably change that to throw a catchable exception, -// but for now it is useful to see every failure. -// -[[noreturn]] void die(const char *pMessage); - // Reports error messages void hipPrint(const char *pMessage); @@ -187,7 +181,7 @@ template class ReleaseGuard { // HIP error for which it is unclear if the function that reported it // succeeded or not. Either way, the state of the program is compromised // and likely unrecoverable. - detail::ur::die("Unrecoverable program state reached in piMemRelease"); + die("Unrecoverable program state reached in piMemRelease"); } } } diff --git a/unified-runtime/source/adapters/hip/event.cpp b/unified-runtime/source/adapters/hip/event.cpp index d971207a6c775..b91340b4ac679 100644 --- a/unified-runtime/source/adapters/hip/event.cpp +++ b/unified-runtime/source/adapters/hip/event.cpp @@ -107,8 +107,7 @@ ur_result_t ur_event_handle_t_::record() { try { EventId = Queue->getNextEventId(); if (EventId == 0) { - detail::ur::die( - "Unrecoverable program state reached in event identifier overflow"); + die("Unrecoverable program state reached in event identifier overflow"); } UR_CHECK_ERROR(hipEventRecord(EvEnd, Stream)); Result = UR_RESULT_SUCCESS; diff --git a/unified-runtime/source/adapters/hip/kernel.cpp b/unified-runtime/source/adapters/hip/kernel.cpp index c5fe0e3357bbb..21535f505bb46 100644 --- a/unified-runtime/source/adapters/hip/kernel.cpp +++ b/unified-runtime/source/adapters/hip/kernel.cpp @@ -328,8 +328,7 @@ urKernelSetArgMemObj(ur_kernel_handle_t hKernel, uint32_t argIndex, if (Format != HIP_AD_FORMAT_UNSIGNED_INT32 && Format != HIP_AD_FORMAT_SIGNED_INT32 && Format != HIP_AD_FORMAT_HALF && Format != HIP_AD_FORMAT_FLOAT) { - detail::ur::die( - "UR HIP kernels only support images with channel types int32, " + die("UR HIP kernels only support images with channel types int32, " "uint32, float, and half."); } hipSurfaceObject_t hipSurf = diff --git a/unified-runtime/source/adapters/hip/memory.cpp b/unified-runtime/source/adapters/hip/memory.cpp index 92d0ec4fbeb41..08df9cdf06734 100644 --- a/unified-runtime/source/adapters/hip/memory.cpp +++ b/unified-runtime/source/adapters/hip/memory.cpp @@ -28,7 +28,7 @@ size_t imageElementByteSize(hipArray_Format ArrayFormat) { case HIP_AD_FORMAT_FLOAT: return 4; default: - detail::ur::die("Invalid HIP format specifier"); + die("Invalid HIP format specifier"); } return 0; } @@ -82,7 +82,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemRelease(ur_mem_handle_t hMem) { // error for which it is unclear if the function that reported it succeeded // or not. Either way, the state of the program is compromised and likely // unrecoverable. - detail::ur::die("Unrecoverable program state reached in urMemRelease"); + die("Unrecoverable program state reached in urMemRelease"); } return UR_RESULT_SUCCESS; @@ -441,7 +441,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urMemImageGetInfo(ur_mem_handle_t hMemory, return UR_IMAGE_CHANNEL_TYPE_FLOAT; default: - detail::ur::die("Invalid Hip format specified."); + die("Invalid Hip format specified."); } }; diff --git a/unified-runtime/source/adapters/hip/memory.hpp b/unified-runtime/source/adapters/hip/memory.hpp index 5b20706b45d0d..3162547552e77 100644 --- a/unified-runtime/source/adapters/hip/memory.hpp +++ b/unified-runtime/source/adapters/hip/memory.hpp @@ -249,7 +249,7 @@ struct SurfaceMem { break; default: // urMemImageCreate given unsupported image_channel_data_type - detail::ur::die("Bad image format given to ur_image_ constructor"); + die("Bad image format given to ur_image_ constructor"); } } diff --git a/unified-runtime/source/adapters/hip/program.cpp b/unified-runtime/source/adapters/hip/program.cpp index ccb08066a10da..d74a5a0785a22 100644 --- a/unified-runtime/source/adapters/hip/program.cpp +++ b/unified-runtime/source/adapters/hip/program.cpp @@ -266,8 +266,8 @@ ur_result_t ur_program_handle_t_::getGlobalVariablePointer( UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(ur_context_handle_t, const void *, size_t, const ur_program_properties_t *, ur_program_handle_t *) { - detail::ur::die("urProgramCreateWithIL not implemented for HIP adapter" - " please use urProgramCreateWithBinary instead"); + die("urProgramCreateWithIL not implemented for HIP adapter" + " please use urProgramCreateWithBinary instead"); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/hip/queue.cpp b/unified-runtime/source/adapters/hip/queue.cpp index 94177e097d4a6..12c96baa0b9ed 100644 --- a/unified-runtime/source/adapters/hip/queue.cpp +++ b/unified-runtime/source/adapters/hip/queue.cpp @@ -313,7 +313,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urQueueCreateWithNativeHandle( else if (HIPFlags == hipStreamNonBlocking) Flags = UR_QUEUE_FLAG_SYNC_WITH_DEFAULT_STREAM; else - detail::ur::die("Unknown hip stream"); + die("Unknown hip stream"); std::vector ComputeHIPStreams(1, HIPStream); std::vector TransferHIPStreams(0); diff --git a/unified-runtime/source/adapters/level_zero/common.hpp b/unified-runtime/source/adapters/level_zero/common.hpp index 4ddd1c49a493c..11b87d9ed276b 100644 --- a/unified-runtime/source/adapters/level_zero/common.hpp +++ b/unified-runtime/source/adapters/level_zero/common.hpp @@ -99,171 +99,6 @@ struct _ur_platform_handle_t; return loaderStable; } -static auto getUrResultString = [](ur_result_t Result) { - switch (Result) { - case UR_RESULT_SUCCESS: - return "UR_RESULT_SUCCESS"; - case UR_RESULT_ERROR_INVALID_OPERATION: - return "UR_RESULT_ERROR_INVALID_OPERATION"; - case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: - return "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; - case UR_RESULT_ERROR_INVALID_QUEUE: - return "UR_RESULT_ERROR_INVALID_QUEUE"; - case UR_RESULT_ERROR_INVALID_VALUE: - return "UR_RESULT_ERROR_INVALID_VALUE"; - case UR_RESULT_ERROR_INVALID_CONTEXT: - return "UR_RESULT_ERROR_INVALID_CONTEXT"; - case UR_RESULT_ERROR_INVALID_PLATFORM: - return "UR_RESULT_ERROR_INVALID_PLATFORM"; - case UR_RESULT_ERROR_INVALID_BINARY: - return "UR_RESULT_ERROR_INVALID_BINARY"; - case UR_RESULT_ERROR_INVALID_PROGRAM: - return "UR_RESULT_ERROR_INVALID_PROGRAM"; - case UR_RESULT_ERROR_INVALID_SAMPLER: - return "UR_RESULT_ERROR_INVALID_SAMPLER"; - case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: - return "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; - case UR_RESULT_ERROR_INVALID_MEM_OBJECT: - return "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; - case UR_RESULT_ERROR_INVALID_EVENT: - return "UR_RESULT_ERROR_INVALID_EVENT"; - case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: - return "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; - case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: - return "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; - case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: - return "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; - case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: - return "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; - case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: - return "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; - case UR_RESULT_ERROR_DEVICE_NOT_FOUND: - return "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; - case UR_RESULT_ERROR_INVALID_DEVICE: - return "UR_RESULT_ERROR_INVALID_DEVICE"; - case UR_RESULT_ERROR_DEVICE_LOST: - return "UR_RESULT_ERROR_DEVICE_LOST"; - case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: - return "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; - case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: - return "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; - case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: - return "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; - case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: - return "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; - case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: - return "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; - case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: - return "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: - return "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; - case UR_RESULT_ERROR_INVALID_KERNEL: - return "UR_RESULT_ERROR_INVALID_KERNEL"; - case UR_RESULT_ERROR_INVALID_KERNEL_NAME: - return "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: - return "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; - case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: - return "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; - case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: - return "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; - case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: - return "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; - case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: - return "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; - case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: - return "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; - case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: - return "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; - case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: - return "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; - case UR_RESULT_ERROR_UNINITIALIZED: - return "UR_RESULT_ERROR_UNINITIALIZED"; - case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: - return "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; - case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: - return "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; - case UR_RESULT_ERROR_OUT_OF_RESOURCES: - return "UR_RESULT_ERROR_OUT_OF_RESOURCES"; - case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: - return "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; - case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: - return "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; - case UR_RESULT_ERROR_UNSUPPORTED_VERSION: - return "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; - case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: - return "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; - case UR_RESULT_ERROR_INVALID_ARGUMENT: - return "UR_RESULT_ERROR_INVALID_ARGUMENT"; - case UR_RESULT_ERROR_INVALID_NULL_HANDLE: - return "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; - case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: - return "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; - case UR_RESULT_ERROR_INVALID_NULL_POINTER: - return "UR_RESULT_ERROR_INVALID_NULL_POINTER"; - case UR_RESULT_ERROR_INVALID_SIZE: - return "UR_RESULT_ERROR_INVALID_SIZE"; - case UR_RESULT_ERROR_UNSUPPORTED_SIZE: - return "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; - case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: - return "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; - case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: - return "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; - case UR_RESULT_ERROR_INVALID_ENUMERATION: - return "UR_RESULT_ERROR_INVALID_ENUMERATION"; - case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: - return "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; - case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: - return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; - case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: - return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; - case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: - return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; - case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: - return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; - case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: - return "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; - case UR_RESULT_ERROR_PROGRAM_UNLINKED: - return "UR_RESULT_ERROR_PROGRAM_UNLINKED"; - case UR_RESULT_ERROR_OVERLAPPING_REGIONS: - return "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; - case UR_RESULT_ERROR_INVALID_HOST_PTR: - return "UR_RESULT_ERROR_INVALID_HOST_PTR"; - case UR_RESULT_ERROR_INVALID_USM_SIZE: - return "UR_RESULT_ERROR_INVALID_USM_SIZE"; - case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: - return "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; - case UR_RESULT_ERROR_ADAPTER_SPECIFIC: - return "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; - default: - return "UR_RESULT_ERROR_UNKNOWN"; - } -}; - -// Trace an internal UR call; returns in case of an error. -#define UR_CALL(Call) \ - { \ - if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ - ur_result_t Result = (Call); \ - if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ - if (Result != UR_RESULT_SUCCESS) \ - return Result; \ - } - -// Trace an internal UR call; throw in case of an error. -#define UR_CALL_THROWS(Call) \ - { \ - if (PrintTrace) \ - logger::always("UR ---> {}", #Call); \ - ur_result_t Result = (Call); \ - if (PrintTrace) \ - logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ - if (Result != UR_RESULT_SUCCESS) \ - throw Result; \ - } - // Controls UR L0 calls tracing. enum UrDebugLevel { UR_L0_DEBUG_NONE = 0x0, @@ -372,11 +207,6 @@ class ZeCall { // setting environment variables. bool setEnvVar(const char *name, const char *value); -// Helper for one-liner validation -#define UR_ASSERT(condition, error) \ - if (!(condition)) \ - return error; - // Returns the ze_structure_type_t to use in .stype of a structured descriptor. // Intentionally not defined; will give an error if no proper specialization template ze_structure_type_t getZeStructureType(); @@ -402,11 +232,6 @@ template struct ZesStruct : public T { // setting environment variables. bool setEnvVar(const char *name, const char *value); -// Helper for one-liner validation -#define UR_ASSERT(condition, error) \ - if (!(condition)) \ - return error; - // Map Level Zero runtime error code to UR error code. ur_result_t ze2urResult(ze_result_t ZeResult); diff --git a/unified-runtime/source/adapters/native_cpu/command_buffer.cpp b/unified-runtime/source/adapters/native_cpu/command_buffer.cpp index e6675ac179dc8..aabdc0efeed59 100644 --- a/unified-runtime/source/adapters/native_cpu/command_buffer.cpp +++ b/unified-runtime/source/adapters/native_cpu/command_buffer.cpp @@ -20,29 +20,29 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferCreateExp( ur_context_handle_t, ur_device_handle_t, const ur_exp_command_buffer_desc_t *, ur_exp_command_buffer_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferRetainExp(ur_exp_command_buffer_handle_t) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferReleaseExp(ur_exp_command_buffer_handle_t) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferFinalizeExp(ur_exp_command_buffer_handle_t) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -52,8 +52,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendKernelLaunchExp( ur_kernel_handle_t *, uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -62,8 +62,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendUSMMemcpyExp( const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -72,8 +72,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyExp( size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -83,8 +83,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urCommandBufferAppendMemBufferCopyRectExp( size_t, size_t, uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -94,8 +94,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteExp( const void *, uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -105,8 +105,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadExp( uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -117,8 +117,8 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferWriteRectExp( uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -129,16 +129,16 @@ ur_result_t UR_APICALL urCommandBufferAppendMemBufferReadRectExp( uint32_t, const ur_exp_command_buffer_sync_point_t *, uint32_t, const ur_event_handle_t *, ur_exp_command_buffer_sync_point_t *, ur_event_handle_t *, ur_exp_command_buffer_command_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } UR_APIEXPORT ur_result_t UR_APICALL urEnqueueCommandBufferExp( ur_queue_handle_t, ur_exp_command_buffer_handle_t, uint32_t, const ur_event_handle_t *, ur_event_handle_t *) { - detail::ur::die("Experimental Command-buffer feature is not " - "implemented for the NativeCPU adapter."); + die("Experimental Command-buffer feature is not " + "implemented for the NativeCPU adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/adapters/native_cpu/common.cpp b/unified-runtime/source/adapters/native_cpu/common.cpp index ab7c7a07ea426..c131483bacc44 100644 --- a/unified-runtime/source/adapters/native_cpu/common.cpp +++ b/unified-runtime/source/adapters/native_cpu/common.cpp @@ -29,8 +29,3 @@ ur_result_t urGetLastResult(ur_platform_handle_t, const char **ppMessage) { *ppMessage = &ErrorMessage[0]; return ErrorMessageCode; } - -void detail::ur::die(const char *pMessage) { - logger::always("ur_die: {}", pMessage); - std::terminate(); -} diff --git a/unified-runtime/source/adapters/native_cpu/common.hpp b/unified-runtime/source/adapters/native_cpu/common.hpp index 14273b7dce6cf..08c572aabc886 100644 --- a/unified-runtime/source/adapters/native_cpu/common.hpp +++ b/unified-runtime/source/adapters/native_cpu/common.hpp @@ -40,19 +40,6 @@ extern thread_local char ErrorMessage[MaxMessageSize]; __FUNCTION__, __LINE__, __FILE__); \ return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; -/// ------ Error handling, matching OpenCL plugin semantics. -/// Taken from other adapter -namespace detail { -namespace ur { - -// Report error and no return (keeps compiler from printing warnings). -// TODO: Probably change that to throw a catchable exception, -// but for now it is useful to see every failure. -// -[[noreturn]] void die(const char *pMessage); -} // namespace ur -} // namespace detail - // Todo: replace this with a common helper once it is available struct RefCounted { std::atomic_uint32_t _refCount; diff --git a/unified-runtime/source/adapters/opencl/common.cpp b/unified-runtime/source/adapters/opencl/common.cpp index a2bd9ed549245..8c2786d7cb32e 100644 --- a/unified-runtime/source/adapters/opencl/common.cpp +++ b/unified-runtime/source/adapters/opencl/common.cpp @@ -106,11 +106,6 @@ ur_result_t mapCLErrorToUR(cl_int Result) { } } -void cl_adapter::die(const char *Message) { - logger::always("ur_die: {}", Message); - std::terminate(); -} - /// Common API for getting the native handle of a UR object /// /// \param URObj is the UR object to get the native handle of diff --git a/unified-runtime/source/adapters/opencl/common.hpp b/unified-runtime/source/adapters/opencl/common.hpp index ed3f44260dfab..d3f4020ce4a54 100644 --- a/unified-runtime/source/adapters/opencl/common.hpp +++ b/unified-runtime/source/adapters/opencl/common.hpp @@ -157,8 +157,6 @@ extern thread_local char ErrorMessage[MaxMessageSize]; [[maybe_unused]] void setErrorMessage(const char *Message, ur_result_t ErrorCode); -[[noreturn]] void die(const char *Message); - template To cast(From Value) { if constexpr (std::is_pointer_v) { diff --git a/unified-runtime/source/adapters/opencl/sampler.cpp b/unified-runtime/source/adapters/opencl/sampler.cpp index a47ba7f894d1f..7dd4fe45216c8 100644 --- a/unified-runtime/source/adapters/opencl/sampler.cpp +++ b/unified-runtime/source/adapters/opencl/sampler.cpp @@ -27,7 +27,7 @@ cl_sampler_info ur2CLSamplerInfo(ur_sampler_info_t URInfo) { #undef CASE default: - cl_adapter::die("Unhandled: ur_sampler_info_t"); + die("Unhandled: ur_sampler_info_t"); } } @@ -48,7 +48,7 @@ cl_addressing_mode ur2CLAddressingMode(ur_sampler_addressing_mode_t Mode) { #undef CASE default: - cl_adapter::die("Unhandled: ur_sampler_addressing_mode_t"); + die("Unhandled: ur_sampler_addressing_mode_t"); } } @@ -65,7 +65,7 @@ cl_filter_mode ur2CLFilterMode(ur_sampler_filter_mode_t Mode) { #undef CASE default: - cl_adapter::die("Unhandled: ur_sampler_filter_mode_t"); + die("Unhandled: ur_sampler_filter_mode_t"); } } @@ -86,7 +86,7 @@ ur_sampler_addressing_mode_t cl2URAddressingMode(cl_addressing_mode Mode) { #undef CASE default: - cl_adapter::die("Unhandled: cl_addressing_mode"); + die("Unhandled: cl_addressing_mode"); } } @@ -102,7 +102,7 @@ ur_sampler_filter_mode_t cl2URFilterMode(cl_filter_mode Mode) { #undef CASE default: - cl_adapter::die("Unhandled: cl_filter_mode"); + die("Unhandled: cl_filter_mode"); } } diff --git a/unified-runtime/source/adapters/opencl/usm_p2p.cpp b/unified-runtime/source/adapters/opencl/usm_p2p.cpp index b0f51eac2bf47..8a264bc11c8bd 100644 --- a/unified-runtime/source/adapters/opencl/usm_p2p.cpp +++ b/unified-runtime/source/adapters/opencl/usm_p2p.cpp @@ -14,8 +14,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PEnablePeerAccessExp([[maybe_unused]] ur_device_handle_t commandDevice, [[maybe_unused]] ur_device_handle_t peerDevice) { - cl_adapter::die( - "Experimental P2P feature is not implemented for OpenCL adapter."); + die("Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -23,8 +22,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PDisablePeerAccessExp([[maybe_unused]] ur_device_handle_t commandDevice, [[maybe_unused]] ur_device_handle_t peerDevice) { - cl_adapter::die( - "Experimental P2P feature is not implemented for OpenCL adapter."); + die("Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } @@ -35,7 +33,6 @@ UR_APIEXPORT ur_result_t UR_APICALL urUsmP2PPeerAccessGetInfoExp( [[maybe_unused]] size_t propSize, [[maybe_unused]] void *pPropValue, [[maybe_unused]] size_t *pPropSizeRet) { - cl_adapter::die( - "Experimental P2P feature is not implemented for OpenCL adapter."); + die("Experimental P2P feature is not implemented for OpenCL adapter."); return UR_RESULT_ERROR_UNSUPPORTED_FEATURE; } diff --git a/unified-runtime/source/loader/layers/sanitizer/sanitizer_common/sanitizer_common.hpp b/unified-runtime/source/loader/layers/sanitizer/sanitizer_common/sanitizer_common.hpp index 2501f769d2ef1..d1a008c1090ba 100644 --- a/unified-runtime/source/loader/layers/sanitizer/sanitizer_common/sanitizer_common.hpp +++ b/unified-runtime/source/loader/layers/sanitizer/sanitizer_common/sanitizer_common.hpp @@ -114,18 +114,6 @@ inline uint64_t GetSizeAndRedzoneSizeForLocal(uint64_t Size, // ================================================================ -// Trace an internal UR call; returns in case of an error. -#define UR_CALL(Call) \ - { \ - if (PrintTrace) \ - getContext()->logger.debug("UR ---> {}", #Call); \ - ur_result_t Result = (Call); \ - if (PrintTrace) \ - getContext()->logger.debug("UR <--- {}({})", #Call, Result); \ - if (Result != UR_RESULT_SUCCESS) \ - return Result; \ - } - using BacktraceFrame = void *; using BacktraceInfo = std::string; diff --git a/unified-runtime/source/ur/ur.hpp b/unified-runtime/source/ur/ur.hpp index ee5644fe2c760..4ac11b3a6748b 100644 --- a/unified-runtime/source/ur/ur.hpp +++ b/unified-runtime/source/ur/ur.hpp @@ -25,8 +25,189 @@ #include +#include "logger/ur_logger.hpp" #include "ur_util.hpp" +// Helper for one-liner validation +#define UR_ASSERT(condition, error) \ + if (!(condition)) \ + return error; + +// Trace an internal UR call; returns in case of an error. +#define UR_CALL(Call) \ + { \ + if (PrintTrace) \ + logger::always("UR ---> {}", #Call); \ + ur_result_t Result = (Call); \ + if (PrintTrace) \ + logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ + if (Result != UR_RESULT_SUCCESS) \ + return Result; \ + } + +// Trace an internal UR call; throw in case of an error. +#define UR_CALL_THROWS(Call) \ + { \ + if (PrintTrace) \ + logger::always("UR ---> {}", #Call); \ + ur_result_t Result = (Call); \ + if (PrintTrace) \ + logger::always("UR <--- {}({})", #Call, getUrResultString(Result)); \ + if (Result != UR_RESULT_SUCCESS) \ + throw Result; \ + } + +// Trace an internal UR call; ignore errors (useful in destructors). +#define UR_CALL_NOCHECK(Call) \ + { \ + if (PrintTrace) \ + logger::always("UR ---> {}", #Call); \ + (void)(Call); \ + if (PrintTrace) \ + logger::always("UR <--- {}({})", #Call); \ + } + +static auto getUrResultString = [](ur_result_t Result) { + switch (Result) { + case UR_RESULT_SUCCESS: + return "UR_RESULT_SUCCESS"; + case UR_RESULT_ERROR_INVALID_OPERATION: + return "UR_RESULT_ERROR_INVALID_OPERATION"; + case UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES: + return "UR_RESULT_ERROR_INVALID_QUEUE_PROPERTIES"; + case UR_RESULT_ERROR_INVALID_QUEUE: + return "UR_RESULT_ERROR_INVALID_QUEUE"; + case UR_RESULT_ERROR_INVALID_VALUE: + return "UR_RESULT_ERROR_INVALID_VALUE"; + case UR_RESULT_ERROR_INVALID_CONTEXT: + return "UR_RESULT_ERROR_INVALID_CONTEXT"; + case UR_RESULT_ERROR_INVALID_PLATFORM: + return "UR_RESULT_ERROR_INVALID_PLATFORM"; + case UR_RESULT_ERROR_INVALID_BINARY: + return "UR_RESULT_ERROR_INVALID_BINARY"; + case UR_RESULT_ERROR_INVALID_PROGRAM: + return "UR_RESULT_ERROR_INVALID_PROGRAM"; + case UR_RESULT_ERROR_INVALID_SAMPLER: + return "UR_RESULT_ERROR_INVALID_SAMPLER"; + case UR_RESULT_ERROR_INVALID_BUFFER_SIZE: + return "UR_RESULT_ERROR_INVALID_BUFFER_SIZE"; + case UR_RESULT_ERROR_INVALID_MEM_OBJECT: + return "UR_RESULT_ERROR_INVALID_MEM_OBJECT"; + case UR_RESULT_ERROR_INVALID_EVENT: + return "UR_RESULT_ERROR_INVALID_EVENT"; + case UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST: + return "UR_RESULT_ERROR_INVALID_EVENT_WAIT_LIST"; + case UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: + return "UR_RESULT_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; + case UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE: + return "UR_RESULT_ERROR_INVALID_WORK_GROUP_SIZE"; + case UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE: + return "UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE"; + case UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE: + return "UR_RESULT_ERROR_PROFILING_INFO_NOT_AVAILABLE"; + case UR_RESULT_ERROR_DEVICE_NOT_FOUND: + return "UR_RESULT_ERROR_DEVICE_NOT_FOUND"; + case UR_RESULT_ERROR_INVALID_DEVICE: + return "UR_RESULT_ERROR_INVALID_DEVICE"; + case UR_RESULT_ERROR_DEVICE_LOST: + return "UR_RESULT_ERROR_DEVICE_LOST"; + case UR_RESULT_ERROR_DEVICE_REQUIRES_RESET: + return "UR_RESULT_ERROR_DEVICE_REQUIRES_RESET"; + case UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE: + return "UR_RESULT_ERROR_DEVICE_IN_LOW_POWER_STATE"; + case UR_RESULT_ERROR_DEVICE_PARTITION_FAILED: + return "UR_RESULT_ERROR_DEVICE_PARTITION_FAILED"; + case UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT: + return "UR_RESULT_ERROR_INVALID_DEVICE_PARTITION_COUNT"; + case UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE: + return "UR_RESULT_ERROR_INVALID_WORK_ITEM_SIZE"; + case UR_RESULT_ERROR_INVALID_WORK_DIMENSION: + return "UR_RESULT_ERROR_INVALID_WORK_DIMENSION"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGS: + return "UR_RESULT_ERROR_INVALID_KERNEL_ARGS"; + case UR_RESULT_ERROR_INVALID_KERNEL: + return "UR_RESULT_ERROR_INVALID_KERNEL"; + case UR_RESULT_ERROR_INVALID_KERNEL_NAME: + return "UR_RESULT_ERROR_INVALID_KERNEL_NAME"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX: + return "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_INDEX"; + case UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE: + return "UR_RESULT_ERROR_INVALID_KERNEL_ARGUMENT_SIZE"; + case UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE: + return "UR_RESULT_ERROR_INVALID_KERNEL_ATTRIBUTE_VALUE"; + case UR_RESULT_ERROR_INVALID_IMAGE_SIZE: + return "UR_RESULT_ERROR_INVALID_IMAGE_SIZE"; + case UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: + return "UR_RESULT_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; + case UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT: + return "UR_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT"; + case UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: + return "UR_RESULT_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; + case UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE: + return "UR_RESULT_ERROR_INVALID_PROGRAM_EXECUTABLE"; + case UR_RESULT_ERROR_UNINITIALIZED: + return "UR_RESULT_ERROR_UNINITIALIZED"; + case UR_RESULT_ERROR_OUT_OF_HOST_MEMORY: + return "UR_RESULT_ERROR_OUT_OF_HOST_MEMORY"; + case UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY: + return "UR_RESULT_ERROR_OUT_OF_DEVICE_MEMORY"; + case UR_RESULT_ERROR_OUT_OF_RESOURCES: + return "UR_RESULT_ERROR_OUT_OF_RESOURCES"; + case UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE: + return "UR_RESULT_ERROR_PROGRAM_BUILD_FAILURE"; + case UR_RESULT_ERROR_PROGRAM_LINK_FAILURE: + return "UR_RESULT_ERROR_PROGRAM_LINK_FAILURE"; + case UR_RESULT_ERROR_UNSUPPORTED_VERSION: + return "UR_RESULT_ERROR_UNSUPPORTED_VERSION"; + case UR_RESULT_ERROR_UNSUPPORTED_FEATURE: + return "UR_RESULT_ERROR_UNSUPPORTED_FEATURE"; + case UR_RESULT_ERROR_INVALID_ARGUMENT: + return "UR_RESULT_ERROR_INVALID_ARGUMENT"; + case UR_RESULT_ERROR_INVALID_NULL_HANDLE: + return "UR_RESULT_ERROR_INVALID_NULL_HANDLE"; + case UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE: + return "UR_RESULT_ERROR_HANDLE_OBJECT_IN_USE"; + case UR_RESULT_ERROR_INVALID_NULL_POINTER: + return "UR_RESULT_ERROR_INVALID_NULL_POINTER"; + case UR_RESULT_ERROR_INVALID_SIZE: + return "UR_RESULT_ERROR_INVALID_SIZE"; + case UR_RESULT_ERROR_UNSUPPORTED_SIZE: + return "UR_RESULT_ERROR_UNSUPPORTED_SIZE"; + case UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT: + return "UR_RESULT_ERROR_UNSUPPORTED_ALIGNMENT"; + case UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT: + return "UR_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT"; + case UR_RESULT_ERROR_INVALID_ENUMERATION: + return "UR_RESULT_ERROR_INVALID_ENUMERATION"; + case UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION: + return "UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION"; + case UR_RESULT_ERROR_INVALID_NATIVE_BINARY: + return "UR_RESULT_ERROR_INVALID_NATIVE_BINARY"; + case UR_RESULT_ERROR_INVALID_GLOBAL_NAME: + return "UR_RESULT_ERROR_INVALID_GLOBAL_NAME"; + case UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE: + return "UR_RESULT_ERROR_FUNCTION_ADDRESS_NOT_AVAILABLE"; + case UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION: + return "UR_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION"; + case UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION: + return "UR_RESULT_ERROR_INVALID_GLOBAL_WIDTH_DIMENSION"; + case UR_RESULT_ERROR_PROGRAM_UNLINKED: + return "UR_RESULT_ERROR_PROGRAM_UNLINKED"; + case UR_RESULT_ERROR_OVERLAPPING_REGIONS: + return "UR_RESULT_ERROR_OVERLAPPING_REGIONS"; + case UR_RESULT_ERROR_INVALID_HOST_PTR: + return "UR_RESULT_ERROR_INVALID_HOST_PTR"; + case UR_RESULT_ERROR_INVALID_USM_SIZE: + return "UR_RESULT_ERROR_INVALID_USM_SIZE"; + case UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE: + return "UR_RESULT_ERROR_OBJECT_ALLOCATION_FAILURE"; + case UR_RESULT_ERROR_ADAPTER_SPECIFIC: + return "UR_RESULT_ERROR_ADAPTER_SPECIFIC"; + default: + return "UR_RESULT_ERROR_UNKNOWN"; + } +}; + template To ur_cast(From Value) { // TODO: see if more sanity checks are possible. assert(sizeof(From) == sizeof(To)); @@ -63,7 +244,7 @@ const ur_command_t UR_EXT_COMMAND_TYPE_USER = // Terminates the process with a catastrophic error message. [[noreturn]] inline void die(const char *Message) { - std::cerr << "die: " << Message << std::endl; + logger::always("ur_die: {}", Message); std::terminate(); } @@ -190,11 +371,6 @@ template struct ZeCache : private T { T *operator->() { return &get(); } }; -// Helper for one-liner validation -#define UR_ASSERT(condition, error) \ - if (!(condition)) \ - return error; - // TODO: populate with target agnostic handling of UR platforms struct _ur_platform {};