diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index 26a1624c56d46..e39268fcad55f 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -447,7 +447,7 @@ class image_accessor void checkDeviceFeatureSupported(const device &Device) { if (!Device.get_info()) throw feature_not_supported("Images are not supported by this device.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } #ifdef __SYCL_DEVICE_ONLY__ @@ -469,7 +469,7 @@ class image_accessor sycl::vec getRangeInternal() const { // TODO: Implement for host. throw runtime_error("image::getRangeInternal() is not implemented for host", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); return sycl::vec{1}; } @@ -1461,7 +1461,7 @@ class __SYCL_SPECIAL_CLASS accessor : throw sycl::invalid_object_error( "accessor with requested offset and range would exceed the bounds of " "the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (!IsPlaceH) addHostAccessorAndWait(AccessorBaseHost::impl.get()); @@ -1502,7 +1502,7 @@ class __SYCL_SPECIAL_CLASS accessor : throw sycl::invalid_object_error( "accessor with requested offset and range would exceed the bounds of " "the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (!IsPlaceH) addHostAccessorAndWait(AccessorBaseHost::impl.get()); @@ -1574,7 +1574,7 @@ class __SYCL_SPECIAL_CLASS accessor : throw sycl::invalid_object_error( "accessor with requested offset and range would exceed the bounds of " "the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), @@ -1614,7 +1614,7 @@ class __SYCL_SPECIAL_CLASS accessor : throw sycl::invalid_object_error( "accessor with requested offset and range would exceed the bounds of " "the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); detail::associateWithHandler(CommandGroupHandler, this, AccessTarget); detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(), @@ -1816,14 +1816,14 @@ class __SYCL_SPECIAL_CLASS accessor : throw sycl::invalid_object_error( "SYCL buffer size is zero. To create a device accessor, SYCL " "buffer size must be greater than zero.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // 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_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } diff --git a/sycl/include/CL/sycl/backend.hpp b/sycl/include/CL/sycl/backend.hpp index 23a3ff2eb5af1..9eb8f6bc57ef8 100644 --- a/sycl/include/CL/sycl/backend.hpp +++ b/sycl/include/CL/sycl/backend.hpp @@ -110,7 +110,7 @@ auto get_native_buffer(const buffer &Obj) throw sycl::runtime_error( errc::feature_not_supported, "Buffer interop is not supported by level zero yet", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); return Obj.template getNative(); } } // namespace detail @@ -121,7 +121,7 @@ auto get_native(const SyclObjectT &Obj) // TODO use SYCL 2020 exception when implemented if (Obj.get_backend() != BackendName) { throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } return Obj.template get_native(); } @@ -157,7 +157,7 @@ get_native(const event &Obj) { // TODO use SYCL 2020 exception when implemented if (Obj.get_backend() != backend::opencl) { throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } backend_return_t ReturnValue; for (auto const &element : Obj.getNativeVector()) { @@ -180,7 +180,7 @@ inline backend_return_t get_native< // TODO use SYCL 2020 exception when implemented if (Obj.get_backend() != backend::opencl) { throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } return reinterpret_cast< typename detail::interop::type>(Obj.getNative()); diff --git a/sycl/include/CL/sycl/buffer.hpp b/sycl/include/CL/sycl/buffer.hpp index 073ae0d3ab0a9..26ad7fb8c25cd 100644 --- a/sycl/include/CL/sycl/buffer.hpp +++ b/sycl/include/CL/sycl/buffer.hpp @@ -329,14 +329,15 @@ class buffer { if (b.is_sub_buffer()) throw cl::sycl::invalid_object_error( - "Cannot create sub buffer from sub buffer.", PI_INVALID_VALUE); + "Cannot create sub buffer from sub buffer.", PI_ERROR_INVALID_VALUE); if (isOutOfBounds(baseIndex, subRange, b.Range)) throw cl::sycl::invalid_object_error( "Requested sub-buffer size exceeds the size of the parent buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (!isContiguousRegion(baseIndex, subRange, b.Range)) throw cl::sycl::invalid_object_error( - "Requested sub-buffer region is not contiguous", PI_INVALID_VALUE); + "Requested sub-buffer region is not contiguous", + PI_ERROR_INVALID_VALUE); } #ifdef __SYCL_INTERNAL_API @@ -435,7 +436,7 @@ class buffer { if (isOutOfBounds(accessOffset, accessRange, this->Range)) throw cl::sycl::invalid_object_error( "Requested accessor would exceed the bounds of the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return accessor>( @@ -451,7 +452,7 @@ class buffer { if (isOutOfBounds(accessOffset, accessRange, this->Range)) throw cl::sycl::invalid_object_error( "Requested accessor would exceed the bounds of the buffer", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return accessor( impl, reinterpretRange, OffsetInBytes, IsSubBuffer); @@ -524,7 +525,7 @@ class buffer { throw cl::sycl::invalid_object_error( "Total byte size of buffer is not evenly divisible by the size of " "the reinterpreted type", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return buffer( impl, range<1>{sz / sizeof(ReinterpretT)}, OffsetInBytes, IsSubBuffer); diff --git a/sycl/include/CL/sycl/detail/array.hpp b/sycl/include/CL/sycl/detail/array.hpp index 5418f41a1faf1..53bfee160514e 100644 --- a/sycl/include/CL/sycl/detail/array.hpp +++ b/sycl/include/CL/sycl/detail/array.hpp @@ -112,7 +112,7 @@ template class array { #ifndef __SYCL_DEVICE_ONLY__ if (dimension >= dimensions || dimension < 0) { throw cl::sycl::invalid_parameter_error("Index out of range", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } #endif (void)dimension; diff --git a/sycl/include/CL/sycl/detail/backend_traits_level_zero.hpp b/sycl/include/CL/sycl/detail/backend_traits_level_zero.hpp index 90860f820ae2b..ca9b7ab77d70a 100644 --- a/sycl/include/CL/sycl/detail/backend_traits_level_zero.hpp +++ b/sycl/include/CL/sycl/detail/backend_traits_level_zero.hpp @@ -140,7 +140,7 @@ struct OptionalDevice { operator device() const { if (!DeviceImpl) - throw runtime_error("No device has been set.", PI_INVALID_DEVICE); + throw runtime_error("No device has been set.", PI_ERROR_INVALID_DEVICE); return createSyclObjFromImpl(DeviceImpl); } diff --git a/sycl/include/CL/sycl/detail/buffer_impl.hpp b/sycl/include/CL/sycl/detail/buffer_impl.hpp index 8e37ed1d7710f..8e31cb1ecf792 100644 --- a/sycl/include/CL/sycl/detail/buffer_impl.hpp +++ b/sycl/include/CL/sycl/detail/buffer_impl.hpp @@ -50,7 +50,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { if (Props.has_property()) throw sycl::invalid_object_error( "The use_host_ptr property requires host pointer to be provided", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } buffer_impl(void *HostData, size_t SizeInBytes, size_t RequiredAlign, @@ -62,7 +62,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { 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_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); BaseT::handleHostData(HostData, RequiredAlign); } @@ -76,7 +76,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { 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_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); BaseT::handleHostData(HostData, RequiredAlign); } @@ -91,7 +91,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { 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_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); BaseT::handleHostData(HostData, RequiredAlign); } @@ -111,7 +111,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { throw sycl::invalid_object_error( "Buffer constructor from a pair of iterator values cannot have the " "use_host_ptr property.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); BaseT::handleHostData(First, Last, RequiredAlign); } @@ -131,7 +131,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT { throw sycl::invalid_object_error( "Buffer constructor from a pair of iterator values cannot have the " "use_host_ptr property.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); BaseT::handleHostData(First, Last, RequiredAlign); } diff --git a/sycl/include/CL/sycl/detail/cg_types.hpp b/sycl/include/CL/sycl/detail/cg_types.hpp index 7f22edae17fd4..8d967e1a92edd 100644 --- a/sycl/include/CL/sycl/detail/cg_types.hpp +++ b/sycl/include/CL/sycl/detail/cg_types.hpp @@ -364,7 +364,7 @@ class HostKernel : public HostKernelBase { if (NDRDesc.LocalSize[I] == 0 || NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0) throw sycl::nd_range_error("Invalid local size for global size", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } @@ -406,7 +406,7 @@ class HostKernel : public HostKernelBase { if (NDRDesc.LocalSize[I] == 0 || NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0) throw sycl::nd_range_error("Invalid local size for global size", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); NGroups[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } diff --git a/sycl/include/CL/sycl/detail/image_accessor_util.hpp b/sycl/include/CL/sycl/detail/image_accessor_util.hpp index 1c81c0671525f..151082445366a 100644 --- a/sycl/include/CL/sycl/detail/image_accessor_util.hpp +++ b/sycl/include/CL/sycl/detail/image_accessor_util.hpp @@ -298,7 +298,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_uint4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } @@ -320,7 +320,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_int4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } @@ -402,7 +402,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_float4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); case image_channel_type::fp16: // Host has conversion from float to half with accuracy as required in // section 8.3.2 OpenCL spec. @@ -445,7 +445,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " "to cl_half4.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -458,7 +458,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::invalid_parameter_error( "Datatype to read- cl_half4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); case image_channel_type::fp16: RetData = PixelData.template convert(); return; @@ -466,7 +466,7 @@ void convertReadData(const vec PixelData, throw cl::sycl::invalid_parameter_error( "Datatype to read - cl_half4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } RetData = RetDataFloat.template convert(); } @@ -506,7 +506,7 @@ convertWriteData(const vec WriteData, throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_uint4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } @@ -539,7 +539,7 @@ convertWriteData(const vec WriteData, throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_int4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } @@ -578,7 +578,7 @@ convertWriteData(const vec WriteData, throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " "to cl_float4.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); case image_channel_type::unorm_short_555: // TODO: Missing information in OpenCL spec. // Check if the below code is correct after the spec is updated. @@ -621,7 +621,7 @@ convertWriteData(const vec WriteData, throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_float4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); case image_channel_type::fp16: // Host has conversion from float to half with accuracy as required in // section 8.3.2 OpenCL spec. @@ -656,7 +656,7 @@ convertWriteData(const vec WriteData, throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " "to cl_half4.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -669,14 +669,14 @@ convertWriteData(const vec WriteData, throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_float4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); case image_channel_type::fp16: return WriteData.convert(); case image_channel_type::fp32: throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_float4 is incompatible with the " "image_channel_type of the image.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } @@ -1043,7 +1043,7 @@ DataT imageReadSamplerHostImpl(const CoordT &Coords, const sampler &Smpl, "Sampler used with unsupported configuration of " "mirrored_repeat/repeat filtering mode with unnormalized " "coordinates. ", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); case addressing_mode::clamp_to_edge: case addressing_mode::clamp: case addressing_mode::none: diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index b468e832efd7f..ad2a929b23071 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -45,23 +45,26 @@ // 7.9 Added new context and ownership arguments to // piextMemCreateWithNativeHandle. // 8.10 Added new optional device argument to piextQueueCreateWithNativeHandle -// -#include "CL/cl.h" -#define _PI_H_VERSION_MAJOR 8 -#define _PI_H_VERSION_MINOR 10 +// 9.11 Use values of OpenCL enums directly, rather than including ``; +// NOTE that this results in a changed API for `piProgramGetBuildInfo`. + +#define _PI_H_VERSION_MAJOR 9 +#define _PI_H_VERSION_MINOR 11 #define _PI_STRING_HELPER(a) #a #define _PI_CONCAT(a, b) _PI_STRING_HELPER(a.b) #define _PI_H_VERSION_STRING \ _PI_CONCAT(_PI_H_VERSION_MAJOR, _PI_H_VERSION_MINOR) -// TODO: we need a mapping of PI to OpenCL somewhere, and this can be done -// elsewhere, e.g. in the pi_opencl, but constants/enums mapping is now -// done here, for efficiency and simplicity. -#include -#include +// NOTE: This file presents a maping of OpenCL to PI enums, constants and +// typedefs. The general approach taken was to replace `CL_` prefix with `PI_`. +// Please consider this when adding or modifying values, as the strict value +// match is required. +// TODO: We should consider re-implementing PI enums and constants and only +// perform a mapping of PI to OpenCL in the pi_opencl backend. #include +#include #include #ifdef __cplusplus @@ -83,89 +86,89 @@ using pi_native_handle = uintptr_t; // TODO: populate PI enums. // typedef enum { - PI_SUCCESS = CL_SUCCESS, - PI_INVALID_KERNEL_NAME = CL_INVALID_KERNEL_NAME, - PI_INVALID_OPERATION = CL_INVALID_OPERATION, - PI_INVALID_KERNEL = CL_INVALID_KERNEL, - PI_INVALID_QUEUE_PROPERTIES = CL_INVALID_QUEUE_PROPERTIES, - PI_INVALID_VALUE = CL_INVALID_VALUE, - PI_INVALID_CONTEXT = CL_INVALID_CONTEXT, - PI_INVALID_PLATFORM = CL_INVALID_PLATFORM, - PI_INVALID_DEVICE = CL_INVALID_DEVICE, - PI_INVALID_BINARY = CL_INVALID_BINARY, - PI_INVALID_QUEUE = CL_INVALID_COMMAND_QUEUE, - PI_OUT_OF_HOST_MEMORY = CL_OUT_OF_HOST_MEMORY, - PI_INVALID_PROGRAM = CL_INVALID_PROGRAM, - PI_INVALID_PROGRAM_EXECUTABLE = CL_INVALID_PROGRAM_EXECUTABLE, - PI_INVALID_SAMPLER = CL_INVALID_SAMPLER, - PI_INVALID_BUFFER_SIZE = CL_INVALID_BUFFER_SIZE, - PI_INVALID_MEM_OBJECT = CL_INVALID_MEM_OBJECT, - PI_OUT_OF_RESOURCES = CL_OUT_OF_RESOURCES, - PI_INVALID_EVENT = CL_INVALID_EVENT, - PI_INVALID_EVENT_WAIT_LIST = CL_INVALID_EVENT_WAIT_LIST, - PI_MISALIGNED_SUB_BUFFER_OFFSET = CL_MISALIGNED_SUB_BUFFER_OFFSET, - PI_BUILD_PROGRAM_FAILURE = CL_BUILD_PROGRAM_FAILURE, - PI_INVALID_WORK_GROUP_SIZE = CL_INVALID_WORK_GROUP_SIZE, - PI_COMPILER_NOT_AVAILABLE = CL_COMPILER_NOT_AVAILABLE, - PI_PROFILING_INFO_NOT_AVAILABLE = CL_PROFILING_INFO_NOT_AVAILABLE, - PI_DEVICE_NOT_FOUND = CL_DEVICE_NOT_FOUND, - PI_INVALID_WORK_ITEM_SIZE = CL_INVALID_WORK_ITEM_SIZE, - PI_INVALID_WORK_DIMENSION = CL_INVALID_WORK_DIMENSION, - PI_INVALID_KERNEL_ARGS = CL_INVALID_KERNEL_ARGS, - PI_INVALID_IMAGE_SIZE = CL_INVALID_IMAGE_SIZE, - PI_INVALID_ARG_VALUE = CL_INVALID_ARG_VALUE, - PI_INVALID_IMAGE_FORMAT_DESCRIPTOR = CL_INVALID_IMAGE_FORMAT_DESCRIPTOR, - PI_IMAGE_FORMAT_NOT_SUPPORTED = CL_IMAGE_FORMAT_NOT_SUPPORTED, - PI_MEM_OBJECT_ALLOCATION_FAILURE = CL_MEM_OBJECT_ALLOCATION_FAILURE, - PI_LINK_PROGRAM_FAILURE = CL_LINK_PROGRAM_FAILURE, - PI_PLUGIN_SPECIFIC_ERROR = -996, ///< PI_PLUGIN_SPECIFIC_ERROR indicates - ///< that an backend spcific error or - ///< warning has been emitted by the plugin. - PI_COMMAND_EXECUTION_FAILURE = - -997, ///< PI_COMMAND_EXECUTION_FAILURE indicates an error occurred + PI_SUCCESS = 0, + PI_ERROR_INVALID_KERNEL_NAME = -46, + PI_ERROR_INVALID_OPERATION = -59, + PI_ERROR_INVALID_KERNEL = -48, + PI_ERROR_INVALID_QUEUE_PROPERTIES = -35, + PI_ERROR_INVALID_VALUE = -30, + PI_ERROR_INVALID_CONTEXT = -34, + PI_ERROR_INVALID_PLATFORM = -32, + PI_ERROR_INVALID_DEVICE = -33, + PI_ERROR_INVALID_BINARY = -42, + PI_ERROR_INVALID_QUEUE = -36, + PI_ERROR_OUT_OF_HOST_MEMORY = -6, + PI_ERROR_INVALID_PROGRAM = -44, + PI_ERROR_INVALID_PROGRAM_EXECUTABLE = -45, + PI_ERROR_INVALID_SAMPLER = -41, + PI_ERROR_INVALID_BUFFER_SIZE = -61, + PI_ERROR_INVALID_MEM_OBJECT = -38, + PI_ERROR_OUT_OF_RESOURCES = -5, + PI_ERROR_INVALID_EVENT = -58, + PI_ERROR_INVALID_EVENT_WAIT_LIST = -57, + PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET = -13, + PI_ERROR_BUILD_PROGRAM_FAILURE = -11, + PI_ERROR_INVALID_WORK_GROUP_SIZE = -54, + PI_ERROR_COMPILER_NOT_AVAILABLE = -3, + PI_ERROR_PROFILING_INFO_NOT_AVAILABLE = -7, + PI_ERROR_DEVICE_NOT_FOUND = -1, + PI_ERROR_INVALID_WORK_ITEM_SIZE = -55, + PI_ERROR_INVALID_WORK_DIMENSION = -53, + PI_ERROR_INVALID_KERNEL_ARGS = -52, + PI_ERROR_INVALID_IMAGE_SIZE = -40, + PI_ERROR_INVALID_ARG_VALUE = -50, + PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR = -39, + PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED = -10, + PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE = -4, + PI_ERROR_LINK_PROGRAM_FAILURE = -17, + PI_ERROR_PLUGIN_SPECIFIC_ERROR = + -996, ///< PI_ERROR_PLUGIN_SPECIFIC_ERROR indicates + ///< that an backend spcific error or + ///< warning has been emitted by the plugin. + PI_ERROR_COMMAND_EXECUTION_FAILURE = + -997, ///< PI_ERROR_COMMAND_EXECUTION_FAILURE indicates an error occurred ///< during command enqueue or execution. - PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE = - -998, ///< PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback + PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE = + -998, ///< PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE indicates a fallback ///< method determines the function exists but its address cannot be ///< found. PI_ERROR_UNKNOWN = -999 } _pi_result; typedef enum { - PI_EVENT_COMPLETE = CL_COMPLETE, - PI_EVENT_RUNNING = CL_RUNNING, - PI_EVENT_SUBMITTED = CL_SUBMITTED, - PI_EVENT_QUEUED = CL_QUEUED + PI_EVENT_COMPLETE = 0x0, + PI_EVENT_RUNNING = 0x1, + PI_EVENT_SUBMITTED = 0x2, + PI_EVENT_QUEUED = 0x3 } _pi_event_status; typedef enum { - PI_PLATFORM_INFO_EXTENSIONS = CL_PLATFORM_EXTENSIONS, - PI_PLATFORM_INFO_NAME = CL_PLATFORM_NAME, - PI_PLATFORM_INFO_PROFILE = CL_PLATFORM_PROFILE, - PI_PLATFORM_INFO_VENDOR = CL_PLATFORM_VENDOR, - PI_PLATFORM_INFO_VERSION = CL_PLATFORM_VERSION + PI_PLATFORM_INFO_EXTENSIONS = 0x0904, + PI_PLATFORM_INFO_NAME = 0x0902, + PI_PLATFORM_INFO_PROFILE = 0x0900, + PI_PLATFORM_INFO_VENDOR = 0x0903, + PI_PLATFORM_INFO_VERSION = 0x0901 } _pi_platform_info; typedef enum { - PI_PROGRAM_BUILD_INFO_STATUS = CL_PROGRAM_BUILD_STATUS, - PI_PROGRAM_BUILD_INFO_OPTIONS = CL_PROGRAM_BUILD_OPTIONS, - PI_PROGRAM_BUILD_INFO_LOG = CL_PROGRAM_BUILD_LOG, - PI_PROGRAM_BUILD_INFO_BINARY_TYPE = CL_PROGRAM_BINARY_TYPE + PI_PROGRAM_BUILD_INFO_STATUS = 0x1181, + PI_PROGRAM_BUILD_INFO_OPTIONS = 0x1182, + PI_PROGRAM_BUILD_INFO_LOG = 0x1183, + PI_PROGRAM_BUILD_INFO_BINARY_TYPE = 0x1184 } _pi_program_build_info; typedef enum { - PI_PROGRAM_BUILD_STATUS_NONE = CL_BUILD_NONE, - PI_PROGRAM_BUILD_STATUS_ERROR = CL_BUILD_ERROR, - PI_PROGRAM_BUILD_STATUS_SUCCESS = CL_BUILD_SUCCESS, - PI_PROGRAM_BUILD_STATUS_IN_PROGRESS = CL_BUILD_IN_PROGRESS + PI_PROGRAM_BUILD_STATUS_NONE = -1, + PI_PROGRAM_BUILD_STATUS_ERROR = -2, + PI_PROGRAM_BUILD_STATUS_SUCCESS = 0, + PI_PROGRAM_BUILD_STATUS_IN_PROGRESS = -3 } _pi_program_build_status; typedef enum { - PI_PROGRAM_BINARY_TYPE_NONE = CL_PROGRAM_BINARY_TYPE_NONE, - PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = - CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT, - PI_PROGRAM_BINARY_TYPE_LIBRARY = CL_PROGRAM_BINARY_TYPE_LIBRARY, - PI_PROGRAM_BINARY_TYPE_EXECUTABLE = CL_PROGRAM_BINARY_TYPE_EXECUTABLE + PI_PROGRAM_BINARY_TYPE_NONE = 0x0, + PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT = 0x1, + PI_PROGRAM_BINARY_TYPE_LIBRARY = 0x2, + PI_PROGRAM_BINARY_TYPE_EXECUTABLE = 0x4 } _pi_program_binary_type; // NOTE: this is made 64-bit to match the size of cl_device_type to @@ -173,135 +176,112 @@ typedef enum { // typedef enum : pi_uint64 { PI_DEVICE_TYPE_DEFAULT = - CL_DEVICE_TYPE_DEFAULT, ///< The default device available in the PI - ///< plugin. - PI_DEVICE_TYPE_ALL = - CL_DEVICE_TYPE_ALL, ///< All devices available in the PI plugin. - PI_DEVICE_TYPE_CPU = - CL_DEVICE_TYPE_CPU, ///< A PI device that is the host processor. - PI_DEVICE_TYPE_GPU = CL_DEVICE_TYPE_GPU, ///< A PI device that is a GPU. - PI_DEVICE_TYPE_ACC = CL_DEVICE_TYPE_ACCELERATOR ///< A PI device that is a - ///< dedicated accelerator. + (1 << 0), ///< The default device available in the PI plugin. + PI_DEVICE_TYPE_ALL = 0xFFFFFFFF, ///< All devices available in the PI plugin. + PI_DEVICE_TYPE_CPU = (1 << 1), ///< A PI device that is the host processor. + PI_DEVICE_TYPE_GPU = (1 << 2), ///< A PI device that is a GPU. + PI_DEVICE_TYPE_ACC = (1 << 3) ///< A PI device that is a + ///< dedicated accelerator. } _pi_device_type; typedef enum { - PI_DEVICE_MEM_CACHE_TYPE_NONE = CL_NONE, - PI_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE = CL_READ_ONLY_CACHE, - PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE = CL_READ_WRITE_CACHE + PI_DEVICE_MEM_CACHE_TYPE_NONE = 0x0, + PI_DEVICE_MEM_CACHE_TYPE_READ_ONLY_CACHE = 0x1, + PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE = 0x2 } _pi_device_mem_cache_type; typedef enum { - PI_DEVICE_LOCAL_MEM_TYPE_LOCAL = CL_LOCAL, - PI_DEVICE_LOCAL_MEM_TYPE_GLOBAL = CL_GLOBAL + PI_DEVICE_LOCAL_MEM_TYPE_LOCAL = 0x1, + PI_DEVICE_LOCAL_MEM_TYPE_GLOBAL = 0x2 } _pi_device_local_mem_type; typedef enum { - PI_DEVICE_INFO_TYPE = CL_DEVICE_TYPE, - PI_DEVICE_INFO_VENDOR_ID = CL_DEVICE_VENDOR_ID, - PI_DEVICE_INFO_MAX_COMPUTE_UNITS = CL_DEVICE_MAX_COMPUTE_UNITS, - PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, - PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES = CL_DEVICE_MAX_WORK_ITEM_SIZES, - PI_DEVICE_INFO_MAX_WORK_GROUP_SIZE = CL_DEVICE_MAX_WORK_GROUP_SIZE, - PI_DEVICE_INFO_SINGLE_FP_CONFIG = CL_DEVICE_SINGLE_FP_CONFIG, - PI_DEVICE_INFO_HALF_FP_CONFIG = CL_DEVICE_HALF_FP_CONFIG, - PI_DEVICE_INFO_DOUBLE_FP_CONFIG = CL_DEVICE_DOUBLE_FP_CONFIG, - PI_DEVICE_INFO_QUEUE_PROPERTIES = CL_DEVICE_QUEUE_PROPERTIES, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, - PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = - CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = - CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = - CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = - CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, - PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, - PI_DEVICE_INFO_MAX_CLOCK_FREQUENCY = CL_DEVICE_MAX_CLOCK_FREQUENCY, - PI_DEVICE_INFO_ADDRESS_BITS = CL_DEVICE_ADDRESS_BITS, - PI_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = CL_DEVICE_MAX_MEM_ALLOC_SIZE, - PI_DEVICE_INFO_IMAGE_SUPPORT = CL_DEVICE_IMAGE_SUPPORT, - PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS = CL_DEVICE_MAX_READ_IMAGE_ARGS, - PI_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = CL_DEVICE_MAX_WRITE_IMAGE_ARGS, - PI_DEVICE_INFO_IMAGE2D_MAX_WIDTH = CL_DEVICE_IMAGE2D_MAX_WIDTH, - PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = CL_DEVICE_IMAGE2D_MAX_HEIGHT, - PI_DEVICE_INFO_IMAGE3D_MAX_WIDTH = CL_DEVICE_IMAGE3D_MAX_WIDTH, - PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = CL_DEVICE_IMAGE3D_MAX_HEIGHT, - PI_DEVICE_INFO_IMAGE3D_MAX_DEPTH = CL_DEVICE_IMAGE3D_MAX_DEPTH, - PI_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, - PI_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, - PI_DEVICE_INFO_MAX_SAMPLERS = CL_DEVICE_MAX_SAMPLERS, - PI_DEVICE_INFO_MAX_PARAMETER_SIZE = CL_DEVICE_MAX_PARAMETER_SIZE, - PI_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = CL_DEVICE_MEM_BASE_ADDR_ALIGN, - PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, - PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = - CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, - PI_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, - PI_DEVICE_INFO_GLOBAL_MEM_SIZE = CL_DEVICE_GLOBAL_MEM_SIZE, - PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, - PI_DEVICE_INFO_MAX_CONSTANT_ARGS = CL_DEVICE_MAX_CONSTANT_ARGS, - PI_DEVICE_INFO_LOCAL_MEM_TYPE = CL_DEVICE_LOCAL_MEM_TYPE, - PI_DEVICE_INFO_LOCAL_MEM_SIZE = CL_DEVICE_LOCAL_MEM_SIZE, - PI_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = CL_DEVICE_ERROR_CORRECTION_SUPPORT, - PI_DEVICE_INFO_HOST_UNIFIED_MEMORY = CL_DEVICE_HOST_UNIFIED_MEMORY, - PI_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = - CL_DEVICE_PROFILING_TIMER_RESOLUTION, - PI_DEVICE_INFO_ENDIAN_LITTLE = CL_DEVICE_ENDIAN_LITTLE, - PI_DEVICE_INFO_AVAILABLE = CL_DEVICE_AVAILABLE, - PI_DEVICE_INFO_COMPILER_AVAILABLE = CL_DEVICE_COMPILER_AVAILABLE, - PI_DEVICE_INFO_LINKER_AVAILABLE = CL_DEVICE_LINKER_AVAILABLE, - PI_DEVICE_INFO_EXECUTION_CAPABILITIES = CL_DEVICE_EXECUTION_CAPABILITIES, - PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = - CL_DEVICE_QUEUE_ON_DEVICE_PROPERTIES, - PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = CL_DEVICE_QUEUE_ON_HOST_PROPERTIES, - PI_DEVICE_INFO_BUILT_IN_KERNELS = CL_DEVICE_BUILT_IN_KERNELS, - PI_DEVICE_INFO_PLATFORM = CL_DEVICE_PLATFORM, - PI_DEVICE_INFO_REFERENCE_COUNT = CL_DEVICE_REFERENCE_COUNT, - PI_DEVICE_INFO_IL_VERSION = CL_DEVICE_IL_VERSION_KHR, - PI_DEVICE_INFO_NAME = CL_DEVICE_NAME, - PI_DEVICE_INFO_VENDOR = CL_DEVICE_VENDOR, - PI_DEVICE_INFO_DRIVER_VERSION = CL_DRIVER_VERSION, - PI_DEVICE_INFO_PROFILE = CL_DEVICE_PROFILE, - PI_DEVICE_INFO_VERSION = CL_DEVICE_VERSION, - PI_DEVICE_INFO_OPENCL_C_VERSION = CL_DEVICE_OPENCL_C_VERSION, - PI_DEVICE_INFO_EXTENSIONS = CL_DEVICE_EXTENSIONS, - PI_DEVICE_INFO_PRINTF_BUFFER_SIZE = CL_DEVICE_PRINTF_BUFFER_SIZE, - PI_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = - CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, - PI_DEVICE_INFO_PARENT_DEVICE = CL_DEVICE_PARENT_DEVICE, - PI_DEVICE_INFO_PARTITION_PROPERTIES = CL_DEVICE_PARTITION_PROPERTIES, - PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = - CL_DEVICE_PARTITION_MAX_SUB_DEVICES, - PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = - CL_DEVICE_PARTITION_AFFINITY_DOMAIN, - PI_DEVICE_INFO_PARTITION_TYPE = CL_DEVICE_PARTITION_TYPE, - PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS = CL_DEVICE_MAX_NUM_SUB_GROUPS, - PI_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = - CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS, - PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = CL_DEVICE_SUB_GROUP_SIZES_INTEL, - PI_DEVICE_INFO_USM_HOST_SUPPORT = CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, - PI_DEVICE_INFO_USM_DEVICE_SUPPORT = CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, - PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = - CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, - PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = - CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, - PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = - CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL, + PI_DEVICE_INFO_TYPE = 0x1000, + PI_DEVICE_INFO_VENDOR_ID = 0x1001, + PI_DEVICE_INFO_MAX_COMPUTE_UNITS = 0x1002, + PI_DEVICE_INFO_MAX_WORK_ITEM_DIMENSIONS = 0x1003, + PI_DEVICE_INFO_MAX_WORK_ITEM_SIZES = 0x1005, + PI_DEVICE_INFO_MAX_WORK_GROUP_SIZE = 0x1004, + PI_DEVICE_INFO_SINGLE_FP_CONFIG = 0x101B, + PI_DEVICE_INFO_HALF_FP_CONFIG = 0x1033, + PI_DEVICE_INFO_DOUBLE_FP_CONFIG = 0x1032, + PI_DEVICE_INFO_QUEUE_PROPERTIES = 0x102A, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_CHAR = 0x1006, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_SHORT = 0x1007, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_INT = 0x1008, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_LONG = 0x1009, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_FLOAT = 0x100A, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_DOUBLE = 0x100B, + PI_DEVICE_INFO_PREFERRED_VECTOR_WIDTH_HALF = 0x1034, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_CHAR = 0x1036, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_SHORT = 0x1037, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_INT = 0x1038, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_LONG = 0x1039, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_FLOAT = 0x103A, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_DOUBLE = 0x103B, + PI_DEVICE_INFO_NATIVE_VECTOR_WIDTH_HALF = 0x103C, + PI_DEVICE_INFO_MAX_CLOCK_FREQUENCY = 0x100C, + PI_DEVICE_INFO_ADDRESS_BITS = 0x100D, + PI_DEVICE_INFO_MAX_MEM_ALLOC_SIZE = 0x1010, + PI_DEVICE_INFO_IMAGE_SUPPORT = 0x1016, + PI_DEVICE_INFO_MAX_READ_IMAGE_ARGS = 0x100E, + PI_DEVICE_INFO_MAX_WRITE_IMAGE_ARGS = 0x100F, + PI_DEVICE_INFO_IMAGE2D_MAX_WIDTH = 0x1011, + PI_DEVICE_INFO_IMAGE2D_MAX_HEIGHT = 0x1012, + PI_DEVICE_INFO_IMAGE3D_MAX_WIDTH = 0x1013, + PI_DEVICE_INFO_IMAGE3D_MAX_HEIGHT = 0x1014, + PI_DEVICE_INFO_IMAGE3D_MAX_DEPTH = 0x1015, + PI_DEVICE_INFO_IMAGE_MAX_BUFFER_SIZE = 0x1040, + PI_DEVICE_INFO_IMAGE_MAX_ARRAY_SIZE = 0x1041, + PI_DEVICE_INFO_MAX_SAMPLERS = 0x1018, + PI_DEVICE_INFO_MAX_PARAMETER_SIZE = 0x1017, + PI_DEVICE_INFO_MEM_BASE_ADDR_ALIGN = 0x1019, + PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE = 0x101C, + PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE = 0x101D, + PI_DEVICE_INFO_GLOBAL_MEM_CACHE_SIZE = 0x101E, + PI_DEVICE_INFO_GLOBAL_MEM_SIZE = 0x101F, + PI_DEVICE_INFO_MAX_CONSTANT_BUFFER_SIZE = 0x1020, + PI_DEVICE_INFO_MAX_CONSTANT_ARGS = 0x1021, + PI_DEVICE_INFO_LOCAL_MEM_TYPE = 0x1022, + PI_DEVICE_INFO_LOCAL_MEM_SIZE = 0x1023, + PI_DEVICE_INFO_ERROR_CORRECTION_SUPPORT = 0x1024, + PI_DEVICE_INFO_HOST_UNIFIED_MEMORY = 0x1035, + PI_DEVICE_INFO_PROFILING_TIMER_RESOLUTION = 0x1025, + PI_DEVICE_INFO_ENDIAN_LITTLE = 0x1026, + PI_DEVICE_INFO_AVAILABLE = 0x1027, + PI_DEVICE_INFO_COMPILER_AVAILABLE = 0x1028, + PI_DEVICE_INFO_LINKER_AVAILABLE = 0x103E, + PI_DEVICE_INFO_EXECUTION_CAPABILITIES = 0x1029, + PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES = 0x104E, + PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES = 0x102A, + PI_DEVICE_INFO_BUILT_IN_KERNELS = 0x103F, + PI_DEVICE_INFO_PLATFORM = 0x1031, + PI_DEVICE_INFO_REFERENCE_COUNT = 0x1047, + PI_DEVICE_INFO_IL_VERSION = 0x105B, + PI_DEVICE_INFO_NAME = 0x102B, + PI_DEVICE_INFO_VENDOR = 0x102C, + PI_DEVICE_INFO_DRIVER_VERSION = 0x102D, + PI_DEVICE_INFO_PROFILE = 0x102E, + PI_DEVICE_INFO_VERSION = 0x102F, + PI_DEVICE_INFO_OPENCL_C_VERSION = 0x103D, + PI_DEVICE_INFO_EXTENSIONS = 0x1030, + PI_DEVICE_INFO_PRINTF_BUFFER_SIZE = 0x1049, + PI_DEVICE_INFO_PREFERRED_INTEROP_USER_SYNC = 0x1048, + PI_DEVICE_INFO_PARENT_DEVICE = 0x1042, + PI_DEVICE_INFO_PARTITION_PROPERTIES = 0x1044, + PI_DEVICE_INFO_PARTITION_MAX_SUB_DEVICES = 0x1043, + PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN = 0x1045, + PI_DEVICE_INFO_PARTITION_TYPE = 0x1046, + PI_DEVICE_INFO_MAX_NUM_SUB_GROUPS = 0x105C, + PI_DEVICE_INFO_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS = 0x105D, + PI_DEVICE_INFO_SUB_GROUP_SIZES_INTEL = 0x4108, + PI_DEVICE_INFO_USM_HOST_SUPPORT = 0x4190, + PI_DEVICE_INFO_USM_DEVICE_SUPPORT = 0x4191, + PI_DEVICE_INFO_USM_SINGLE_SHARED_SUPPORT = 0x4192, + PI_DEVICE_INFO_USM_CROSS_SHARED_SUPPORT = 0x4193, + PI_DEVICE_INFO_USM_SYSTEM_SHARED_SUPPORT = 0x4194, // Intel UUID extension. - PI_DEVICE_INFO_UUID = CL_DEVICE_UUID_KHR, + PI_DEVICE_INFO_UUID = 0x106A, // These are Intel-specific extensions. PI_DEVICE_INFO_PCI_ADDRESS = 0x10020, PI_DEVICE_INFO_GPU_EU_COUNT = 0x10021, @@ -326,134 +306,131 @@ typedef enum { } _pi_device_info; typedef enum { - PI_PROGRAM_INFO_REFERENCE_COUNT = CL_PROGRAM_REFERENCE_COUNT, - PI_PROGRAM_INFO_CONTEXT = CL_PROGRAM_CONTEXT, - PI_PROGRAM_INFO_NUM_DEVICES = CL_PROGRAM_NUM_DEVICES, - PI_PROGRAM_INFO_DEVICES = CL_PROGRAM_DEVICES, - PI_PROGRAM_INFO_SOURCE = CL_PROGRAM_SOURCE, - PI_PROGRAM_INFO_BINARY_SIZES = CL_PROGRAM_BINARY_SIZES, - PI_PROGRAM_INFO_BINARIES = CL_PROGRAM_BINARIES, - PI_PROGRAM_INFO_NUM_KERNELS = CL_PROGRAM_NUM_KERNELS, - PI_PROGRAM_INFO_KERNEL_NAMES = CL_PROGRAM_KERNEL_NAMES + PI_PROGRAM_INFO_REFERENCE_COUNT = 0x1160, + PI_PROGRAM_INFO_CONTEXT = 0x1161, + PI_PROGRAM_INFO_NUM_DEVICES = 0x1162, + PI_PROGRAM_INFO_DEVICES = 0x1163, + PI_PROGRAM_INFO_SOURCE = 0x1164, + PI_PROGRAM_INFO_BINARY_SIZES = 0x1165, + PI_PROGRAM_INFO_BINARIES = 0x1166, + PI_PROGRAM_INFO_NUM_KERNELS = 0x1167, + PI_PROGRAM_INFO_KERNEL_NAMES = 0x1168 } _pi_program_info; typedef enum { - PI_CONTEXT_INFO_DEVICES = CL_CONTEXT_DEVICES, - PI_CONTEXT_INFO_NUM_DEVICES = CL_CONTEXT_NUM_DEVICES, - PI_CONTEXT_INFO_PROPERTIES = CL_CONTEXT_PROPERTIES, - PI_CONTEXT_INFO_REFERENCE_COUNT = CL_CONTEXT_REFERENCE_COUNT, + PI_CONTEXT_INFO_DEVICES = 0x1081, + PI_CONTEXT_INFO_NUM_DEVICES = 0x1083, + PI_CONTEXT_INFO_PROPERTIES = 0x1082, + PI_CONTEXT_INFO_REFERENCE_COUNT = 0x1080, // Atomics capabilities extensions PI_CONTEXT_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES = 0x10010, PI_CONTEXT_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES = 0x10011 } _pi_context_info; typedef enum { - PI_QUEUE_INFO_CONTEXT = CL_QUEUE_CONTEXT, - PI_QUEUE_INFO_DEVICE = CL_QUEUE_DEVICE, - PI_QUEUE_INFO_DEVICE_DEFAULT = CL_QUEUE_DEVICE_DEFAULT, - PI_QUEUE_INFO_PROPERTIES = CL_QUEUE_PROPERTIES, - PI_QUEUE_INFO_REFERENCE_COUNT = CL_QUEUE_REFERENCE_COUNT, - PI_QUEUE_INFO_SIZE = CL_QUEUE_SIZE + PI_QUEUE_INFO_CONTEXT = 0x1090, + PI_QUEUE_INFO_DEVICE = 0x1091, + PI_QUEUE_INFO_DEVICE_DEFAULT = 0x1095, + PI_QUEUE_INFO_PROPERTIES = 0x1093, + PI_QUEUE_INFO_REFERENCE_COUNT = 0x1092, + PI_QUEUE_INFO_SIZE = 0x1094 } _pi_queue_info; typedef enum { - PI_KERNEL_INFO_FUNCTION_NAME = CL_KERNEL_FUNCTION_NAME, - PI_KERNEL_INFO_NUM_ARGS = CL_KERNEL_NUM_ARGS, - PI_KERNEL_INFO_REFERENCE_COUNT = CL_KERNEL_REFERENCE_COUNT, - PI_KERNEL_INFO_CONTEXT = CL_KERNEL_CONTEXT, - PI_KERNEL_INFO_PROGRAM = CL_KERNEL_PROGRAM, - PI_KERNEL_INFO_ATTRIBUTES = CL_KERNEL_ATTRIBUTES + PI_KERNEL_INFO_FUNCTION_NAME = 0x1190, + PI_KERNEL_INFO_NUM_ARGS = 0x1191, + PI_KERNEL_INFO_REFERENCE_COUNT = 0x1192, + PI_KERNEL_INFO_CONTEXT = 0x1193, + PI_KERNEL_INFO_PROGRAM = 0x1194, + PI_KERNEL_INFO_ATTRIBUTES = 0x1195 } _pi_kernel_info; typedef enum { - PI_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = CL_KERNEL_GLOBAL_WORK_SIZE, - PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE = CL_KERNEL_WORK_GROUP_SIZE, - PI_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE = - CL_KERNEL_COMPILE_WORK_GROUP_SIZE, - PI_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE = CL_KERNEL_LOCAL_MEM_SIZE, - PI_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = - CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, - PI_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE = CL_KERNEL_PRIVATE_MEM_SIZE, + PI_KERNEL_GROUP_INFO_GLOBAL_WORK_SIZE = 0x11B5, + PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE = 0x11B0, + PI_KERNEL_GROUP_INFO_COMPILE_WORK_GROUP_SIZE = 0x11B1, + PI_KERNEL_GROUP_INFO_LOCAL_MEM_SIZE = 0x11B2, + PI_KERNEL_GROUP_INFO_PREFERRED_WORK_GROUP_SIZE_MULTIPLE = 0x11B3, + PI_KERNEL_GROUP_INFO_PRIVATE_MEM_SIZE = 0x11B4, // The number of registers used by the compiled kernel (device specific) PI_KERNEL_GROUP_INFO_NUM_REGS = 0x10112 } _pi_kernel_group_info; typedef enum { - PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT, - PI_FP_ROUND_TO_NEAREST = CL_FP_ROUND_TO_NEAREST, - PI_FP_ROUND_TO_ZERO = CL_FP_ROUND_TO_ZERO, - PI_FP_ROUND_TO_INF = CL_FP_ROUND_TO_INF, - PI_FP_INF_NAN = CL_FP_INF_NAN, - PI_FP_DENORM = CL_FP_DENORM, - PI_FP_FMA = CL_FP_FMA + PI_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT = (1 << 7), + PI_FP_ROUND_TO_NEAREST = (1 << 2), + PI_FP_ROUND_TO_ZERO = (1 << 3), + PI_FP_ROUND_TO_INF = (1 << 4), + PI_FP_INF_NAN = (1 << 1), + PI_FP_DENORM = (1 << 0), + PI_FP_FMA = (1 << 5) } _pi_fp_capabilities; typedef enum { - PI_IMAGE_INFO_FORMAT = CL_IMAGE_FORMAT, - PI_IMAGE_INFO_ELEMENT_SIZE = CL_IMAGE_ELEMENT_SIZE, - PI_IMAGE_INFO_ROW_PITCH = CL_IMAGE_ROW_PITCH, - PI_IMAGE_INFO_SLICE_PITCH = CL_IMAGE_SLICE_PITCH, - PI_IMAGE_INFO_WIDTH = CL_IMAGE_WIDTH, - PI_IMAGE_INFO_HEIGHT = CL_IMAGE_HEIGHT, - PI_IMAGE_INFO_DEPTH = CL_IMAGE_DEPTH + PI_IMAGE_INFO_FORMAT = 0x1110, + PI_IMAGE_INFO_ELEMENT_SIZE = 0x1111, + PI_IMAGE_INFO_ROW_PITCH = 0x1112, + PI_IMAGE_INFO_SLICE_PITCH = 0x1113, + PI_IMAGE_INFO_WIDTH = 0x1114, + PI_IMAGE_INFO_HEIGHT = 0x1115, + PI_IMAGE_INFO_DEPTH = 0x1116 } _pi_image_info; typedef enum { - PI_KERNEL_MAX_SUB_GROUP_SIZE = CL_KERNEL_MAX_SUB_GROUP_SIZE_FOR_NDRANGE, - PI_KERNEL_MAX_NUM_SUB_GROUPS = CL_KERNEL_MAX_NUM_SUB_GROUPS, - PI_KERNEL_COMPILE_NUM_SUB_GROUPS = CL_KERNEL_COMPILE_NUM_SUB_GROUPS, - PI_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL = - CL_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL + PI_KERNEL_MAX_SUB_GROUP_SIZE = 0x2033, + PI_KERNEL_MAX_NUM_SUB_GROUPS = 0x11B9, + PI_KERNEL_COMPILE_NUM_SUB_GROUPS = 0x11BA, + PI_KERNEL_COMPILE_SUB_GROUP_SIZE_INTEL = 0x410A } _pi_kernel_sub_group_info; typedef enum { - PI_EVENT_INFO_COMMAND_QUEUE = CL_EVENT_COMMAND_QUEUE, - PI_EVENT_INFO_CONTEXT = CL_EVENT_CONTEXT, - PI_EVENT_INFO_COMMAND_TYPE = CL_EVENT_COMMAND_TYPE, - PI_EVENT_INFO_COMMAND_EXECUTION_STATUS = CL_EVENT_COMMAND_EXECUTION_STATUS, - PI_EVENT_INFO_REFERENCE_COUNT = CL_EVENT_REFERENCE_COUNT + PI_EVENT_INFO_COMMAND_QUEUE = 0x11D0, + PI_EVENT_INFO_CONTEXT = 0x11D4, + PI_EVENT_INFO_COMMAND_TYPE = 0x11D1, + PI_EVENT_INFO_COMMAND_EXECUTION_STATUS = 0x11D3, + PI_EVENT_INFO_REFERENCE_COUNT = 0x11D2 } _pi_event_info; typedef enum { - PI_COMMAND_TYPE_NDRANGE_KERNEL = CL_COMMAND_NDRANGE_KERNEL, - PI_COMMAND_TYPE_MEM_BUFFER_READ = CL_COMMAND_READ_BUFFER, - PI_COMMAND_TYPE_MEM_BUFFER_WRITE = CL_COMMAND_WRITE_BUFFER, - PI_COMMAND_TYPE_MEM_BUFFER_COPY = CL_COMMAND_COPY_BUFFER, - PI_COMMAND_TYPE_MEM_BUFFER_MAP = CL_COMMAND_MAP_BUFFER, - PI_COMMAND_TYPE_MEM_BUFFER_UNMAP = CL_COMMAND_UNMAP_MEM_OBJECT, - PI_COMMAND_TYPE_MEM_BUFFER_READ_RECT = CL_COMMAND_READ_BUFFER_RECT, - PI_COMMAND_TYPE_MEM_BUFFER_WRITE_RECT = CL_COMMAND_WRITE_BUFFER_RECT, - PI_COMMAND_TYPE_MEM_BUFFER_COPY_RECT = CL_COMMAND_COPY_BUFFER_RECT, - PI_COMMAND_TYPE_USER = CL_COMMAND_USER, - PI_COMMAND_TYPE_MEM_BUFFER_FILL = CL_COMMAND_FILL_BUFFER, - PI_COMMAND_TYPE_IMAGE_READ = CL_COMMAND_READ_IMAGE, - PI_COMMAND_TYPE_IMAGE_WRITE = CL_COMMAND_WRITE_IMAGE, - PI_COMMAND_TYPE_IMAGE_COPY = CL_COMMAND_COPY_IMAGE, - PI_COMMAND_TYPE_NATIVE_KERNEL = CL_COMMAND_NATIVE_KERNEL, - PI_COMMAND_TYPE_COPY_BUFFER_TO_IMAGE = CL_COMMAND_COPY_BUFFER_TO_IMAGE, - PI_COMMAND_TYPE_COPY_IMAGE_TO_BUFFER = CL_COMMAND_COPY_IMAGE_TO_BUFFER, - PI_COMMAND_TYPE_MAP_IMAGE = CL_COMMAND_MAP_IMAGE, - PI_COMMAND_TYPE_MARKER = CL_COMMAND_MARKER, - PI_COMMAND_TYPE_ACQUIRE_GL_OBJECTS = CL_COMMAND_ACQUIRE_GL_OBJECTS, - PI_COMMAND_TYPE_RELEASE_GL_OBJECTS = CL_COMMAND_RELEASE_GL_OBJECTS, - PI_COMMAND_TYPE_BARRIER = CL_COMMAND_BARRIER, - PI_COMMAND_TYPE_MIGRATE_MEM_OBJECTS = CL_COMMAND_MIGRATE_MEM_OBJECTS, - PI_COMMAND_TYPE_FILL_IMAGE = CL_COMMAND_FILL_IMAGE, - PI_COMMAND_TYPE_SVM_FREE = CL_COMMAND_SVM_FREE, - PI_COMMAND_TYPE_SVM_MEMCPY = CL_COMMAND_SVM_MEMCPY, - PI_COMMAND_TYPE_SVM_MEMFILL = CL_COMMAND_SVM_MEMFILL, - PI_COMMAND_TYPE_SVM_MAP = CL_COMMAND_SVM_MAP, - PI_COMMAND_TYPE_SVM_UNMAP = CL_COMMAND_SVM_UNMAP + PI_COMMAND_TYPE_NDRANGE_KERNEL = 0x11F0, + PI_COMMAND_TYPE_MEM_BUFFER_READ = 0x11F3, + PI_COMMAND_TYPE_MEM_BUFFER_WRITE = 0x11F4, + PI_COMMAND_TYPE_MEM_BUFFER_COPY = 0x11F5, + PI_COMMAND_TYPE_MEM_BUFFER_MAP = 0x11FB, + PI_COMMAND_TYPE_MEM_BUFFER_UNMAP = 0x11FD, + PI_COMMAND_TYPE_MEM_BUFFER_READ_RECT = 0x1201, + PI_COMMAND_TYPE_MEM_BUFFER_WRITE_RECT = 0x1202, + PI_COMMAND_TYPE_MEM_BUFFER_COPY_RECT = 0x1203, + PI_COMMAND_TYPE_USER = 0x1204, + PI_COMMAND_TYPE_MEM_BUFFER_FILL = 0x1207, + PI_COMMAND_TYPE_IMAGE_READ = 0x11F6, + PI_COMMAND_TYPE_IMAGE_WRITE = 0x11F7, + PI_COMMAND_TYPE_IMAGE_COPY = 0x11F8, + PI_COMMAND_TYPE_NATIVE_KERNEL = 0x11F2, + PI_COMMAND_TYPE_COPY_BUFFER_TO_IMAGE = 0x11FA, + PI_COMMAND_TYPE_COPY_IMAGE_TO_BUFFER = 0x11F9, + PI_COMMAND_TYPE_MAP_IMAGE = 0x11FC, + PI_COMMAND_TYPE_MARKER = 0x11FE, + PI_COMMAND_TYPE_ACQUIRE_GL_OBJECTS = 0x11FF, + PI_COMMAND_TYPE_RELEASE_GL_OBJECTS = 0x1200, + PI_COMMAND_TYPE_BARRIER = 0x1205, + PI_COMMAND_TYPE_MIGRATE_MEM_OBJECTS = 0x1206, + PI_COMMAND_TYPE_FILL_IMAGE = 0x1208, + PI_COMMAND_TYPE_SVM_FREE = 0x1209, + PI_COMMAND_TYPE_SVM_MEMCPY = 0x120A, + PI_COMMAND_TYPE_SVM_MEMFILL = 0x120B, + PI_COMMAND_TYPE_SVM_MAP = 0x120C, + PI_COMMAND_TYPE_SVM_UNMAP = 0x120D } _pi_command_type; typedef enum { - PI_MEM_TYPE_BUFFER = CL_MEM_OBJECT_BUFFER, - PI_MEM_TYPE_IMAGE2D = CL_MEM_OBJECT_IMAGE2D, - PI_MEM_TYPE_IMAGE3D = CL_MEM_OBJECT_IMAGE3D, - PI_MEM_TYPE_IMAGE2D_ARRAY = CL_MEM_OBJECT_IMAGE2D_ARRAY, - PI_MEM_TYPE_IMAGE1D = CL_MEM_OBJECT_IMAGE1D, - PI_MEM_TYPE_IMAGE1D_ARRAY = CL_MEM_OBJECT_IMAGE1D_ARRAY, - PI_MEM_TYPE_IMAGE1D_BUFFER = CL_MEM_OBJECT_IMAGE1D_BUFFER + PI_MEM_TYPE_BUFFER = 0x10F0, + PI_MEM_TYPE_IMAGE2D = 0x10F1, + PI_MEM_TYPE_IMAGE3D = 0x10F2, + PI_MEM_TYPE_IMAGE2D_ARRAY = 0x10F3, + PI_MEM_TYPE_IMAGE1D = 0x10F4, + PI_MEM_TYPE_IMAGE1D_ARRAY = 0x10F5, + PI_MEM_TYPE_IMAGE1D_BUFFER = 0x10F6 } _pi_mem_type; typedef enum { @@ -472,87 +449,83 @@ typedef enum { } _pi_mem_advice; typedef enum { - PI_IMAGE_CHANNEL_ORDER_A = CL_A, - PI_IMAGE_CHANNEL_ORDER_R = CL_R, - PI_IMAGE_CHANNEL_ORDER_RG = CL_RG, - PI_IMAGE_CHANNEL_ORDER_RA = CL_RA, - PI_IMAGE_CHANNEL_ORDER_RGB = CL_RGB, - PI_IMAGE_CHANNEL_ORDER_RGBA = CL_RGBA, - PI_IMAGE_CHANNEL_ORDER_BGRA = CL_BGRA, - PI_IMAGE_CHANNEL_ORDER_ARGB = CL_ARGB, - PI_IMAGE_CHANNEL_ORDER_ABGR = CL_ABGR, - PI_IMAGE_CHANNEL_ORDER_INTENSITY = CL_INTENSITY, - PI_IMAGE_CHANNEL_ORDER_LUMINANCE = CL_LUMINANCE, - PI_IMAGE_CHANNEL_ORDER_Rx = CL_Rx, - PI_IMAGE_CHANNEL_ORDER_RGx = CL_RGx, - PI_IMAGE_CHANNEL_ORDER_RGBx = CL_RGBx, - PI_IMAGE_CHANNEL_ORDER_sRGBA = CL_sRGBA + PI_IMAGE_CHANNEL_ORDER_A = 0x10B1, + PI_IMAGE_CHANNEL_ORDER_R = 0x10B0, + PI_IMAGE_CHANNEL_ORDER_RG = 0x10B2, + PI_IMAGE_CHANNEL_ORDER_RA = 0x10B3, + PI_IMAGE_CHANNEL_ORDER_RGB = 0x10B4, + PI_IMAGE_CHANNEL_ORDER_RGBA = 0x10B5, + PI_IMAGE_CHANNEL_ORDER_BGRA = 0x10B6, + PI_IMAGE_CHANNEL_ORDER_ARGB = 0x10B7, + PI_IMAGE_CHANNEL_ORDER_ABGR = 0x10C3, + PI_IMAGE_CHANNEL_ORDER_INTENSITY = 0x10B8, + PI_IMAGE_CHANNEL_ORDER_LUMINANCE = 0x10B9, + PI_IMAGE_CHANNEL_ORDER_Rx = 0x10BA, + PI_IMAGE_CHANNEL_ORDER_RGx = 0x10BB, + PI_IMAGE_CHANNEL_ORDER_RGBx = 0x10BC, + PI_IMAGE_CHANNEL_ORDER_sRGBA = 0x10C1 } _pi_image_channel_order; typedef enum { - PI_IMAGE_CHANNEL_TYPE_SNORM_INT8 = CL_SNORM_INT8, - PI_IMAGE_CHANNEL_TYPE_SNORM_INT16 = CL_SNORM_INT16, - PI_IMAGE_CHANNEL_TYPE_UNORM_INT8 = CL_UNORM_INT8, - PI_IMAGE_CHANNEL_TYPE_UNORM_INT16 = CL_UNORM_INT16, - PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565 = CL_UNORM_SHORT_565, - PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555 = CL_UNORM_SHORT_555, - PI_IMAGE_CHANNEL_TYPE_UNORM_INT_101010 = CL_UNORM_INT_101010, - PI_IMAGE_CHANNEL_TYPE_SIGNED_INT8 = CL_SIGNED_INT8, - PI_IMAGE_CHANNEL_TYPE_SIGNED_INT16 = CL_SIGNED_INT16, - PI_IMAGE_CHANNEL_TYPE_SIGNED_INT32 = CL_SIGNED_INT32, - PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8 = CL_UNSIGNED_INT8, - PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16 = CL_UNSIGNED_INT16, - PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32 = CL_UNSIGNED_INT32, - PI_IMAGE_CHANNEL_TYPE_HALF_FLOAT = CL_HALF_FLOAT, - PI_IMAGE_CHANNEL_TYPE_FLOAT = CL_FLOAT + PI_IMAGE_CHANNEL_TYPE_SNORM_INT8 = 0x10D0, + PI_IMAGE_CHANNEL_TYPE_SNORM_INT16 = 0x10D1, + PI_IMAGE_CHANNEL_TYPE_UNORM_INT8 = 0x10D2, + PI_IMAGE_CHANNEL_TYPE_UNORM_INT16 = 0x10D3, + PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565 = 0x10D4, + PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_555 = 0x10D5, + PI_IMAGE_CHANNEL_TYPE_UNORM_INT_101010 = 0x10D6, + PI_IMAGE_CHANNEL_TYPE_SIGNED_INT8 = 0x10D7, + PI_IMAGE_CHANNEL_TYPE_SIGNED_INT16 = 0x10D8, + PI_IMAGE_CHANNEL_TYPE_SIGNED_INT32 = 0x10D9, + PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8 = 0x10DA, + PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16 = 0x10DB, + PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32 = 0x10DC, + PI_IMAGE_CHANNEL_TYPE_HALF_FLOAT = 0x10DD, + PI_IMAGE_CHANNEL_TYPE_FLOAT = 0x10DE } _pi_image_channel_type; -typedef enum { - PI_BUFFER_CREATE_TYPE_REGION = CL_BUFFER_CREATE_TYPE_REGION -} _pi_buffer_create_type; +typedef enum { PI_BUFFER_CREATE_TYPE_REGION = 0x1220 } _pi_buffer_create_type; -const pi_bool PI_TRUE = CL_TRUE; -const pi_bool PI_FALSE = CL_FALSE; +const pi_bool PI_TRUE = 1; +const pi_bool PI_FALSE = 0; typedef enum { - PI_SAMPLER_INFO_REFERENCE_COUNT = CL_SAMPLER_REFERENCE_COUNT, - PI_SAMPLER_INFO_CONTEXT = CL_SAMPLER_CONTEXT, - PI_SAMPLER_INFO_NORMALIZED_COORDS = CL_SAMPLER_NORMALIZED_COORDS, - PI_SAMPLER_INFO_ADDRESSING_MODE = CL_SAMPLER_ADDRESSING_MODE, - PI_SAMPLER_INFO_FILTER_MODE = CL_SAMPLER_FILTER_MODE, - PI_SAMPLER_INFO_MIP_FILTER_MODE = CL_SAMPLER_MIP_FILTER_MODE, - PI_SAMPLER_INFO_LOD_MIN = CL_SAMPLER_LOD_MIN, - PI_SAMPLER_INFO_LOD_MAX = CL_SAMPLER_LOD_MAX + PI_SAMPLER_INFO_REFERENCE_COUNT = 0x1150, + PI_SAMPLER_INFO_CONTEXT = 0x1151, + PI_SAMPLER_INFO_NORMALIZED_COORDS = 0x1152, + PI_SAMPLER_INFO_ADDRESSING_MODE = 0x1153, + PI_SAMPLER_INFO_FILTER_MODE = 0x1154, + PI_SAMPLER_INFO_MIP_FILTER_MODE = 0x1155, + PI_SAMPLER_INFO_LOD_MIN = 0x1156, + PI_SAMPLER_INFO_LOD_MAX = 0x1157 } _pi_sampler_info; typedef enum { - PI_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT = CL_ADDRESS_MIRRORED_REPEAT, - PI_SAMPLER_ADDRESSING_MODE_REPEAT = CL_ADDRESS_REPEAT, - PI_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = CL_ADDRESS_CLAMP_TO_EDGE, - PI_SAMPLER_ADDRESSING_MODE_CLAMP = CL_ADDRESS_CLAMP, - PI_SAMPLER_ADDRESSING_MODE_NONE = CL_ADDRESS_NONE + PI_SAMPLER_ADDRESSING_MODE_MIRRORED_REPEAT = 0x1134, + PI_SAMPLER_ADDRESSING_MODE_REPEAT = 0x1133, + PI_SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = 0x1131, + PI_SAMPLER_ADDRESSING_MODE_CLAMP = 0x1132, + PI_SAMPLER_ADDRESSING_MODE_NONE = 0x1130 } _pi_sampler_addressing_mode; typedef enum { - PI_SAMPLER_FILTER_MODE_NEAREST = CL_FILTER_NEAREST, - PI_SAMPLER_FILTER_MODE_LINEAR = CL_FILTER_LINEAR, + PI_SAMPLER_FILTER_MODE_NEAREST = 0x1140, + PI_SAMPLER_FILTER_MODE_LINEAR = 0x1141, } _pi_sampler_filter_mode; using pi_context_properties = intptr_t; using pi_device_exec_capabilities = pi_bitfield; constexpr pi_device_exec_capabilities PI_DEVICE_EXEC_CAPABILITIES_KERNEL = - CL_EXEC_KERNEL; + (1 << 0); constexpr pi_device_exec_capabilities - PI_DEVICE_EXEC_CAPABILITIES_NATIVE_KERNEL = CL_EXEC_NATIVE_KERNEL; + PI_DEVICE_EXEC_CAPABILITIES_NATIVE_KERNEL = (1 << 1); using pi_sampler_properties = pi_bitfield; constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_NORMALIZED_COORDS = - CL_SAMPLER_NORMALIZED_COORDS; -constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_ADDRESSING_MODE = - CL_SAMPLER_ADDRESSING_MODE; -constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_FILTER_MODE = - CL_SAMPLER_FILTER_MODE; + 0x1152; +constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_ADDRESSING_MODE = 0x1153; +constexpr pi_sampler_properties PI_SAMPLER_PROPERTIES_FILTER_MODE = 0x1154; using pi_memory_order_capabilities = pi_bitfield; constexpr pi_memory_order_capabilities PI_MEMORY_ORDER_RELAXED = 0x01; @@ -569,10 +542,10 @@ constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_DEVICE = 0x08; constexpr pi_memory_scope_capabilities PI_MEMORY_SCOPE_SYSTEM = 0x10; typedef enum { - PI_PROFILING_INFO_COMMAND_QUEUED = CL_PROFILING_COMMAND_QUEUED, - PI_PROFILING_INFO_COMMAND_SUBMIT = CL_PROFILING_COMMAND_SUBMIT, - PI_PROFILING_INFO_COMMAND_START = CL_PROFILING_COMMAND_START, - PI_PROFILING_INFO_COMMAND_END = CL_PROFILING_COMMAND_END + PI_PROFILING_INFO_COMMAND_QUEUED = 0x1280, + PI_PROFILING_INFO_COMMAND_SUBMIT = 0x1281, + PI_PROFILING_INFO_COMMAND_START = 0x1282, + PI_PROFILING_INFO_COMMAND_END = 0x1283 } _pi_profiling_info; // NOTE: this is made 64-bit to match the size of cl_mem_flags to @@ -581,53 +554,44 @@ typedef enum { // using pi_mem_flags = pi_bitfield; // Access -constexpr pi_mem_flags PI_MEM_FLAGS_ACCESS_RW = CL_MEM_READ_WRITE; -constexpr pi_mem_flags PI_MEM_ACCESS_READ_ONLY = CL_MEM_READ_ONLY; +constexpr pi_mem_flags PI_MEM_FLAGS_ACCESS_RW = (1 << 0); +constexpr pi_mem_flags PI_MEM_ACCESS_READ_ONLY = (1 << 2); // Host pointer -constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_USE = CL_MEM_USE_HOST_PTR; -constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_COPY = CL_MEM_COPY_HOST_PTR; -constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_ALLOC = CL_MEM_ALLOC_HOST_PTR; +constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_USE = (1 << 3); +constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_COPY = (1 << 5); +constexpr pi_mem_flags PI_MEM_FLAGS_HOST_PTR_ALLOC = (1 << 4); // flags passed to Map operations using pi_map_flags = pi_bitfield; -constexpr pi_map_flags PI_MAP_READ = CL_MAP_READ; -constexpr pi_map_flags PI_MAP_WRITE = CL_MAP_WRITE; -constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION = - CL_MAP_WRITE_INVALIDATE_REGION; - +constexpr pi_map_flags PI_MAP_READ = (1 << 0); +constexpr pi_map_flags PI_MAP_WRITE = (1 << 1); +constexpr pi_map_flags PI_MAP_WRITE_INVALIDATE_REGION = (1 << 2); // NOTE: this is made 64-bit to match the size of cl_mem_properties_intel to // make the translation to OpenCL transparent. using pi_mem_properties = pi_bitfield; -constexpr pi_mem_properties PI_MEM_PROPERTIES_CHANNEL = CL_MEM_CHANNEL_INTEL; -constexpr pi_mem_properties PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = - CL_MEM_ALLOC_BUFFER_LOCATION_INTEL; +constexpr pi_mem_properties PI_MEM_PROPERTIES_CHANNEL = 0x4213; +constexpr pi_mem_properties PI_MEM_PROPERTIES_ALLOC_BUFFER_LOCATION = 0x419E; // NOTE: this is made 64-bit to match the size of cl_mem_properties_intel to // make the translation to OpenCL transparent. using pi_usm_mem_properties = pi_bitfield; -constexpr pi_usm_mem_properties PI_MEM_ALLOC_FLAGS = CL_MEM_ALLOC_FLAGS_INTEL; -constexpr pi_usm_mem_properties PI_MEM_ALLOC_WRTITE_COMBINED = - CL_MEM_ALLOC_WRITE_COMBINED_INTEL; +constexpr pi_usm_mem_properties PI_MEM_ALLOC_FLAGS = 0x4195; +constexpr pi_usm_mem_properties PI_MEM_ALLOC_WRTITE_COMBINED = (1 << 0); constexpr pi_usm_mem_properties PI_MEM_ALLOC_INITIAL_PLACEMENT_DEVICE = - CL_MEM_ALLOC_INITIAL_PLACEMENT_DEVICE_INTEL; -constexpr pi_usm_mem_properties PI_MEM_ALLOC_INITIAL_PLACEMENT_HOST = - CL_MEM_ALLOC_INITIAL_PLACEMENT_HOST_INTEL; + (1 << 1); +constexpr pi_usm_mem_properties PI_MEM_ALLOC_INITIAL_PLACEMENT_HOST = (1 << 2); // Hints that the device/shared allocation will not be written on device. constexpr pi_usm_mem_properties PI_MEM_ALLOC_DEVICE_READ_ONLY = (1 << 3); -constexpr pi_usm_mem_properties PI_MEM_USM_ALLOC_BUFFER_LOCATION = - CL_MEM_ALLOC_BUFFER_LOCATION_INTEL; +constexpr pi_usm_mem_properties PI_MEM_USM_ALLOC_BUFFER_LOCATION = 0x419E; // NOTE: queue properties are implemented this way to better support bit // manipulations using pi_queue_properties = pi_bitfield; -constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = - CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; -constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = - CL_QUEUE_PROFILING_ENABLE; -constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = CL_QUEUE_ON_DEVICE; -constexpr pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT = - CL_QUEUE_ON_DEVICE_DEFAULT; +constexpr pi_queue_properties PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE = (1 << 0); +constexpr pi_queue_properties PI_QUEUE_PROFILING_ENABLE = (1 << 1); +constexpr pi_queue_properties PI_QUEUE_ON_DEVICE = (1 << 2); +constexpr pi_queue_properties PI_QUEUE_ON_DEVICE_DEFAULT = (1 << 3); using pi_result = _pi_result; using pi_platform_info = _pi_platform_info; @@ -656,24 +620,23 @@ using pi_sampler_info = _pi_sampler_info; using pi_event_status = _pi_event_status; using pi_program_build_info = _pi_program_build_info; using pi_program_build_status = _pi_program_build_status; +using pi_program_binary_type = _pi_program_binary_type; using pi_kernel_info = _pi_kernel_info; using pi_profiling_info = _pi_profiling_info; // For compatibility with OpenCL define this not as enum. using pi_device_partition_property = intptr_t; static constexpr pi_device_partition_property PI_DEVICE_PARTITION_EQUALLY = - CL_DEVICE_PARTITION_EQUALLY; + 0x1086; static constexpr pi_device_partition_property - PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = - CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN; + PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN = 0x1088; // For compatibility with OpenCL define this not as enum. using pi_device_affinity_domain = pi_bitfield; static constexpr pi_device_affinity_domain PI_DEVICE_AFFINITY_DOMAIN_NUMA = - CL_DEVICE_AFFINITY_DOMAIN_NUMA; + (1 << 0); static constexpr pi_device_affinity_domain - PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = - CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE; + PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE = (1 << 5); // Entry type, matches OpenMP for compatibility struct _pi_offload_entry_struct { @@ -949,10 +912,7 @@ typedef struct { using pi_image_format = _pi_image_format; using pi_image_desc = _pi_image_desc; -typedef enum { - PI_MEM_CONTEXT = CL_MEM_CONTEXT, - PI_MEM_SIZE = CL_MEM_SIZE -} _pi_mem_info; +typedef enum { PI_MEM_CONTEXT = 0x1106, PI_MEM_SIZE = 0x1102 } _pi_mem_info; using pi_mem_info = _pi_mem_info; @@ -1062,8 +1022,8 @@ __SYCL_EXPORT pi_result piextDeviceSelectBinary(pi_device device, /// \arg \c program. /// /// If a fallback method determines the function exists but the address is -/// not available PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE is returned. If the -/// address does not exist PI_INVALID_KERNEL_NAME is returned. +/// not available PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE is returned. If the +/// address does not exist PI_ERROR_INVALID_KERNEL_NAME is returned. __SYCL_EXPORT pi_result piextGetDeviceFunctionPointer( pi_device device, pi_program program, const char *function_name, pi_uint64 *function_pointer_ret); @@ -1118,10 +1078,11 @@ piextContextGetNativeHandle(pi_context context, pi_native_handle *nativeHandle); /// should take ownership of the native handle. /// \param context is the PI context created from the native handle. /// \return PI_SUCCESS if successfully created pi_context from the handle. -/// PI_OUT_OF_HOST_MEMORY if can't allocate memory for the pi_context -/// object. PI_INVALID_VALUE if numDevices == 0 or devices is NULL but -/// backend doesn't have API to query a list of devices from the context -/// native handle. PI_UNKNOWN_ERROR in case of another error. +/// PI_ERROR_OUT_OF_HOST_MEMORY if can't allocate memory for the +/// pi_context object. PI_ERROR_INVALID_VALUE if numDevices == 0 or +/// devices is NULL but backend doesn't have API to query a list of +/// devices from the context native handle. PI_UNKNOWN_ERROR in case of +/// another error. __SYCL_EXPORT pi_result piextContextCreateWithNativeHandle( pi_native_handle nativeHandle, pi_uint32 numDevices, const pi_device *devices, bool pluginOwnsNativeHandle, pi_context *context); @@ -1278,8 +1239,7 @@ __SYCL_EXPORT pi_result piProgramBuild( void (*pfn_notify)(pi_program program, void *user_data), void *user_data); __SYCL_EXPORT pi_result piProgramGetBuildInfo( - pi_program program, pi_device device, - cl_program_build_info param_name, // TODO: untie from OpenCL + pi_program program, pi_device device, _pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret); __SYCL_EXPORT pi_result piProgramRetain(pi_program program); @@ -1326,7 +1286,7 @@ typedef enum { /// indicates that the kernel might access data through USM ptrs PI_USM_INDIRECT_ACCESS, /// provides an explicit list of pointers that the kernel will access - PI_USM_PTRS = CL_KERNEL_EXEC_INFO_USM_PTRS_INTEL + PI_USM_PTRS = 0x4203 } _pi_kernel_exec_info; using pi_kernel_exec_info = _pi_kernel_exec_info; @@ -1621,35 +1581,32 @@ __SYCL_EXPORT pi_result piextKernelSetArgSampler(pi_kernel kernel, // USM /// typedef enum { - PI_USM_HOST_SUPPORT = CL_DEVICE_HOST_MEM_CAPABILITIES_INTEL, - PI_USM_DEVICE_SUPPORT = CL_DEVICE_DEVICE_MEM_CAPABILITIES_INTEL, - PI_USM_SINGLE_SHARED_SUPPORT = - CL_DEVICE_SINGLE_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, - PI_USM_CROSS_SHARED_SUPPORT = - CL_DEVICE_CROSS_DEVICE_SHARED_MEM_CAPABILITIES_INTEL, - PI_USM_SYSTEM_SHARED_SUPPORT = CL_DEVICE_SHARED_SYSTEM_MEM_CAPABILITIES_INTEL + PI_USM_HOST_SUPPORT = 0x4190, + PI_USM_DEVICE_SUPPORT = 0x4191, + PI_USM_SINGLE_SHARED_SUPPORT = 0x4192, + PI_USM_CROSS_SHARED_SUPPORT = 0x4193, + PI_USM_SYSTEM_SHARED_SUPPORT = 0x4194 } _pi_usm_capability_query; typedef enum : pi_bitfield { - PI_USM_ACCESS = CL_UNIFIED_SHARED_MEMORY_ACCESS_INTEL, - PI_USM_ATOMIC_ACCESS = CL_UNIFIED_SHARED_MEMORY_ATOMIC_ACCESS_INTEL, - PI_USM_CONCURRENT_ACCESS = CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ACCESS_INTEL, - PI_USM_CONCURRENT_ATOMIC_ACCESS = - CL_UNIFIED_SHARED_MEMORY_CONCURRENT_ATOMIC_ACCESS_INTEL + PI_USM_ACCESS = (1 << 0), + PI_USM_ATOMIC_ACCESS = (1 << 1), + PI_USM_CONCURRENT_ACCESS = (1 << 2), + PI_USM_CONCURRENT_ATOMIC_ACCESS = (1 << 3) } _pi_usm_capabilities; typedef enum { - PI_MEM_ALLOC_TYPE = CL_MEM_ALLOC_TYPE_INTEL, - PI_MEM_ALLOC_BASE_PTR = CL_MEM_ALLOC_BASE_PTR_INTEL, - PI_MEM_ALLOC_SIZE = CL_MEM_ALLOC_SIZE_INTEL, - PI_MEM_ALLOC_DEVICE = CL_MEM_ALLOC_DEVICE_INTEL, + PI_MEM_ALLOC_TYPE = 0x419A, + PI_MEM_ALLOC_BASE_PTR = 0x419B, + PI_MEM_ALLOC_SIZE = 0x419C, + PI_MEM_ALLOC_DEVICE = 0x419D, } _pi_mem_alloc_info; typedef enum { - PI_MEM_TYPE_UNKNOWN = CL_MEM_TYPE_UNKNOWN_INTEL, - PI_MEM_TYPE_HOST = CL_MEM_TYPE_HOST_INTEL, - PI_MEM_TYPE_DEVICE = CL_MEM_TYPE_DEVICE_INTEL, - PI_MEM_TYPE_SHARED = CL_MEM_TYPE_SHARED_INTEL + PI_MEM_TYPE_UNKNOWN = 0x4196, + PI_MEM_TYPE_HOST = 0x4197, + PI_MEM_TYPE_DEVICE = 0x4198, + PI_MEM_TYPE_SHARED = 0x4199 } _pi_usm_type; // Flag is used for piProgramUSMEnqueuePrefetch. PI_USM_MIGRATION_TBD0 is a diff --git a/sycl/include/CL/sycl/detail/pi.hpp b/sycl/include/CL/sycl/detail/pi.hpp index dbb7adabd2c26..5bddf65c8cc2e 100644 --- a/sycl/include/CL/sycl/detail/pi.hpp +++ b/sycl/include/CL/sycl/detail/pi.hpp @@ -13,6 +13,9 @@ #pragma once +#ifdef PI_OPENCL_AVAILABLE +#include +#endif // PI_OPENCL_AVAILABLE #include #include #include @@ -420,6 +423,16 @@ template inline To cast(From value) { return (To)(value); } +template inline To cast(std::vector value) { + RT::assertion(false, + "Compatibility specialization, not expected to be used. " + "The only allowed cast using a vector of From values is " + "implemented in the OpenCL backend (see cl_event case)."); + return {}; +} + +#ifdef PI_OPENCL_AVAILABLE + // Cast for std::vector, according to the spec, make_event // should create one(?) event from a vector of cl_event template inline To cast(std::vector value) { @@ -439,6 +452,7 @@ template <> inline pi::PiDevice cast(cl_device_id) { RT::assertion(false, "pi::cast -> use piextCreateDeviceWithNativeHandle"); return {}; } +#endif // PI_OPENCL_AVAILABLE } // namespace pi } // namespace detail diff --git a/sycl/include/CL/sycl/detail/property_list_base.hpp b/sycl/include/CL/sycl/detail/property_list_base.hpp index eed8cf9ad4252..d3f1ec09d44ac 100644 --- a/sycl/include/CL/sycl/detail/property_list_base.hpp +++ b/sycl/include/CL/sycl/detail/property_list_base.hpp @@ -93,14 +93,14 @@ class PropertyListBase { const int PropKind = static_cast(PropT::getKind()); if (PropKind >= PropWithDataKind::PropWithDataKindSize) throw sycl::invalid_object_error("The property is not found", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); 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_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } void add_or_replace_accessor_properties_helper( diff --git a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp index 2b4c90d46a598..10b4e415fd087 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -267,7 +267,7 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI { throw runtime_error( "Buffer constructor from a pair of iterator values does not support " "use_host_ptr property.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); setAlign(RequiredAlign); MShadowCopy = allocateHostMem(); @@ -301,7 +301,7 @@ class __SYCL_EXPORT SYCLMemObjT : public SYCLMemObjI { (void)InitFromUserData; (void)HostPtr; (void)InteropEvent; - throw runtime_error("Not implemented", PI_INVALID_OPERATION); + throw runtime_error("Not implemented", PI_ERROR_INVALID_OPERATION); } __SYCL_DLL_LOCAL MemObjType getType() const override { diff --git a/sycl/include/CL/sycl/group.hpp b/sycl/include/CL/sycl/group.hpp index 0577925df24ee..566b481a9fbb3 100644 --- a/sycl/include/CL/sycl/group.hpp +++ b/sycl/include/CL/sycl/group.hpp @@ -125,7 +125,7 @@ template class group { return __spirv::initLocalInvocationId>(); #else throw runtime_error("get_local_id() is not implemented on host device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); // Implementing get_local_id() on host device requires ABI breaking change. // It requires extending class group with local item which represents // local_id. Currently this local id is only used in nd_item and group diff --git a/sycl/include/CL/sycl/group_algorithm.hpp b/sycl/include/CL/sycl/group_algorithm.hpp index bc3a1d9834edf..8c96484993153 100644 --- a/sycl/include/CL/sycl/group_algorithm.hpp +++ b/sycl/include/CL/sycl/group_algorithm.hpp @@ -159,7 +159,7 @@ Function for_each(Group g, Ptr first, Ptr last, Function f) { (void)last; (void)f; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } } // namespace detail @@ -186,7 +186,7 @@ reduce_over_group(Group, T x, BinaryOperation binary_op) { typename sycl::detail::GroupOpTag::type(), x, binary_op); #else throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -209,7 +209,7 @@ reduce_over_group(Group g, T x, BinaryOperation binary_op) { (void)x; (void)binary_op; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -257,7 +257,7 @@ reduce_over_group(Group g, V x, T init, BinaryOperation binary_op) { #else (void)g; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -285,7 +285,7 @@ reduce_over_group(Group g, V x, T init, BinaryOperation binary_op) { #else (void)g; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -309,7 +309,7 @@ joint_reduce(Group g, Ptr first, Ptr last, BinaryOperation binary_op) { (void)last; (void)binary_op; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -344,7 +344,7 @@ joint_reduce(Group g, Ptr first, Ptr last, T init, BinaryOperation binary_op) { (void)g; (void)last; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -357,7 +357,7 @@ any_of_group(Group, bool pred) { #else (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -383,7 +383,7 @@ joint_any_of(Group g, Ptr first, Ptr last, Predicate pred) { (void)last; (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -396,7 +396,7 @@ all_of_group(Group, bool pred) { #else (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -422,7 +422,7 @@ joint_all_of(Group g, Ptr first, Ptr last, Predicate pred) { (void)last; (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -435,7 +435,7 @@ none_of_group(Group, bool pred) { #else (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -458,7 +458,7 @@ joint_none_of(Group g, Ptr first, Ptr last, Predicate pred) { (void)last; (void)pred; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -477,7 +477,7 @@ shift_group_left(Group, T x, typename Group::linear_id_type delta = 1) { (void)x; (void)delta; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -496,7 +496,7 @@ shift_group_right(Group, T x, typename Group::linear_id_type delta = 1) { (void)x; (void)delta; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -515,7 +515,7 @@ permute_group_by_xor(Group, T x, typename Group::linear_id_type mask) { (void)x; (void)mask; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -534,7 +534,7 @@ select_from_group(Group, T x, typename Group::id_type local_id) { (void)x; (void)local_id; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -553,7 +553,7 @@ group_broadcast(Group, T x, typename Group::id_type local_id) { (void)x; (void)local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -572,7 +572,7 @@ group_broadcast(Group g, T x, typename Group::linear_id_type linear_local_id) { (void)x; (void)linear_local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -588,7 +588,7 @@ group_broadcast(Group g, T x) { (void)g; (void)x; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -613,7 +613,7 @@ exclusive_scan_over_group(Group, T x, BinaryOperation binary_op) { typename sycl::detail::GroupOpTag::type(), x, binary_op); #else throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -636,7 +636,7 @@ exclusive_scan_over_group(Group g, T x, BinaryOperation binary_op) { (void)x; (void)binary_op; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -714,7 +714,7 @@ exclusive_scan_over_group(Group g, V x, T init, BinaryOperation binary_op) { #else (void)g; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -772,7 +772,7 @@ joint_exclusive_scan(Group g, InPtr first, InPtr last, OutPtr result, T init, (void)result; (void)init; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -844,7 +844,7 @@ inclusive_scan_over_group(Group, T x, BinaryOperation binary_op) { typename sycl::detail::GroupOpTag::type(), x, binary_op); #else throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -866,7 +866,7 @@ inclusive_scan_over_group(Group g, T x, BinaryOperation binary_op) { (void)x; (void)binary_op; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -896,7 +896,7 @@ inclusive_scan_over_group(Group g, V x, BinaryOperation binary_op, T init) { #else (void)g; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -974,7 +974,7 @@ joint_inclusive_scan(Group g, InPtr first, InPtr last, OutPtr result, (void)last; (void)result; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -1033,7 +1033,7 @@ group_barrier(Group, memory_scope FenceScope = Group::fence_scope) { __spv::MemorySemanticsMask::CrossWorkgroupMemory); #else throw sycl::runtime_error("Barriers are not supported on host device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index ca2bd89143af6..64a39ee2c40ac 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -143,7 +143,7 @@ checkValueRangeImpl(ValT V) { static constexpr size_t Limit = static_cast((std::numeric_limits::max)()); if (V > Limit) - throw runtime_error(NotIntMsg::Msg, PI_INVALID_VALUE); + throw runtime_error(NotIntMsg::Msg, PI_ERROR_INVALID_VALUE); } #endif @@ -550,11 +550,11 @@ class __SYCL_EXPORT handler { if (is_host()) { throw invalid_object_error( "This kernel invocation method cannot be used on the host", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } if (Kernel.is_host()) { throw invalid_object_error("Invalid kernel type, OpenCL expected", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } } @@ -714,7 +714,7 @@ class __SYCL_EXPORT handler { if (IsCallableWithKernelHandler && MIsHost) { throw cl::sycl::feature_not_supported( "kernel_handler is not yet supported by host device.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } KernelType *KernelPtr = ResetHostKernel(KernelFunc); @@ -1767,7 +1767,7 @@ class __SYCL_EXPORT handler { " reduction requires work group size not bigger" " than " + std::to_string(MaxWGSize), - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); // 1. Call the kernel that includes user's lambda function. ext::oneapi::detail::reduCGFunc(*this, KernelFunc, Range, Redu); @@ -1786,7 +1786,7 @@ class __SYCL_EXPORT handler { "The maximal work group size depends on the " "device and the size of the objects passed to " "the reduction.", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); size_t NWorkItems = Range.get_group_range().size(); while (NWorkItems > 1) { handler AuxHandler(QueueCopy, MIsHost); @@ -1865,7 +1865,7 @@ class __SYCL_EXPORT handler { " reduction requires work group size not bigger" " than " + std::to_string(MaxWGSize), - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); ext::oneapi::detail::reduCGFunc(*this, KernelFunc, Range, ReduTuple, ReduIndices); diff --git a/sycl/include/CL/sycl/interop_handle.hpp b/sycl/include/CL/sycl/interop_handle.hpp index a68f5b5e91177..c7f8398a8a6c5 100644 --- a/sycl/include/CL/sycl/interop_handle.hpp +++ b/sycl/include/CL/sycl/interop_handle.hpp @@ -60,7 +60,7 @@ class interop_handle { #ifndef __SYCL_DEVICE_ONLY__ if (Backend != get_backend()) throw invalid_object_error("Incorrect backend argument was passed", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); const auto *AccBase = static_cast(&Acc); return getMemImpl( detail::getSyclObjImpl(*AccBase).get()); @@ -91,7 +91,7 @@ class interop_handle { // are ready to be used. if (Backend != get_backend()) throw invalid_object_error("Incorrect backend argument was passed", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); return reinterpret_cast>(getNativeQueue()); #else // we believe this won't be ever called on device side @@ -112,7 +112,7 @@ class interop_handle { // are ready to be used. if (Backend != get_backend()) throw invalid_object_error("Incorrect backend argument was passed", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); // C-style cast required to allow various native types return (backend_return_t)getNativeDevice(); #else @@ -134,7 +134,7 @@ class interop_handle { // are ready to be used. if (Backend != get_backend()) throw invalid_object_error("Incorrect backend argument was passed", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); return reinterpret_cast>( getNativeContext()); #else diff --git a/sycl/include/CL/sycl/kernel_handler.hpp b/sycl/include/CL/sycl/kernel_handler.hpp index 86caabce7076e..1758b6694c724 100644 --- a/sycl/include/CL/sycl/kernel_handler.hpp +++ b/sycl/include/CL/sycl/kernel_handler.hpp @@ -32,7 +32,7 @@ class kernel_handler { throw cl::sycl::feature_not_supported( "kernel_handler::get_specialization_constant() is not yet supported by " "host device.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); #endif // __SYCL_DEVICE_ONLY__ } #endif // __cplusplus >= 201703L diff --git a/sycl/include/CL/sycl/property_list.hpp b/sycl/include/CL/sycl/property_list.hpp index 8c9a8183a6c1f..7431727fe0f97 100644 --- a/sycl/include/CL/sycl/property_list.hpp +++ b/sycl/include/CL/sycl/property_list.hpp @@ -42,7 +42,7 @@ 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_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return get_property_helper(); } diff --git a/sycl/include/CL/sycl/queue.hpp b/sycl/include/CL/sycl/queue.hpp index f01e4be0548e6..4477d7bfb05a3 100644 --- a/sycl/include/CL/sycl/queue.hpp +++ b/sycl/include/CL/sycl/queue.hpp @@ -1187,7 +1187,7 @@ event submitAssertCapture(queue &Self, event &Event, queue *SecondaryQueue, if (AH->Flag == __SYCL_ASSERT_START) throw sycl::runtime_error( "Internal Error. Invalid value in assert description.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); #endif if (AH->Flag) { diff --git a/sycl/include/CL/sycl/reduction.hpp b/sycl/include/CL/sycl/reduction.hpp index 32d6bd991b650..57f4d25db19ca 100644 --- a/sycl/include/CL/sycl/reduction.hpp +++ b/sycl/include/CL/sycl/reduction.hpp @@ -46,7 +46,7 @@ reduction(buffer, handler &, BinaryOperation, (void)PropList; throw runtime_error("Identity-less reductions with unknown identity are not " "supported yet.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs a reduction object using the reduction variable referenced by @@ -80,7 +80,7 @@ reduction(T *, BinaryOperation, const property_list &PropList = {}) { (void)PropList; throw runtime_error("Identity-less reductions with unknown identity are not " "supported yet.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs a reduction object using the given buffer \p Var, handler \p CGH, @@ -149,7 +149,7 @@ reduction(span, BinaryOperation, (void)PropList; throw runtime_error("Identity-less reductions with unknown identity are not " "supported yet.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs a reduction object using the reduction variable referenced by diff --git a/sycl/include/CL/sycl/sub_group.hpp b/sycl/include/CL/sycl/sub_group.hpp index bbae64f2504e6..40fc72a0040b1 100644 --- a/sycl/include/CL/sycl/sub_group.hpp +++ b/sycl/include/CL/sycl/sub_group.hpp @@ -25,7 +25,7 @@ inline sub_group this_sub_group() { return sub_group(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } } // namespace experimental diff --git a/sycl/include/sycl/ext/oneapi/__function_pointer.hpp b/sycl/include/sycl/ext/oneapi/__function_pointer.hpp index 4569f47513d04..9d259624e8c16 100644 --- a/sycl/include/sycl/ext/oneapi/__function_pointer.hpp +++ b/sycl/include/sycl/ext/oneapi/__function_pointer.hpp @@ -80,7 +80,7 @@ device_func_ptr_holder_t get_device_func_ptr(FuncType F, const char *FuncName, if (program_state::linked != P.get_state()) { throw invalid_parameter_error( "Program must be built before passing to get_device_func_ptr", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } return sycl::detail::getDeviceFunctionPointerImpl(D, P, FuncName); diff --git a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp index fe305d5f9f0e6..9f5e64d1de42b 100644 --- a/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp +++ b/sycl/include/sycl/ext/oneapi/accessor_property_list.hpp @@ -181,7 +181,7 @@ class accessor_property_list : protected sycl::detail::PropertyListBase { PropT get_property() const { if (!has_property()) throw sycl::invalid_object_error("The property is not found", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return get_property_helper(); } diff --git a/sycl/include/sycl/ext/oneapi/backend/level_zero.hpp b/sycl/include/sycl/ext/oneapi/backend/level_zero.hpp index 9340681c7f537..4d2121f74e841 100644 --- a/sycl/include/sycl/ext/oneapi/backend/level_zero.hpp +++ b/sycl/include/sycl/ext/oneapi/backend/level_zero.hpp @@ -231,7 +231,7 @@ inline auto get_native( // TODO use SYCL 2020 exception when implemented if (Obj.get_backend() != backend::ext_oneapi_level_zero) throw runtime_error(errc::backend_mismatch, "Backends mismatch", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); return Obj.template getNative(); } diff --git a/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp b/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp index ee5c58b67a440..dfa850ef0a725 100644 --- a/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp +++ b/sycl/include/sycl/ext/oneapi/bf16_storage_builtins.hpp @@ -43,7 +43,7 @@ std::enable_if_t::value, T> fabs(T x) { #else (void)x; throw runtime_error("bf16 is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } template @@ -54,7 +54,7 @@ std::enable_if_t::value, T> fmin(T x, T y) { (void)x; (void)y; throw runtime_error("bf16 is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } template @@ -65,7 +65,7 @@ std::enable_if_t::value, T> fmax(T x, T y) { (void)x; (void)y; throw runtime_error("bf16 is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } template @@ -77,7 +77,7 @@ std::enable_if_t::value, T> fma(T x, T y, T z) { (void)y; (void)z; throw runtime_error("bf16 is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } diff --git a/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp b/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp index 9c824ffa3a64b..f0bbfcee7f707 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/cuda/barrier.hpp @@ -35,7 +35,7 @@ class barrier { (void)state; (void)expected_count; throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -44,7 +44,7 @@ class barrier { __clc_BarrierInvalidate(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -53,7 +53,7 @@ class barrier { return __clc_BarrierArrive(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -62,7 +62,7 @@ class barrier { return __clc_BarrierArriveAndDrop(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -72,7 +72,7 @@ class barrier { #else (void)count; throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -82,7 +82,7 @@ class barrier { #else (void)count; throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -91,7 +91,7 @@ class barrier { __clc_BarrierCopyAsyncArrive(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -100,7 +100,7 @@ class barrier { __clc_BarrierCopyAsyncArriveNoInc(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -110,7 +110,7 @@ class barrier { #else (void)arrival; throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -120,7 +120,7 @@ class barrier { #else (void)arrival; throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -129,7 +129,7 @@ class barrier { __clc_BarrierArriveAndWait(&state); #else throw runtime_error("Barrier is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } diff --git a/sycl/include/sycl/ext/oneapi/experimental/group_helpers_sorters.hpp b/sycl/include/sycl/ext/oneapi/experimental/group_helpers_sorters.hpp index a47ee187855a5..f00c8e8e654d5 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/group_helpers_sorters.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/group_helpers_sorters.hpp @@ -53,7 +53,7 @@ template > class default_sorter { (void)first; (void)last; throw sycl::exception( - std::error_code(PI_INVALID_DEVICE, sycl::sycl_category()), + std::error_code(PI_ERROR_INVALID_DEVICE, sycl::sycl_category()), "default_sorter constructor is not supported on host device."); #endif } @@ -74,7 +74,7 @@ template > class default_sorter { #else (void)g; throw sycl::exception( - std::error_code(PI_INVALID_DEVICE, sycl::sycl_category()), + std::error_code(PI_ERROR_INVALID_DEVICE, sycl::sycl_category()), "default_sorter operator() is not supported on host device."); #endif return val; diff --git a/sycl/include/sycl/ext/oneapi/experimental/group_sort.hpp b/sycl/include/sycl/ext/oneapi/experimental/group_sort.hpp index df29ab840f7ff..8af120b1ac869 100644 --- a/sycl/include/sycl/ext/oneapi/experimental/group_sort.hpp +++ b/sycl/include/sycl/ext/oneapi/experimental/group_sort.hpp @@ -77,7 +77,7 @@ sort_over_group(Group group, T value, Sorter sorter) { (void)value; (void)sorter; throw sycl::exception( - std::error_code(PI_INVALID_DEVICE, sycl::sycl_category()), + std::error_code(PI_ERROR_INVALID_DEVICE, sycl::sycl_category()), "Group algorithms are not supported on host device."); #endif } @@ -112,7 +112,7 @@ joint_sort(Group group, Iter first, Iter last, Sorter sorter) { (void)last; (void)sorter; throw sycl::exception( - std::error_code(PI_INVALID_DEVICE, sycl::sycl_category()), + std::error_code(PI_ERROR_INVALID_DEVICE, sycl::sycl_category()), "Group algorithms are not supported on host device."); #endif } diff --git a/sycl/include/sycl/ext/oneapi/group_algorithm.hpp b/sycl/include/sycl/ext/oneapi/group_algorithm.hpp index d328744010724..bd2ba9730d76b 100644 --- a/sycl/include/sycl/ext/oneapi/group_algorithm.hpp +++ b/sycl/include/sycl/ext/oneapi/group_algorithm.hpp @@ -154,7 +154,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)x; (void)local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -176,7 +176,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)x; (void)local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -198,7 +198,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)x; (void)linear_local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -221,7 +221,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)x; (void)linear_local_id; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -238,7 +238,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)g; (void)x; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -258,7 +258,7 @@ detail::enable_if_t<(detail::is_generic_group::value && (void)g; (void)x; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -541,7 +541,7 @@ leader(Group g) { #else (void)g; throw runtime_error("Group algorithms are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } diff --git a/sycl/include/sycl/ext/oneapi/group_local_memory.hpp b/sycl/include/sycl/ext/oneapi/group_local_memory.hpp index 7a9b41c73c526..3049b332fe616 100644 --- a/sycl/include/sycl/ext/oneapi/group_local_memory.hpp +++ b/sycl/include/sycl/ext/oneapi/group_local_memory.hpp @@ -36,7 +36,7 @@ std::enable_if_t::value && #else throw feature_not_supported( "sycl_ext_oneapi_local_memory extension is not supported on host device", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); #endif } @@ -61,7 +61,7 @@ std::enable_if_t::value && [&args...] {}(); throw feature_not_supported( "sycl_ext_oneapi_local_memory extension is not supported on host device", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); #endif } } // namespace oneapi diff --git a/sycl/include/sycl/ext/oneapi/matrix/matrix-jit.hpp b/sycl/include/sycl/ext/oneapi/matrix/matrix-jit.hpp index af4d1927fd176..b84eb16b7b088 100644 --- a/sycl/include/sycl/ext/oneapi/matrix/matrix-jit.hpp +++ b/sycl/include/sycl/ext/oneapi/matrix/matrix-jit.hpp @@ -61,7 +61,7 @@ struct joint_matrix { #ifndef __SYCL_DEVICE_ONLY__ (void)sg; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -119,7 +119,7 @@ joint_matrix_load(Group sg, (void)stride; (void)MemL; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -167,7 +167,7 @@ joint_matrix_store(Group sg, (void)stride; (void)MemL; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -199,7 +199,7 @@ joint_matrix_mad(Group sg, joint_matrix &mA, (void)mB; (void)mC; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -240,7 +240,7 @@ class wi_element { return __spirv_VectorExtractDynamic(M.spvm, idx); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -249,7 +249,7 @@ class wi_element { return __spirv_VectorExtractDynamic(M.spvm, idx) != static_cast(0); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -260,7 +260,7 @@ class wi_element { #else (void)rhs; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -273,7 +273,7 @@ class wi_element { #else (void)rhs; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -292,7 +292,7 @@ class wi_element { template wi_element &operator op##=(const T2 &rhs) { \ (void)rhs; \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } #endif // __SYCL_DEVICE_ONLY__ OP(+) @@ -322,7 +322,7 @@ class wi_element { return __spirv_VectorExtractDynamic(M.spvm, idx); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -332,7 +332,7 @@ class wi_element { std::numeric_limits::epsilon(); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -343,7 +343,7 @@ class wi_element { #else (void)rhs; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -356,7 +356,7 @@ class wi_element { #else (void)rhs; throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -392,7 +392,7 @@ class wi_element { wi_element &operator op##=(const uint16_t &rhs) { \ (void)rhs; \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } #endif // __SYCL_DEVICE_ONLY__ OP(+) @@ -430,7 +430,7 @@ class wi_element { (void)lhs; \ (void)rhs; \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } \ friend type operator op( \ const uint16_t &lhs, \ @@ -438,7 +438,7 @@ class wi_element { (void)lhs; \ (void)rhs; \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } #endif // __SYCL_DEVICE_ONLY__ OP(float, uint16_t, +) @@ -471,7 +471,7 @@ class wi_element= std::numeric_limits::epsilon(); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } @@ -492,7 +492,7 @@ class wi_element &, \ const sycl::ext::oneapi::experimental::bfloat16 &) { \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } \ friend type operator op( \ const sycl::ext::oneapi::experimental::bfloat16 &, \ const wi_element &) { \ throw runtime_error("joint matrix is not supported on host device.", \ - PI_INVALID_DEVICE); \ + PI_ERROR_INVALID_DEVICE); \ } OP(sycl::ext::oneapi::experimental::bfloat16, +) OP(sycl::ext::oneapi::experimental::bfloat16, -) @@ -616,7 +616,7 @@ class wi_data { return __spirv_JointMatrixWorkItemLengthINTEL(M.spvm); #else throw runtime_error("joint matrix is not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // __SYCL_DEVICE_ONLY__ } wi_element operator[](size_t i) { diff --git a/sycl/include/sycl/ext/oneapi/matrix/matrix-tensorcore.hpp b/sycl/include/sycl/ext/oneapi/matrix/matrix-tensorcore.hpp index 5c6df9114b161..08949553e97f3 100644 --- a/sycl/include/sycl/ext/oneapi/matrix/matrix-tensorcore.hpp +++ b/sycl/include/sycl/ext/oneapi/matrix/matrix-tensorcore.hpp @@ -524,7 +524,7 @@ void joint_matrix_load( throw runtime_error( "When using SYCL_EXT_ONEAPI_MATRIX=3 joint_matrix_load is " "only supported by CUDA devices", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__) } @@ -546,7 +546,7 @@ void joint_matrix_store(Group sg, throw runtime_error( "When using SYCL_EXT_ONEAPI_MATRIX=3 joint_matrix_store is " "only supported by CUDA devices", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__) } @@ -569,7 +569,7 @@ joint_matrix_mad( (void)C; throw runtime_error("When using SYCL_EXT_ONEAPI_MATRIX=3 joint_matrix_mad is " "only supported by CUDA devices", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__) } diff --git a/sycl/include/sycl/ext/oneapi/reduction.hpp b/sycl/include/sycl/ext/oneapi/reduction.hpp index 91b07f07cc083..28353b457b156 100644 --- a/sycl/include/sycl/ext/oneapi/reduction.hpp +++ b/sycl/include/sycl/ext/oneapi/reduction.hpp @@ -778,7 +778,7 @@ class reduction_impl if (Buffer.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs reduction_impl when the identity value is statically known. @@ -791,7 +791,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs reduction_impl when the identity value is statically known. @@ -804,7 +804,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// SYCL-2020. @@ -822,7 +822,7 @@ class reduction_impl if (Buffer.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // For now the implementation ignores the identity value given by user // when the implementation knows the identity. // The SPEC could prohibit passing identity parameter to operations with @@ -847,7 +847,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // For now the implementation ignores the identity value given by user // when the implementation knows the identity. // The SPEC could prohibit passing identity parameter to operations with @@ -872,7 +872,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // For now the implementation ignores the identity value given by user // when the implementation knows the identity. // The SPEC could prohibit passing identity parameter to operations with @@ -900,7 +900,7 @@ class reduction_impl if (Buffer.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs reduction_impl when the identity value is unknown. @@ -912,7 +912,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs reduction_impl when the identity value is unknown. @@ -924,7 +924,7 @@ class reduction_impl if (Acc.size() != 1) throw sycl::runtime_error(errc::invalid, "Reduction variable must be a scalar.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } /// Constructs reduction_impl when the identity value is statically known. diff --git a/sycl/include/sycl/ext/oneapi/sub_group.hpp b/sycl/include/sycl/ext/oneapi/sub_group.hpp index 07d1f8ca5526a..58f9c61d72433 100644 --- a/sycl/include/sycl/ext/oneapi/sub_group.hpp +++ b/sycl/include/sycl/ext/oneapi/sub_group.hpp @@ -121,7 +121,7 @@ struct sub_group { return __spirv_SubgroupLocalInvocationId(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -130,7 +130,7 @@ struct sub_group { return static_cast(get_local_id()[0]); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -139,7 +139,7 @@ struct sub_group { return __spirv_SubgroupSize(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -148,7 +148,7 @@ struct sub_group { return __spirv_SubgroupMaxSize(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -157,7 +157,7 @@ struct sub_group { return __spirv_SubgroupId(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -166,7 +166,7 @@ struct sub_group { return static_cast(get_group_id()[0]); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -175,7 +175,7 @@ struct sub_group { return __spirv_NumSubgroups(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -194,7 +194,7 @@ struct sub_group { (void)x; (void)local_id; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -205,7 +205,7 @@ struct sub_group { (void)x; (void)delta; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -216,7 +216,7 @@ struct sub_group { (void)x; (void)delta; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -227,7 +227,7 @@ struct sub_group { (void)x; (void)value; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -272,7 +272,7 @@ struct sub_group { T load(CVT *src) const { (void)src; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } #endif //__SYCL_DEVICE_ONLY__ @@ -291,7 +291,7 @@ struct sub_group { #else (void)src; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -306,7 +306,7 @@ struct sub_group { #else (void)src; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } #ifdef __SYCL_DEVICE_ONLY__ @@ -382,7 +382,7 @@ struct sub_group { load(const multi_ptr src) const { (void)src; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } #endif // __SYCL_DEVICE_ONLY__ @@ -402,7 +402,7 @@ struct sub_group { #else (void)src; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -449,7 +449,7 @@ struct sub_group { (void)dst; (void)x; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } #endif //__SYCL_DEVICE_ONLY__ @@ -467,7 +467,7 @@ struct sub_group { (void)dst; (void)x; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -481,7 +481,7 @@ struct sub_group { (void)dst; (void)x; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -539,7 +539,7 @@ struct sub_group { (void)dst; (void)x; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } #endif // __SYCL_DEVICE_ONLY__ @@ -555,7 +555,7 @@ struct sub_group { (void)dst; (void)x; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -570,7 +570,7 @@ struct sub_group { __spv::MemorySemanticsMask::CrossWorkgroupMemory); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -584,7 +584,7 @@ struct sub_group { #else (void)accessSpace; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -599,7 +599,7 @@ struct sub_group { (void)x; (void)local_id; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -615,7 +615,7 @@ struct sub_group { (void)x; (void)op; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -630,7 +630,7 @@ struct sub_group { (void)init; (void)op; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -646,7 +646,7 @@ struct sub_group { (void)x; (void)op; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -669,7 +669,7 @@ struct sub_group { (void)init; (void)op; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -685,7 +685,7 @@ struct sub_group { (void)x; (void)op; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -704,7 +704,7 @@ struct sub_group { (void)op; (void)init; throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -713,7 +713,7 @@ struct sub_group { return static_cast(get_group_range()[0]); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -722,7 +722,7 @@ struct sub_group { return static_cast(get_local_range()[0]); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -731,7 +731,7 @@ struct sub_group { return get_local_linear_id() == 0; #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } @@ -749,7 +749,7 @@ inline sub_group this_sub_group() { return sub_group(); #else throw runtime_error("Sub-groups are not supported on host device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #endif } diff --git a/sycl/plugins/cuda/pi_cuda.cpp b/sycl/plugins/cuda/pi_cuda.cpp index 2b1014e125122..5e8dfb0dbf6f5 100644 --- a/sycl/plugins/cuda/pi_cuda.cpp +++ b/sycl/plugins/cuda/pi_cuda.cpp @@ -41,23 +41,23 @@ pi_result map_error(CUresult result) { case CUDA_SUCCESS: return PI_SUCCESS; case CUDA_ERROR_NOT_PERMITTED: - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; case CUDA_ERROR_INVALID_CONTEXT: - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; case CUDA_ERROR_INVALID_DEVICE: - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; case CUDA_ERROR_INVALID_VALUE: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; case CUDA_ERROR_OUT_OF_MEMORY: - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; case CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES: - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; default: return PI_ERROR_UNKNOWN; } } -// Global variables for PI_PLUGIN_SPECIFIC_ERROR +// Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR constexpr size_t MaxMessageSize = 256; thread_local pi_result ErrorMessageCode = PI_SUCCESS; thread_local char ErrorMessage[MaxMessageSize]; @@ -83,7 +83,7 @@ pi_result forLatestEvents(const pi_event *event_wait_list, std::size_t num_events_in_wait_list, Func &&f) { if (event_wait_list == nullptr || num_events_in_wait_list == 0) { - return PI_INVALID_EVENT_WAIT_LIST; + return PI_ERROR_INVALID_EVENT_WAIT_LIST; } // Fast path if we only have a single event @@ -181,7 +181,7 @@ class ScopedContext { public: ScopedContext(pi_context ctxt) { if (!ctxt) { - throw PI_INVALID_CONTEXT; + throw PI_ERROR_INVALID_CONTEXT; } CUcontext desired = ctxt->get(); @@ -208,7 +208,7 @@ pi_result getInfoImpl(size_t param_value_size, void *param_value, if (param_value != nullptr) { if (param_value_size < value_size) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } assign_func(param_value, value, value_size); @@ -492,13 +492,13 @@ pi_uint64 _pi_event::get_end_time() const { pi_result _pi_event::record() { if (is_recorded() || !is_started()) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } - pi_result result = PI_INVALID_OPERATION; + pi_result result = PI_ERROR_INVALID_OPERATION; if (!queue_) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } try { @@ -642,7 +642,7 @@ pi_result _pi_program::build_program(const char *build_options) { success ? PI_PROGRAM_BUILD_STATUS_SUCCESS : PI_PROGRAM_BUILD_STATUS_ERROR; // If no exception, result is correct - return success ? PI_SUCCESS : PI_BUILD_PROGRAM_FAILURE; + return success ? PI_SUCCESS : PI_ERROR_BUILD_PROGRAM_FAILURE; } /// Finds kernel names by searching for entry points in the PTX source, as the @@ -756,10 +756,10 @@ pi_result cuda_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, static std::vector<_pi_platform> platformIds; if (num_entries == 0 && platforms != nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (platforms == nullptr && num_platforms == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result err = PI_SUCCESS; @@ -814,7 +814,7 @@ pi_result cuda_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, platformIds[i].devices_.clear(); } platformIds.clear(); - err = PI_OUT_OF_HOST_MEMORY; + err = PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { // Clear and rethrow to allow retry for (int i = 0; i < numDevices; ++i) { @@ -840,7 +840,7 @@ pi_result cuda_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -906,7 +906,7 @@ pi_result cuda_piDevicesGet(pi_platform platform, pi_device_type device_type, } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -953,7 +953,7 @@ pi_result cuda_piContextGetInfo(pi_context context, pi_context_info param_name, __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } pi_result cuda_piContextRetain(pi_context context) { @@ -971,10 +971,8 @@ pi_result cuda_piextContextSetExtendedDeleter( } /// Not applicable to CUDA, devices cannot be partitioned. -/// TODO: untie cl_device_partition_property from OpenCL -/// pi_result cuda_piDevicePartition(pi_device, - const cl_device_partition_property *, + const pi_device_partition_property *, pi_uint32, pi_device *, pi_uint32 *) { return {}; } @@ -1006,7 +1004,7 @@ pi_result cuda_piextDeviceSelectBinary(pi_device device, } // No image can be loaded for the given device - return PI_INVALID_BINARY; + return PI_ERROR_INVALID_BINARY; } pi_result cuda_piextGetDeviceFunctionPointer(pi_device device, @@ -1026,7 +1024,7 @@ pi_result cuda_piextGetDeviceFunctionPointer(pi_device device, retError = PI_CHECK_ERROR(ret); if (ret == CUDA_ERROR_NOT_FOUND) { *func_pointer_ret = 0; - retError = PI_INVALID_KERNEL_NAME; + retError = PI_ERROR_INVALID_KERNEL_NAME; } return retError; @@ -1462,7 +1460,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: { // TODO: is this config consistent across all NVIDIA GPUs? return getInfo(param_value_size, param_value, param_value_size_ret, - CL_READ_WRITE_CACHE); + PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE); } case PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: { // The value is documented for all existing GPUs in the CUDA programming @@ -1569,20 +1567,20 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, PI_TRUE); } case PI_DEVICE_INFO_EXECUTION_CAPABILITIES: { - auto capability = CL_EXEC_KERNEL; + auto capability = PI_DEVICE_EXEC_CAPABILITIES_KERNEL; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { // The mandated minimum capability: auto capability = - CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { // The mandated minimum capability: - auto capability = CL_QUEUE_PROFILING_ENABLE; + auto capability = PI_QUEUE_PROFILING_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } @@ -1670,15 +1668,14 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, } case PI_DEVICE_INFO_PARTITION_PROPERTIES: { return getInfo(param_value_size, param_value, param_value_size_ret, - static_cast(0u)); + static_cast(0u)); } case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: { return getInfo(param_value_size, param_value, param_value_size_ret, 0u); } case PI_DEVICE_INFO_PARTITION_TYPE: { - // TODO: uncouple from OpenCL return getInfo(param_value_size, param_value, param_value_size_ret, - static_cast(0u)); + static_cast(0u)); } // Intel USM extensions @@ -1826,7 +1823,7 @@ pi_result cuda_piDeviceGetInfo(pi_device device, pi_device_info param_name, // For details about this extension, see // sycl/doc/extensions/supported/sycl_ext_intel_device_info.md case PI_DEVICE_INFO_UUID: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; default: __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); @@ -1917,7 +1914,7 @@ pi_result cuda_piContextCreate(const pi_context_properties *properties, // Unknown property. cl::sycl::detail::pi::die( "Unknown piContextCreate property in property list"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } @@ -1967,7 +1964,7 @@ pi_result cuda_piContextCreate(const pi_context_properties *properties, } catch (pi_result err) { errcode_ret = err; } catch (...) { - errcode_ret = PI_OUT_OF_RESOURCES; + errcode_ret = PI_ERROR_OUT_OF_RESOURCES; } return errcode_ret; } @@ -2095,13 +2092,13 @@ pi_result cuda_piMemBufferCreate(pi_context context, pi_mem_flags flags, } } } else { - retErr = PI_OUT_OF_HOST_MEMORY; + retErr = PI_ERROR_OUT_OF_HOST_MEMORY; } } } catch (pi_result err) { retErr = err; } catch (...) { - retErr = PI_OUT_OF_RESOURCES; + retErr = PI_ERROR_OUT_OF_RESOURCES; } *ret_mem = retMemObj; @@ -2114,7 +2111,7 @@ pi_result cuda_piMemBufferCreate(pi_context context, pi_mem_flags flags, /// \return PI_SUCCESS unless deallocation error /// pi_result cuda_piMemRelease(pi_mem memObj) { - assert((memObj != nullptr) && "PI_INVALID_MEM_OBJECTS"); + assert((memObj != nullptr) && "PI_ERROR_INVALID_MEM_OBJECTS"); pi_result ret = PI_SUCCESS; @@ -2158,7 +2155,7 @@ pi_result cuda_piMemRelease(pi_mem memObj) { } catch (pi_result err) { ret = err; } catch (...) { - ret = PI_OUT_OF_RESOURCES; + ret = PI_ERROR_OUT_OF_RESOURCES; } if (ret != PI_SUCCESS) { @@ -2180,30 +2177,30 @@ pi_result cuda_piMemRelease(pi_mem memObj) { pi_result cuda_piMemBufferPartition(pi_mem parent_buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, void *buffer_create_info, pi_mem *memObj) { - assert((parent_buffer != nullptr) && "PI_INVALID_MEM_OBJECT"); - assert(parent_buffer->is_buffer() && "PI_INVALID_MEM_OBJECTS"); - assert(!parent_buffer->is_sub_buffer() && "PI_INVALID_MEM_OBJECT"); + assert((parent_buffer != nullptr) && "PI_ERROR_INVALID_MEM_OBJECT"); + assert(parent_buffer->is_buffer() && "PI_ERROR_INVALID_MEM_OBJECTS"); + assert(!parent_buffer->is_sub_buffer() && "PI_ERROR_INVALID_MEM_OBJECT"); // Default value for flags means PI_MEM_FLAGS_ACCCESS_RW. if (flags == 0) { flags = PI_MEM_FLAGS_ACCESS_RW; } - assert((flags == PI_MEM_FLAGS_ACCESS_RW) && "PI_INVALID_VALUE"); + assert((flags == PI_MEM_FLAGS_ACCESS_RW) && "PI_ERROR_INVALID_VALUE"); assert((buffer_create_type == PI_BUFFER_CREATE_TYPE_REGION) && - "PI_INVALID_VALUE"); - assert((buffer_create_info != nullptr) && "PI_INVALID_VALUE"); + "PI_ERROR_INVALID_VALUE"); + assert((buffer_create_info != nullptr) && "PI_ERROR_INVALID_VALUE"); assert(memObj != nullptr); const auto bufferRegion = *reinterpret_cast(buffer_create_info); - assert((bufferRegion.size != 0u) && "PI_INVALID_BUFFER_SIZE"); + assert((bufferRegion.size != 0u) && "PI_ERROR_INVALID_BUFFER_SIZE"); assert((bufferRegion.origin <= (bufferRegion.origin + bufferRegion.size)) && "Overflow"); assert(((bufferRegion.origin + bufferRegion.size) <= parent_buffer->mem_.buffer_mem_.get_size()) && - "PI_INVALID_BUFFER_SIZE"); + "PI_ERROR_INVALID_BUFFER_SIZE"); // Retained indirectly due to retaining parent buffer below. pi_context context = parent_buffer->context_; _pi_mem::mem_::buffer_mem_::alloc_mode allocMode = @@ -2233,7 +2230,7 @@ pi_result cuda_piMemBufferPartition(pi_mem parent_buffer, pi_mem_flags flags, return err; } catch (...) { *memObj = nullptr; - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } releaseGuard.dismiss(); @@ -2290,7 +2287,7 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, if (context->get_device() != device) { *queue = nullptr; - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } unsigned int flags = 0; @@ -2323,7 +2320,7 @@ pi_result cuda_piQueueCreate(pi_context context, pi_device device, } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -2381,7 +2378,7 @@ pi_result cuda_piQueueRelease(pi_queue command_queue) { } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -2404,7 +2401,7 @@ pi_result cuda_piQueueFinish(pi_queue command_queue) { } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; @@ -2551,11 +2548,11 @@ pi_result cuda_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { assert(num_events != 0); assert(event_list); if (num_events == 0) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (!event_list) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } auto context = event_list[0]->get_context(); @@ -2563,11 +2560,11 @@ pi_result cuda_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { auto waitFunc = [context](pi_event event) -> pi_result { if (!event) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } if (event->get_context() != context) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } return event->wait(); @@ -2576,7 +2573,7 @@ pi_result cuda_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -2613,7 +2610,7 @@ pi_result cuda_piKernelCreate(pi_program program, const char *kernel_name, } catch (pi_result err) { retErr = err; } catch (...) { - retErr = PI_OUT_OF_HOST_MEMORY; + retErr = PI_ERROR_OUT_OF_HOST_MEMORY; } *kernel = retKernel.release(); @@ -2759,7 +2756,7 @@ pi_result cuda_piKernelGetGroupInfo(pi_kernel kernel, pi_device device, } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result cuda_piEnqueueKernelLaunch( @@ -2798,17 +2795,17 @@ pi_result cuda_piEnqueueKernelLaunch( auto isValid = [&](int dim) { if (reqdThreadsPerBlock[dim] != 0 && local_work_size[dim] != reqdThreadsPerBlock[dim]) - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; if (local_work_size[dim] > maxThreadsPerBlock[dim]) - return PI_INVALID_WORK_ITEM_SIZE; + return PI_ERROR_INVALID_WORK_ITEM_SIZE; // Checks that local work sizes are a divisor of the global work sizes // which includes that the local work sizes are neither larger than // the global work sizes and not 0. if (0u == local_work_size[dim]) - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; if (0u != (global_work_size[dim] % local_work_size[dim])) - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; threadsPerBlock[dim] = local_work_size[dim]; return PI_SUCCESS; }; @@ -2826,7 +2823,7 @@ pi_result cuda_piEnqueueKernelLaunch( if (maxWorkGroupSize < size_t(threadsPerBlock[0] * threadsPerBlock[1] * threadsPerBlock[2])) { - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } size_t blocksPerGrid[3] = {1u, 1u, 1u}; @@ -2883,8 +2880,8 @@ pi_result cuda_piEnqueueKernelLaunch( if (env_val <= 0 || env_val > device_max_local_mem) { setErrorMessage("Invalid value specified for " "SYCL_PI_CUDA_MAX_LOCAL_MEM_SIZE", - PI_PLUGIN_SPECIFIC_ERROR); - return PI_PLUGIN_SPECIFIC_ERROR; + PI_ERROR_PLUGIN_SPECIFIC_ERROR); + return PI_ERROR_PLUGIN_SPECIFIC_ERROR; } PI_CHECK_ERROR(cuFuncSetAttribute( cuFunc, CU_FUNC_ATTRIBUTE_MAX_DYNAMIC_SHARED_SIZE_BYTES, env_val)); @@ -3063,7 +3060,7 @@ pi_result cuda_piMemImageCreate(pi_context context, pi_mem_flags flags, context, image_array, surface, image_desc->image_type, host_ptr}); if (piMemObj == nullptr) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } *ret_mem = piMemObj.release(); @@ -3099,7 +3096,7 @@ pi_result cuda_piclProgramCreateWithSource(pi_context, pi_uint32, const char **, const size_t *, pi_program *) { cl::sycl::detail::pi::cuPrint( "cuda_piclProgramCreateWithSource not implemented"); - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } /// Loads the images from a PI program into a CUmodule that can be @@ -3313,7 +3310,7 @@ pi_result cuda_piProgramCompile( } pi_result cuda_piProgramGetBuildInfo(pi_program program, pi_device device, - cl_program_build_info param_name, + pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { // Ignore unused parameter @@ -3362,14 +3359,14 @@ pi_result cuda_piProgramRelease(pi_program program) { std::unique_ptr<_pi_program> program_ptr{program}; - pi_result result = PI_INVALID_PROGRAM; + pi_result result = PI_ERROR_INVALID_PROGRAM; try { ScopedContext active(program->get_context()); auto cuModule = program->get(); result = PI_CHECK_ERROR(cuModuleUnload(cuModule)); } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; @@ -3439,7 +3436,7 @@ pi_result cuda_piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result cuda_piKernelGetSubGroupInfo( @@ -3492,7 +3489,7 @@ pi_result cuda_piKernelGetSubGroupInfo( __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result cuda_piKernelRetain(pi_kernel kernel) { @@ -3576,11 +3573,11 @@ pi_result cuda_piEventGetInfo(pi_event event, pi_event_info param_name, __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } /// Obtain profiling information from PI CUDA events -/// \TODO Untie from OpenCL, timings from CUDA are only elapsed time. +/// \TODO Timings from CUDA are only elapsed time. pi_result cuda_piEventGetProfilingInfo(pi_event event, pi_profiling_info param_name, size_t param_value_size, @@ -3591,7 +3588,7 @@ pi_result cuda_piEventGetProfilingInfo(pi_event event, pi_queue queue = event->get_queue(); if (queue == nullptr || !(queue->properties_ & PI_QUEUE_PROFILING_ENABLE)) { - return PI_PROFILING_INFO_NOT_AVAILABLE; + return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } switch (param_name) { @@ -3619,7 +3616,7 @@ pi_result cuda_piEventSetCallback(pi_event, pi_int32, pfn_notify, void *) { pi_result cuda_piEventSetStatus(pi_event, pi_int32) { cl::sycl::detail::pi::die("Event Set Status not implemented in CUDA backend"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result cuda_piEventRetain(pi_event event) { @@ -3646,12 +3643,12 @@ pi_result cuda_piEventRelease(pi_event event) { // decrement ref count. If it is 0, delete the event. if (event->decrement_reference_count() == 0) { std::unique_ptr<_pi_event> event_ptr{event}; - pi_result result = PI_INVALID_EVENT; + pi_result result = PI_ERROR_INVALID_EVENT; try { ScopedContext active(event->get_context()); result = event->release(); } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; } @@ -3689,7 +3686,7 @@ pi_result cuda_piEnqueueEventsWaitWithBarrier(pi_queue command_queue, const pi_event *event_wait_list, pi_event *event) { if (!command_queue) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } try { @@ -3727,7 +3724,7 @@ pi_result cuda_piEnqueueEventsWaitWithBarrier(pi_queue command_queue, /// \param[in] event The PI event to get the native CUDA object of. /// \param[out] nativeHandle Set to the native handle of the PI event object. /// -/// \return PI_SUCCESS on success. PI_INVALID_EVENT if given a user event. +/// \return PI_SUCCESS on success. PI_ERROR_INVALID_EVENT if given a user event. pi_result cuda_piextEventGetNativeHandle(pi_event event, pi_native_handle *nativeHandle) { *nativeHandle = reinterpret_cast(event->get()); @@ -3755,7 +3752,8 @@ pi_result cuda_piextEventCreateWithNativeHandle(pi_native_handle, pi_context, /// \param[in] sampler_properties The properties for the sampler. /// \param[out] result_sampler Set to the resulting sampler object. /// -/// \return PI_SUCCESS on success. PI_INVALID_VALUE if given an invalid property +/// \return PI_SUCCESS on success. PI_ERROR_INVALID_VALUE if given an invalid +/// property /// or if there is multiple of properties from the same category. pi_result cuda_piSamplerCreate(pi_context context, const pi_sampler_properties *sampler_properties, @@ -3767,14 +3765,14 @@ pi_result cuda_piSamplerCreate(pi_context context, switch (sampler_properties[i]) { case PI_SAMPLER_PROPERTIES_NORMALIZED_COORDS: if (propSeen[0]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[0] = true; retImplSampl->props_ |= sampler_properties[i + 1]; break; case PI_SAMPLER_PROPERTIES_FILTER_MODE: if (propSeen[1]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[1] = true; retImplSampl->props_ |= @@ -3782,23 +3780,25 @@ pi_result cuda_piSamplerCreate(pi_context context, break; case PI_SAMPLER_PROPERTIES_ADDRESSING_MODE: if (propSeen[2]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[2] = true; retImplSampl->props_ |= (sampler_properties[i + 1] - PI_SAMPLER_ADDRESSING_MODE_NONE) << 2; break; default: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } if (!propSeen[0]) { - retImplSampl->props_ |= CL_TRUE; + retImplSampl->props_ |= PI_TRUE; } - // Default filter mode to CL_FILTER_NEAREST + // Default filter mode to PI_SAMPLER_FILTER_MODE_NEAREST if (!propSeen[2]) { - retImplSampl->props_ |= (CL_ADDRESS_CLAMP % CL_ADDRESS_NONE) << 2; + retImplSampl->props_ |= + (PI_SAMPLER_ADDRESSING_MODE_CLAMP % PI_SAMPLER_ADDRESSING_MODE_NONE) + << 2; } *result_sampler = retImplSampl.release(); @@ -3814,7 +3814,7 @@ pi_result cuda_piSamplerCreate(pi_context context, /// \param[out] param_value_size_ret Set to the size of the information value. /// /// \return PI_SUCCESS on success. -pi_result cuda_piSamplerGetInfo(pi_sampler sampler, cl_sampler_info param_name, +pi_result cuda_piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { assert(sampler != nullptr); @@ -4055,7 +4055,7 @@ pi_result cuda_piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, const pi_event *event_wait_list, pi_event *event) { if (!command_queue) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } std::unique_ptr<_pi_event> retImplEv{nullptr}; @@ -4320,7 +4320,7 @@ static pi_result commonEnqueueMemImageNDCopy( cpyDesc.Depth = region[2]; return PI_CHECK_ERROR(cuMemcpy3DAsync(&cpyDesc, cu_stream)); } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result cuda_piEnqueueMemImageRead( @@ -4528,7 +4528,7 @@ pi_result cuda_piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, return retErr; } -/// \TODO Not implemented in CUDA, requires untie from OpenCL +/// \TODO Not implemented in CUDA. pi_result cuda_piEnqueueMemImageFill(pi_queue, pi_mem, const void *, const size_t *, const size_t *, pi_uint32, const pi_event *, pi_event *) { @@ -4540,7 +4540,6 @@ pi_result cuda_piEnqueueMemImageFill(pi_queue, pi_mem, const void *, /// Mapped pointers are stored in the pi_mem object. /// If the buffer uses pinned host memory a pointer to that memory is returned /// and no read operation is done. -/// \TODO Untie types from OpenCL /// pi_result cuda_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, @@ -4554,7 +4553,7 @@ pi_result cuda_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, assert(buffer != nullptr); assert(buffer->mem_type_ == _pi_mem::mem_type::buffer); - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; const bool is_pinned = buffer->mem_.buffer_mem_.allocMode_ == _pi_mem::mem_::buffer_mem_::alloc_mode::alloc_host_ptr; @@ -4846,7 +4845,7 @@ pi_result cuda_piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, setErrorMessage("Prefetch hint ignored as device does not support " "concurrent managed access", PI_SUCCESS); - return PI_PLUGIN_SPECIFIC_ERROR; + return PI_ERROR_PLUGIN_SPECIFIC_ERROR; } unsigned int is_managed; @@ -4855,12 +4854,12 @@ pi_result cuda_piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, if (!is_managed) { setErrorMessage("Prefetch hint ignored as prefetch only works with USM", PI_SUCCESS); - return PI_PLUGIN_SPECIFIC_ERROR; + return PI_ERROR_PLUGIN_SPECIFIC_ERROR; } // flags is currently unused so fail if set if (flags != 0) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; assert(queue != nullptr); assert(ptr != nullptr); pi_result result = PI_SUCCESS; @@ -5021,7 +5020,7 @@ pi_result cuda_piextUSMGetMemAllocInfo(pi_context context, const void *ptr, return getInfo(param_value_size, param_value, param_value_size_ret, value); #else - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; #endif } case PI_MEM_ALLOC_SIZE: { @@ -5033,7 +5032,7 @@ pi_result cuda_piextUSMGetMemAllocInfo(pi_context context, const void *ptr, return getInfo(param_value_size, param_value, param_value_size_ret, value); #else - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; #endif } case PI_MEM_ALLOC_DEVICE: { @@ -5072,13 +5071,13 @@ pi_result piPluginInit(pi_plugin *PluginInit) { if (CompareVersions < 0) { // PI interface supports lower version of PI. // TODO: Take appropriate actions. - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } // PI interface supports higher version or the same version. size_t PluginVersionSize = sizeof(PluginInit->PluginVersion); if (strlen(SupportedVersion) >= PluginVersionSize) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; strncpy(PluginInit->PluginVersion, SupportedVersion, PluginVersionSize); // Set whole function table to zero to make it easier to detect if diff --git a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp index 7ef6123f49cc4..c33fc598a6a9c 100644 --- a/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp +++ b/sycl/plugins/esimd_emulator/pi_esimd_emulator.cpp @@ -55,7 +55,7 @@ pi_result getInfoImpl(size_t ParamValueSize, void *ParamValue, Assign &&AssignFunc) { if (ParamValue != nullptr) { if (ParamValueSize < ValueSize) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } AssignFunc(ParamValue, Value, ValueSize); } @@ -141,7 +141,7 @@ static std::mutex *PiESimdSurfaceMapLock = new std::mutex; // For PI_DEVICE_INFO_DRIVER_VERSION info static char ESimdEmuVersionString[32]; -// Global variables for PI_PLUGIN_SPECIFIC_ERROR +// Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR constexpr size_t MaxMessageSize = 256; thread_local pi_result ErrorMessageCode = PI_SUCCESS; thread_local char ErrorMessage[MaxMessageSize]; @@ -371,7 +371,7 @@ extern "C" { << " - File : " << __FILE__; \ std::cerr << " / Line : " << __LINE__ << std::endl; \ } \ - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; #define CONTINUE_NO_IMPLEMENTATION \ if (PrintPiTrace) { \ @@ -389,7 +389,7 @@ extern "C" { << __FUNCTION__ << ":" << __LINE__ << "(" << __FILE__ << ")" \ << std::endl; \ } \ - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, pi_uint32 *NumPlatforms) { @@ -413,13 +413,13 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, "(Platforms!=nullptr) while querying number of platforms" << std::endl; } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } if (Platforms == nullptr && NumPlatforms == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } std::lock_guard Lock{*PiPlatformCacheLock}; @@ -440,7 +440,7 @@ pi_result piPlatformGetInfo(pi_platform Platform, pi_platform_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { if (Platform == nullptr) { - return PI_INVALID_PLATFORM; + return PI_ERROR_INVALID_PLATFORM; } ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); @@ -480,7 +480,7 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType, pi_uint32 NumEntries, pi_device *Devices, pi_uint32 *NumDevices) { if (Platform == nullptr) { - return PI_INVALID_PLATFORM; + return PI_ERROR_INVALID_PLATFORM; } pi_result Res = Platform->populateDeviceCacheIfNeeded(); @@ -503,7 +503,7 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType, "(Devices!=nullptr) while querying number of platforms" << std::endl; } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } @@ -540,7 +540,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() { int Result = cm_support::CreateCmDevice(CmDevice, Version); if (Result != cm_support::CM_SUCCESS) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } // CM Device version info consists of two decimal numbers - major @@ -555,7 +555,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() { std::cerr << "CM_EMU Device version info is incorrect : " << Version << std::endl; } - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } std::ostringstream StrFormat; @@ -570,7 +570,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() { pi_result piDeviceRetain(pi_device Device) { if (Device == nullptr) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } // CM supports only single device, which is root-device. 'Retain' is @@ -580,7 +580,7 @@ pi_result piDeviceRetain(pi_device Device) { pi_result piDeviceRelease(pi_device Device) { if (Device == nullptr) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } // CM supports only single device, which is root-device. 'Release' @@ -835,20 +835,20 @@ pi_result piContextCreate(const pi_context_properties *Properties, ARG_UNUSED(UserData); if (NumDevices != 1) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (Devices == nullptr) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } if (RetContext == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } try { /// Single-root-device *RetContext = new _pi_context(Devices[0]); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -877,7 +877,7 @@ pi_result piextContextCreateWithNativeHandle(pi_native_handle, pi_uint32, pi_result piContextRetain(pi_context Context) { if (Context == nullptr) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } ++(Context->RefCount); @@ -887,7 +887,7 @@ pi_result piContextRetain(pi_context Context) { pi_result piContextRelease(pi_context Context) { if (Context == nullptr || (Context->RefCount <= 0)) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } if (--(Context->RefCount) == 0) { @@ -934,20 +934,20 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, if (Properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { // TODO : Support Out-of-order Queue *Queue = nullptr; - return PI_INVALID_QUEUE_PROPERTIES; + return PI_ERROR_INVALID_QUEUE_PROPERTIES; } cm_support::CmQueue *CmQueue; int Result = Context->Device->CmDevicePtr->CreateQueue(CmQueue); if (Result != cm_support::CM_SUCCESS) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } try { *Queue = new _pi_queue(Context, CmQueue); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -961,7 +961,7 @@ pi_result piQueueGetInfo(pi_queue, pi_queue_info, size_t, void *, size_t *) { pi_result piQueueRetain(pi_queue Queue) { if (Queue == nullptr) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } ++(Queue->RefCount); return PI_SUCCESS; @@ -969,7 +969,7 @@ pi_result piQueueRetain(pi_queue Queue) { pi_result piQueueRelease(pi_queue Queue) { if ((Queue == nullptr) || (Queue->CmQueuePtr == nullptr)) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } if (--(Queue->RefCount) == 0) { @@ -1014,19 +1014,19 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, std::cerr << "Invalid memory attribute for piMemBufferCreate" << std::endl; } - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } if (Context == nullptr) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } if (RetMem == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // Flag & HostPtr argument sanity check if (!Context->checkSurfaceArgument(Flags, HostPtr)) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } char *MapBasePtr = nullptr; @@ -1053,7 +1053,7 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, } if (Status != cm_support::CM_SUCCESS) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } MapBasePtr = @@ -1063,7 +1063,7 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, *RetMem = new _pi_buffer(Context, MapBasePtr, CmBuf, CmIndex->get_data(), Size); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -1084,7 +1084,7 @@ pi_result piMemGetInfo(pi_mem, pi_mem_info, size_t, void *, size_t *) { pi_result piMemRetain(pi_mem Mem) { if (Mem == nullptr) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } ++(Mem->RefCount); return PI_SUCCESS; @@ -1092,7 +1092,7 @@ pi_result piMemRetain(pi_mem Mem) { pi_result piMemRelease(pi_mem Mem) { if ((Mem == nullptr) || (Mem->RefCount == 0)) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } if (--(Mem->RefCount) == 0) { @@ -1163,11 +1163,11 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, if (PrintPiTrace) { std::cerr << "Invalid memory attribute for piMemImageCreate" << std::endl; } - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } if (ImageFormat == nullptr || ImageDesc == nullptr) - return PI_INVALID_IMAGE_FORMAT_DESCRIPTOR; + return PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR; switch (ImageDesc->image_type) { case PI_MEM_TYPE_IMAGE2D: @@ -1180,7 +1180,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, CASE_PI_UNSUPPORTED(PI_MEM_TYPE_IMAGE1D_BUFFER) default: - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } auto BytesPerPixel = 4; @@ -1205,18 +1205,18 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, CASE_PI_UNSUPPORTED(PI_IMAGE_CHANNEL_TYPE_HALF_FLOAT) CASE_PI_UNSUPPORTED(PI_IMAGE_CHANNEL_TYPE_FLOAT) default: - return PI_IMAGE_FORMAT_NOT_SUPPORTED; + return PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED; } // Flag & HostPtr argument sanity check if (!Context->checkSurfaceArgument(Flags, HostPtr)) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } cm_support::CM_SURFACE_FORMAT CmSurfFormat = ConvertPiImageFormatToCmFormat(ImageFormat); if (CmSurfFormat == cm_support::CM_SURFACE_FORMAT_UNKNOWN) { - return PI_IMAGE_FORMAT_NOT_SUPPORTED; + return PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED; } char *MapBasePtr = nullptr; @@ -1248,7 +1248,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, } if (Status != cm_support::CM_SUCCESS) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } MapBasePtr = @@ -1259,7 +1259,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, ImageDesc->image_width, ImageDesc->image_height, BytesPerPixel); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -1328,7 +1328,7 @@ pi_result piProgramBuild(pi_program, pi_uint32, const pi_device *, const char *, DIE_NO_IMPLEMENTATION; } -pi_result piProgramGetBuildInfo(pi_program, pi_device, cl_program_build_info, +pi_result piProgramGetBuildInfo(pi_program, pi_device, pi_program_build_info, size_t, void *, size_t *) { DIE_NO_IMPLEMENTATION; } @@ -1412,11 +1412,11 @@ pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) { continue; } if (EventList[i]->CmEventPtr == nullptr) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } int Result = EventList[i]->CmEventPtr->WaitForTaskFinished(); if (Result != cm_support::CM_SUCCESS) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } return PI_SUCCESS; @@ -1431,7 +1431,7 @@ pi_result piEventSetStatus(pi_event, pi_int32) { DIE_NO_IMPLEMENTATION; } pi_result piEventRetain(pi_event Event) { if (Event == nullptr) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } ++(Event->RefCount); @@ -1441,17 +1441,17 @@ pi_result piEventRetain(pi_event Event) { pi_result piEventRelease(pi_event Event) { if (Event == nullptr || (Event->RefCount <= 0)) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } if (--(Event->RefCount) == 0) { if (!Event->IsDummyEvent) { if ((Event->CmEventPtr == nullptr) || (Event->OwnerQueue == nullptr)) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } int Result = Event->OwnerQueue->DestroyEvent(Event->CmEventPtr); if (Result != cm_support::CM_SUCCESS) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } } delete Event; @@ -1511,7 +1511,7 @@ pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src, "ESIMD_EMULATOR does not support buffer reading with offsets"); if (NumEventsInWaitList != 0) { - return PI_INVALID_EVENT_WAIT_LIST; + return PI_ERROR_INVALID_EVENT_WAIT_LIST; } _pi_buffer *buf = static_cast<_pi_buffer *>(Src); @@ -1534,7 +1534,7 @@ pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src, static_cast(Size)); if (Status != cm_support::CM_SUCCESS) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } } @@ -1619,7 +1619,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem MemObj, // False as the second value in pair means that mapping was not inserted // because mapping already exists. if (!Res.second) { - ret = PI_INVALID_VALUE; + ret = PI_ERROR_INVALID_VALUE; if (PrintPiTrace) { std::cerr << "piEnqueueMemBufferMap: duplicate mapping detected" << std::endl; @@ -1656,7 +1656,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem MemObj, void *MappedPtr, std::lock_guard Lock(MemObj->MappingsMutex); auto It = MemObj->Mappings.find(MappedPtr); if (It == MemObj->Mappings.end()) { - ret = PI_INVALID_VALUE; + ret = PI_ERROR_INVALID_VALUE; if (PrintPiTrace) { std::cerr << "piEnqueueMemUnmap: unknown memory mapping" << std::endl; } @@ -1721,7 +1721,7 @@ pi_result piEnqueueMemImageRead(pi_queue CommandQueue, pi_mem Image, static_cast(Size)); if (Status != cm_support::CM_SUCCESS) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } } @@ -1768,11 +1768,11 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, const size_t LocalWorkSz[] = {1, 1, 1}; if (Kernel == nullptr) { - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } if (WorkDim > 3 || WorkDim == 0) { - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } if (isNull(WorkDim, LocalWorkSize)) { @@ -1781,7 +1781,7 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, for (pi_uint32 I = 0; I < WorkDim; I++) { if ((GlobalWorkSize[I] % LocalWorkSize[I]) != 0) { - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } } @@ -1855,11 +1855,11 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context, ARG_UNUSED(Alignment); if (Context == nullptr || (Device != Context->Device)) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } if (ResultPtr == nullptr) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } // 'Size' must be power of two in order to prevent memory corruption @@ -1874,13 +1874,13 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context, Size, SystemMemPtr, CM_SVM_ACCESS_FLAG_DEFAULT, Buf); if (Result != cm_support::CM_SUCCESS) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } *ResultPtr = SystemMemPtr; std::lock_guard Lock(Context->Addr2CmBufferSVMLock); auto Iter = Context->Addr2CmBufferSVM.find(SystemMemPtr); if (Context->Addr2CmBufferSVM.end() != Iter) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } Context->Addr2CmBufferSVM[SystemMemPtr] = Buf; return PI_SUCCESS; @@ -1888,20 +1888,20 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context, pi_result piextUSMFree(pi_context Context, void *Ptr) { if (Context == nullptr) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } if (Ptr == nullptr) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } std::lock_guard Lock(Context->Addr2CmBufferSVMLock); cm_support::CmBufferSVM *Buf = Context->Addr2CmBufferSVM[Ptr]; if (Buf == nullptr) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } auto Count = Context->Addr2CmBufferSVM.erase(Ptr); if (Count != 1) { - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } int32_t Result = Context->Device->CmDevicePtr->DestroyBufferSVM(Buf); if (cm_support::CM_SUCCESS != Result) { @@ -1954,7 +1954,7 @@ pi_result piextDeviceSelectBinary(pi_device, pi_device_binary *, << "Only single device binary image is supported in ESIMD_EMULATOR" << std::endl; } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } *ImgInd = 0; return PI_SUCCESS; @@ -1988,12 +1988,12 @@ pi_result piTearDown(void *) { pi_result piPluginInit(pi_plugin *PluginInit) { if (PluginInit == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } size_t PluginVersionSize = sizeof(PluginInit->PluginVersion); if (strlen(_PI_H_VERSION_STRING) >= PluginVersionSize) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } strncpy(PluginInit->PluginVersion, _PI_H_VERSION_STRING, PluginVersionSize); diff --git a/sycl/plugins/hip/pi_hip.cpp b/sycl/plugins/hip/pi_hip.cpp index 0e07bb373e92f..b0a9d58187494 100644 --- a/sycl/plugins/hip/pi_hip.cpp +++ b/sycl/plugins/hip/pi_hip.cpp @@ -98,21 +98,21 @@ pi_result map_error(hipError_t result) { case hipSuccess: return PI_SUCCESS; case hipErrorInvalidContext: - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; case hipErrorInvalidDevice: - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; case hipErrorInvalidValue: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; case hipErrorOutOfMemory: - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; case hipErrorLaunchOutOfResources: - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; default: return PI_ERROR_UNKNOWN; } } -// Global variables for PI_PLUGIN_SPECIFIC_ERROR +// Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR constexpr size_t MaxMessageSize = 256; thread_local pi_result ErrorMessageCode = PI_SUCCESS; thread_local char ErrorMessage[MaxMessageSize]; @@ -139,7 +139,7 @@ pi_result forLatestEvents(const pi_event *event_wait_list, std::size_t num_events_in_wait_list, Func &&f) { if (event_wait_list == nullptr || num_events_in_wait_list == 0) { - return PI_INVALID_EVENT_WAIT_LIST; + return PI_ERROR_INVALID_EVENT_WAIT_LIST; } // Fast path if we only have a single event @@ -226,7 +226,7 @@ class ScopedContext { ScopedContext(pi_context ctxt) : placedContext_{ctxt}, needToRecover_{false} { if (!placedContext_) { - throw PI_INVALID_CONTEXT; + throw PI_ERROR_INVALID_CONTEXT; } hipCtx_t desired = placedContext_->get(); @@ -263,7 +263,7 @@ pi_result getInfoImpl(size_t param_value_size, void *param_value, if (param_value != nullptr) { if (param_value_size < value_size) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } assign_func(param_value, value, value_size); @@ -488,13 +488,13 @@ pi_uint64 _pi_event::get_end_time() const { pi_result _pi_event::record() { if (is_recorded() || !is_started()) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } - pi_result result = PI_INVALID_OPERATION; + pi_result result = PI_ERROR_INVALID_OPERATION; if (!queue_) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } hipStream_t hipStream = queue_->get(); @@ -597,7 +597,7 @@ pi_result _pi_program::build_program(const char *build_options) { success ? PI_PROGRAM_BUILD_STATUS_SUCCESS : PI_PROGRAM_BUILD_STATUS_ERROR; // If no exception, result is correct - return success ? PI_SUCCESS : PI_BUILD_PROGRAM_FAILURE; + return success ? PI_SUCCESS : PI_ERROR_BUILD_PROGRAM_FAILURE; } /// Finds kernel names by searching for entry points in the PTX source, as the @@ -706,10 +706,10 @@ pi_result hip_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, static std::vector<_pi_platform> platformIds; if (num_entries == 0 and platforms != nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (platforms == nullptr and num_platforms == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result err = PI_SUCCESS; @@ -748,7 +748,7 @@ pi_result hip_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, platformIds[i].devices_.clear(); } platformIds.clear(); - err = PI_OUT_OF_HOST_MEMORY; + err = PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { // Clear and rethrow to allow retry for (int i = 0; i < numDevices; ++i) { @@ -774,7 +774,7 @@ pi_result hip_piPlatformsGet(pi_uint32 num_entries, pi_platform *platforms, } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -840,7 +840,7 @@ pi_result hip_piDevicesGet(pi_platform platform, pi_device_type device_type, } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -869,7 +869,7 @@ pi_result hip_piContextGetInfo(pi_context context, pi_context_info param_name, __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } pi_result hip_piContextRetain(pi_context context) { @@ -888,17 +888,17 @@ pi_result hip_piextContextSetExtendedDeleter( /// Not applicable to HIP, devices cannot be partitioned. /// -pi_result hip_piDevicePartition( - pi_device device, - const cl_device_partition_property *properties, // TODO: untie from OpenCL - pi_uint32 num_devices, pi_device *out_devices, pi_uint32 *out_num_devices) { +pi_result hip_piDevicePartition(pi_device device, + const pi_device_partition_property *properties, + pi_uint32 num_devices, pi_device *out_devices, + pi_uint32 *out_num_devices) { (void)device; (void)properties; (void)num_devices; (void)out_devices; (void)out_num_devices; - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } /// \return If available, the first binary that is PTX @@ -933,7 +933,7 @@ pi_result hip_piextDeviceSelectBinary(pi_device device, } // No image can be loaded for the given device - return PI_INVALID_BINARY; + return PI_ERROR_INVALID_BINARY; } pi_result hip_piextGetDeviceFunctionPointer(pi_device device, @@ -953,7 +953,7 @@ pi_result hip_piextGetDeviceFunctionPointer(pi_device device, retError = PI_CHECK_ERROR(ret); if (ret == hipErrorNotFound) { *func_pointer_ret = 0; - retError = PI_INVALID_KERNEL_NAME; + retError = PI_ERROR_INVALID_KERNEL_NAME; } return retError; @@ -1339,7 +1339,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, } case PI_DEVICE_INFO_GLOBAL_MEM_CACHE_TYPE: { return getInfo(param_value_size, param_value, param_value_size_ret, - CL_READ_WRITE_CACHE); + PI_DEVICE_MEM_CACHE_TYPE_READ_WRITE_CACHE); } case PI_DEVICE_INFO_GLOBAL_MEM_CACHELINE_SIZE: { // The value is dohipmented for all existing GPUs in the HIP programming @@ -1450,20 +1450,20 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, PI_TRUE); } case PI_DEVICE_INFO_EXECUTION_CAPABILITIES: { - auto capability = CL_EXEC_KERNEL; + auto capability = PI_DEVICE_EXEC_CAPABILITIES_KERNEL; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_DEVICE_PROPERTIES: { // The mandated minimum capability: auto capability = - CL_QUEUE_PROFILING_ENABLE | CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; + PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } case PI_DEVICE_INFO_QUEUE_ON_HOST_PROPERTIES: { // The mandated minimum capability: - auto capability = CL_QUEUE_PROFILING_ENABLE; + auto capability = PI_QUEUE_PROFILING_ENABLE; return getInfo(param_value_size, param_value, param_value_size_ret, capability); } @@ -1549,15 +1549,14 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, } case PI_DEVICE_INFO_PARTITION_PROPERTIES: { return getInfo(param_value_size, param_value, param_value_size_ret, - static_cast(0u)); + static_cast(0u)); } case PI_DEVICE_INFO_PARTITION_AFFINITY_DOMAIN: { return getInfo(param_value_size, param_value, param_value_size_ret, 0u); } case PI_DEVICE_INFO_PARTITION_TYPE: { - // TODO: uncouple from OpenCL return getInfo(param_value_size, param_value, param_value_size_ret, - static_cast(0u)); + static_cast(0u)); } // Intel USM extensions @@ -1678,7 +1677,7 @@ pi_result hip_piDeviceGetInfo(pi_device device, pi_device_info param_name, case PI_DEVICE_INFO_GPU_EU_COUNT_PER_SUBSLICE: case PI_DEVICE_INFO_GPU_HW_THREADS_PER_EU: case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; default: __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); @@ -1773,7 +1772,7 @@ pi_result hip_piContextCreate(const pi_context_properties *properties, // Unknown property. cl::sycl::detail::pi::die( "Unknown piContextCreate property in property list"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } @@ -1817,7 +1816,7 @@ pi_result hip_piContextCreate(const pi_context_properties *properties, } catch (pi_result err) { errcode_ret = err; } catch (...) { - errcode_ret = PI_OUT_OF_RESOURCES; + errcode_ret = PI_ERROR_OUT_OF_RESOURCES; } return errcode_ret; } @@ -1963,13 +1962,13 @@ pi_result hip_piMemBufferCreate(pi_context context, pi_mem_flags flags, } } } else { - retErr = PI_OUT_OF_HOST_MEMORY; + retErr = PI_ERROR_OUT_OF_HOST_MEMORY; } } } catch (pi_result err) { retErr = err; } catch (...) { - retErr = PI_OUT_OF_RESOURCES; + retErr = PI_ERROR_OUT_OF_RESOURCES; } *ret_mem = retMemObj; @@ -1982,7 +1981,7 @@ pi_result hip_piMemBufferCreate(pi_context context, pi_mem_flags flags, /// \return PI_SUCCESS unless deallocation error /// pi_result hip_piMemRelease(pi_mem memObj) { - assert((memObj != nullptr) && "PI_INVALID_MEM_OBJECTS"); + assert((memObj != nullptr) && "PI_ERROR_INVALID_MEM_OBJECTS"); pi_result ret = PI_SUCCESS; @@ -2029,7 +2028,7 @@ pi_result hip_piMemRelease(pi_mem memObj) { } catch (pi_result err) { ret = err; } catch (...) { - ret = PI_OUT_OF_RESOURCES; + ret = PI_ERROR_OUT_OF_RESOURCES; } if (ret != PI_SUCCESS) { @@ -2051,30 +2050,30 @@ pi_result hip_piMemRelease(pi_mem memObj) { pi_result hip_piMemBufferPartition(pi_mem parent_buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, void *buffer_create_info, pi_mem *memObj) { - assert((parent_buffer != nullptr) && "PI_INVALID_MEM_OBJECT"); - assert(parent_buffer->is_buffer() && "PI_INVALID_MEM_OBJECTS"); - assert(!parent_buffer->is_sub_buffer() && "PI_INVALID_MEM_OBJECT"); + assert((parent_buffer != nullptr) && "PI_ERROR_INVALID_MEM_OBJECT"); + assert(parent_buffer->is_buffer() && "PI_ERROR_INVALID_MEM_OBJECTS"); + assert(!parent_buffer->is_sub_buffer() && "PI_ERROR_INVALID_MEM_OBJECT"); // Default value for flags means PI_MEM_FLAGS_ACCCESS_RW. if (flags == 0) { flags = PI_MEM_FLAGS_ACCESS_RW; } - assert((flags == PI_MEM_FLAGS_ACCESS_RW) && "PI_INVALID_VALUE"); + assert((flags == PI_MEM_FLAGS_ACCESS_RW) && "PI_ERROR_INVALID_VALUE"); assert((buffer_create_type == PI_BUFFER_CREATE_TYPE_REGION) && - "PI_INVALID_VALUE"); - assert((buffer_create_info != nullptr) && "PI_INVALID_VALUE"); + "PI_ERROR_INVALID_VALUE"); + assert((buffer_create_info != nullptr) && "PI_ERROR_INVALID_VALUE"); assert(memObj != nullptr); const auto bufferRegion = *reinterpret_cast(buffer_create_info); - assert((bufferRegion.size != 0u) && "PI_INVALID_BUFFER_SIZE"); + assert((bufferRegion.size != 0u) && "PI_ERROR_INVALID_BUFFER_SIZE"); assert((bufferRegion.origin <= (bufferRegion.origin + bufferRegion.size)) && "Overflow"); assert(((bufferRegion.origin + bufferRegion.size) <= parent_buffer->mem_.buffer_mem_.get_size()) && - "PI_INVALID_BUFFER_SIZE"); + "PI_ERROR_INVALID_BUFFER_SIZE"); // Retained indirectly due to retaining parent buffer below. pi_context context = parent_buffer->context_; _pi_mem::mem_::buffer_mem_::alloc_mode allocMode = @@ -2104,7 +2103,7 @@ pi_result hip_piMemBufferPartition(pi_mem parent_buffer, pi_mem_flags flags, return err; } catch (...) { *memObj = nullptr; - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } releaseGuard.dismiss(); @@ -2143,7 +2142,7 @@ pi_result hip_piextMemGetNativeHandle(pi_mem mem, mem->mem_.buffer_mem_.get() >> (sizeof(pi_native_handle) * CHAR_BIT); if (upperBits) { // Return an error if any of the remaining bits is non-zero. - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; } } *nativeHandle = static_cast(mem->mem_.buffer_mem_.get()); @@ -2196,7 +2195,7 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, if (context->get_device() != device) { *queue = nullptr; - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } ScopedContext active(context); @@ -2220,7 +2219,7 @@ pi_result hip_piQueueCreate(pi_context context, pi_device device, } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -2277,14 +2276,14 @@ pi_result hip_piQueueRelease(pi_queue command_queue) { } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } pi_result hip_piQueueFinish(pi_queue command_queue) { // set default result to a negative result (avoid false-positve tests) - pi_result result = PI_OUT_OF_HOST_MEMORY; + pi_result result = PI_ERROR_OUT_OF_HOST_MEMORY; try { @@ -2299,7 +2298,7 @@ pi_result hip_piQueueFinish(pi_queue command_queue) { } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; @@ -2451,11 +2450,11 @@ pi_result hip_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { assert(num_events != 0); assert(event_list); if (num_events == 0) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (!event_list) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } auto context = event_list[0]->get_context(); @@ -2463,11 +2462,11 @@ pi_result hip_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { auto waitFunc = [context](pi_event event) -> pi_result { if (!event) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } if (event->get_context() != context) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } return event->wait(); @@ -2476,7 +2475,7 @@ pi_result hip_piEventsWait(pi_uint32 num_events, const pi_event *event_list) { } catch (pi_result err) { return err; } catch (...) { - return PI_OUT_OF_RESOURCES; + return PI_ERROR_OUT_OF_RESOURCES; } } @@ -2513,7 +2512,7 @@ pi_result hip_piKernelCreate(pi_program program, const char *kernel_name, } catch (pi_result err) { retErr = err; } catch (...) { - retErr = PI_OUT_OF_HOST_MEMORY; + retErr = PI_ERROR_OUT_OF_HOST_MEMORY; } *kernel = retKernel.release(); @@ -2627,14 +2626,14 @@ pi_result hip_piEnqueueKernelLaunch( if (providedLocalWorkGroupSize) { auto isValid = [&](int dim) { if (local_work_size[dim] > maxThreadsPerBlock[dim]) - return PI_INVALID_WORK_ITEM_SIZE; + return PI_ERROR_INVALID_WORK_ITEM_SIZE; // Checks that local work sizes are a divisor of the global work sizes // which includes that the local work sizes are neither larger than the // global work sizes and not 0. if (0u == local_work_size[dim]) - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; if (0u != (global_work_size[dim] % local_work_size[dim])) - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; threadsPerBlock[dim] = local_work_size[dim]; return PI_SUCCESS; }; @@ -2652,7 +2651,7 @@ pi_result hip_piEnqueueKernelLaunch( if (maxWorkGroupSize < size_t(threadsPerBlock[0] * threadsPerBlock[1] * threadsPerBlock[2])) { - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } size_t blocksPerGrid[3] = {1u, 1u, 1u}; @@ -2879,7 +2878,7 @@ pi_result hip_piMemImageCreate(pi_context context, pi_mem_flags flags, context, image_array, surface, image_desc->image_type, host_ptr}); if (piMemObj == nullptr) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } *ret_mem = piMemObj.release(); @@ -2929,7 +2928,7 @@ pi_result hip_piclProgramCreateWithSource(pi_context context, pi_uint32 count, cl::sycl::detail::pi::hipPrint( "hip_piclProgramCreateWithSource not implemented"); - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } /// Loads the images from a PI program into a HIPmodule that can be @@ -3107,7 +3106,7 @@ pi_result hip_piProgramCompile( } pi_result hip_piProgramGetBuildInfo(pi_program program, pi_device device, - cl_program_build_info param_name, + pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { (void)device; @@ -3155,14 +3154,14 @@ pi_result hip_piProgramRelease(pi_program program) { std::unique_ptr<_pi_program> program_ptr{program}; - pi_result result = PI_INVALID_PROGRAM; + pi_result result = PI_ERROR_INVALID_PROGRAM; try { ScopedContext active(program->get_context()); auto hipModule = program->get(); result = PI_CHECK_ERROR(hipModuleUnload(hipModule)); } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; @@ -3241,7 +3240,7 @@ pi_result hip_piKernelGetInfo(pi_kernel kernel, pi_kernel_info param_name, } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result hip_piKernelGetGroupInfo(pi_kernel kernel, pi_device device, @@ -3312,7 +3311,7 @@ pi_result hip_piKernelGetGroupInfo(pi_kernel kernel, pi_device device, } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result hip_piKernelGetSubGroupInfo( @@ -3364,7 +3363,7 @@ pi_result hip_piKernelGetSubGroupInfo( __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } } - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } pi_result hip_piKernelRetain(pi_kernel kernel) { @@ -3457,11 +3456,11 @@ pi_result hip_piEventGetInfo(pi_event event, pi_event_info param_name, __SYCL_PI_HANDLE_UNKNOWN_PARAM_NAME(param_name); } - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } /// Obtain profiling information from PI HIP events -/// \TODO Untie from OpenCL, timings from HIP are only elapsed time. +/// Timings from HIP are only elapsed time. pi_result hip_piEventGetProfilingInfo(pi_event event, pi_profiling_info param_name, size_t param_value_size, @@ -3472,7 +3471,7 @@ pi_result hip_piEventGetProfilingInfo(pi_event event, pi_queue queue = event->get_queue(); if (queue == nullptr || !(queue->properties_ & PI_QUEUE_PROFILING_ENABLE)) { - return PI_PROFILING_INFO_NOT_AVAILABLE; + return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } switch (param_name) { @@ -3510,7 +3509,7 @@ pi_result hip_piEventSetStatus(pi_event event, pi_int32 execution_status) { (void)execution_status; cl::sycl::detail::pi::die("Event Set Status not implemented in HIP backend"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result hip_piEventRetain(pi_event event) { @@ -3536,12 +3535,12 @@ pi_result hip_piEventRelease(pi_event event) { // decrement ref count. If it is 0, delete the event. if (event->decrement_reference_count() == 0) { std::unique_ptr<_pi_event> event_ptr{event}; - pi_result result = PI_INVALID_EVENT; + pi_result result = PI_ERROR_INVALID_EVENT; try { ScopedContext active(event->get_context()); result = event->release(); } catch (...) { - result = PI_OUT_OF_RESOURCES; + result = PI_ERROR_OUT_OF_RESOURCES; } return result; } @@ -3574,7 +3573,7 @@ pi_result hip_piEnqueueEventsWaitWithBarrier(pi_queue command_queue, const pi_event *event_wait_list, pi_event *event) { if (!command_queue) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } try { @@ -3611,7 +3610,7 @@ pi_result hip_piEnqueueEventsWaitWithBarrier(pi_queue command_queue, /// \param[in] event The PI event to get the native HIP object of. /// \param[out] nativeHandle Set to the native handle of the PI event object. /// -/// \return PI_SUCCESS on success. PI_INVALID_EVENT if given a user event. +/// \return PI_SUCCESS on success. PI_ERROR_INVALID_EVENT if given a user event. pi_result hip_piextEventGetNativeHandle(pi_event event, pi_native_handle *nativeHandle) { *nativeHandle = reinterpret_cast(event->get()); @@ -3646,7 +3645,8 @@ pi_result hip_piextEventCreateWithNativeHandle(pi_native_handle nativeHandle, /// \param[in] sampler_properties The properties for the sampler. /// \param[out] result_sampler Set to the resulting sampler object. /// -/// \return PI_SUCCESS on success. PI_INVALID_VALUE if given an invalid property +/// \return PI_SUCCESS on success. PI_ERROR_INVALID_VALUE if given an invalid +/// property /// or if there is multiple of properties from the same category. pi_result hip_piSamplerCreate(pi_context context, const pi_sampler_properties *sampler_properties, @@ -3658,14 +3658,14 @@ pi_result hip_piSamplerCreate(pi_context context, switch (sampler_properties[i]) { case PI_SAMPLER_PROPERTIES_NORMALIZED_COORDS: if (propSeen[0]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[0] = true; retImplSampl->props_ |= sampler_properties[i + 1]; break; case PI_SAMPLER_PROPERTIES_FILTER_MODE: if (propSeen[1]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[1] = true; retImplSampl->props_ |= @@ -3673,23 +3673,25 @@ pi_result hip_piSamplerCreate(pi_context context, break; case PI_SAMPLER_PROPERTIES_ADDRESSING_MODE: if (propSeen[2]) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } propSeen[2] = true; retImplSampl->props_ |= (sampler_properties[i + 1] - PI_SAMPLER_ADDRESSING_MODE_NONE) << 2; break; default: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } if (!propSeen[0]) { - retImplSampl->props_ |= CL_TRUE; + retImplSampl->props_ |= PI_TRUE; } // Default filter mode to CL_FILTER_NEAREST if (!propSeen[2]) { - retImplSampl->props_ |= (CL_ADDRESS_CLAMP % CL_ADDRESS_NONE) << 2; + retImplSampl->props_ |= + (PI_SAMPLER_ADDRESSING_MODE_CLAMP % PI_SAMPLER_ADDRESSING_MODE_NONE) + << 2; } *result_sampler = retImplSampl.release(); @@ -3705,7 +3707,7 @@ pi_result hip_piSamplerCreate(pi_context context, /// \param[out] param_value_size_ret Set to the size of the information value. /// /// \return PI_SUCCESS on success. -pi_result hip_piSamplerGetInfo(pi_sampler sampler, cl_sampler_info param_name, +pi_result hip_piSamplerGetInfo(pi_sampler sampler, pi_sampler_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { assert(sampler != nullptr); @@ -3943,7 +3945,7 @@ pi_result hip_piEnqueueMemBufferCopy(pi_queue command_queue, pi_mem src_buffer, const pi_event *event_wait_list, pi_event *event) { if (!command_queue) { - return PI_INVALID_QUEUE; + return PI_ERROR_INVALID_QUEUE; } std::unique_ptr<_pi_event> retImplEv{nullptr}; @@ -4233,7 +4235,7 @@ static pi_result commonEnqueueMemImageNDCopy( return PI_ERROR_UNKNOWN; } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } pi_result hip_piEnqueueMemImageRead(pi_queue command_queue, pi_mem image, @@ -4444,7 +4446,7 @@ pi_result hip_piEnqueueMemImageCopy(pi_queue command_queue, pi_mem src_image, return retErr; } -/// \TODO Not implemented in HIP, requires untie from OpenCL +/// \TODO Not implemented in HIP. pi_result hip_piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, const void *fill_color, const size_t *origin, const size_t *region, @@ -4468,7 +4470,6 @@ pi_result hip_piEnqueueMemImageFill(pi_queue command_queue, pi_mem image, /// Mapped pointers are stored in the pi_mem object. /// If the buffer uses pinned host memory a pointer to that memory is returned /// and no read operation is done. -/// \TODO Untie types from OpenCL /// pi_result hip_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, pi_bool blocking_map, @@ -4482,7 +4483,7 @@ pi_result hip_piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, assert(buffer != nullptr); assert(buffer->mem_type_ == _pi_mem::mem_type::buffer); - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; const bool is_pinned = buffer->mem_.buffer_mem_.allocMode_ == _pi_mem::mem_::buffer_mem_::alloc_mode::alloc_host_ptr; @@ -4762,7 +4763,7 @@ pi_result hip_piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, // flags is currently unused so fail if set if (flags != 0) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; assert(queue != nullptr); assert(ptr != nullptr); hipStream_t hipStream = queue->get(); @@ -4873,10 +4874,10 @@ pi_result hip_piextUSMGetMemAllocInfo(pi_context context, const void *ptr, PI_MEM_TYPE_UNKNOWN); } case PI_MEM_ALLOC_BASE_PTR: { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } case PI_MEM_ALLOC_SIZE: { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } case PI_MEM_ALLOC_DEVICE: { @@ -4919,13 +4920,13 @@ pi_result piPluginInit(pi_plugin *PluginInit) { if (CompareVersions < 0) { // PI interface supports lower version of PI. // TODO: Take appropriate actions. - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } // PI interface supports higher version or the same version. size_t PluginVersionSize = sizeof(PluginInit->PluginVersion); if (strlen(SupportedVersion) >= PluginVersionSize) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; strncpy(PluginInit->PluginVersion, SupportedVersion, PluginVersionSize); // Set whole function table to zero to make it easier to detect if diff --git a/sycl/plugins/level_zero/pi_level_zero.cpp b/sycl/plugins/level_zero/pi_level_zero.cpp index 5f247be544faf..d118517b5d281 100644 --- a/sycl/plugins/level_zero/pi_level_zero.cpp +++ b/sycl/plugins/level_zero/pi_level_zero.cpp @@ -128,28 +128,28 @@ static pi_result mapError(ze_result_t ZeResult) { // values, which is TBD. static std::unordered_map ErrorMapping = { {ZE_RESULT_SUCCESS, PI_SUCCESS}, - {ZE_RESULT_ERROR_DEVICE_LOST, PI_DEVICE_NOT_FOUND}, - {ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, PI_INVALID_OPERATION}, - {ZE_RESULT_ERROR_NOT_AVAILABLE, PI_INVALID_OPERATION}, - {ZE_RESULT_ERROR_UNINITIALIZED, PI_INVALID_PLATFORM}, - {ZE_RESULT_ERROR_INVALID_ARGUMENT, PI_INVALID_ARG_VALUE}, - {ZE_RESULT_ERROR_INVALID_NULL_POINTER, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_INVALID_SIZE, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_UNSUPPORTED_SIZE, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT, PI_INVALID_EVENT}, - {ZE_RESULT_ERROR_INVALID_ENUMERATION, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT, PI_INVALID_VALUE}, - {ZE_RESULT_ERROR_INVALID_NATIVE_BINARY, PI_INVALID_BINARY}, - {ZE_RESULT_ERROR_INVALID_KERNEL_NAME, PI_INVALID_KERNEL_NAME}, - {ZE_RESULT_ERROR_INVALID_FUNCTION_NAME, PI_BUILD_PROGRAM_FAILURE}, - {ZE_RESULT_ERROR_OVERLAPPING_REGIONS, PI_INVALID_OPERATION}, + {ZE_RESULT_ERROR_DEVICE_LOST, PI_ERROR_DEVICE_NOT_FOUND}, + {ZE_RESULT_ERROR_INSUFFICIENT_PERMISSIONS, PI_ERROR_INVALID_OPERATION}, + {ZE_RESULT_ERROR_NOT_AVAILABLE, PI_ERROR_INVALID_OPERATION}, + {ZE_RESULT_ERROR_UNINITIALIZED, PI_ERROR_INVALID_PLATFORM}, + {ZE_RESULT_ERROR_INVALID_ARGUMENT, PI_ERROR_INVALID_ARG_VALUE}, + {ZE_RESULT_ERROR_INVALID_NULL_POINTER, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_INVALID_SIZE, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_UNSUPPORTED_SIZE, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_UNSUPPORTED_ALIGNMENT, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_INVALID_SYNCHRONIZATION_OBJECT, PI_ERROR_INVALID_EVENT}, + {ZE_RESULT_ERROR_INVALID_ENUMERATION, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_UNSUPPORTED_ENUMERATION, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_UNSUPPORTED_IMAGE_FORMAT, PI_ERROR_INVALID_VALUE}, + {ZE_RESULT_ERROR_INVALID_NATIVE_BINARY, PI_ERROR_INVALID_BINARY}, + {ZE_RESULT_ERROR_INVALID_KERNEL_NAME, PI_ERROR_INVALID_KERNEL_NAME}, + {ZE_RESULT_ERROR_INVALID_FUNCTION_NAME, PI_ERROR_BUILD_PROGRAM_FAILURE}, + {ZE_RESULT_ERROR_OVERLAPPING_REGIONS, PI_ERROR_INVALID_OPERATION}, {ZE_RESULT_ERROR_INVALID_GROUP_SIZE_DIMENSION, - PI_INVALID_WORK_GROUP_SIZE}, - {ZE_RESULT_ERROR_MODULE_BUILD_FAILURE, PI_BUILD_PROGRAM_FAILURE}, - {ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, PI_OUT_OF_RESOURCES}, - {ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, PI_OUT_OF_HOST_MEMORY}}; + PI_ERROR_INVALID_WORK_GROUP_SIZE}, + {ZE_RESULT_ERROR_MODULE_BUILD_FAILURE, PI_ERROR_BUILD_PROGRAM_FAILURE}, + {ZE_RESULT_ERROR_OUT_OF_DEVICE_MEMORY, PI_ERROR_OUT_OF_RESOURCES}, + {ZE_RESULT_ERROR_OUT_OF_HOST_MEMORY, PI_ERROR_OUT_OF_HOST_MEMORY}}; auto It = ErrorMapping.find(ZeResult); if (It == ErrorMapping.end()) { @@ -284,7 +284,7 @@ pi_result getInfoImpl(size_t param_value_size, void *param_value, if (param_value != nullptr) { if (param_value_size < value_size) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } assign_func(param_value, value, value_size); @@ -586,7 +586,7 @@ inline void zeParseError(ze_result_t ZeError, const char *&ErrorString) { } // switch } -// Global variables for PI_PLUGIN_SPECIFIC_ERROR +// Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR constexpr size_t MaxMessageSize = 256; thread_local pi_result ErrorMessageCode = PI_SUCCESS; thread_local char ErrorMessage[MaxMessageSize]; @@ -1194,7 +1194,7 @@ _pi_context::getAvailableCommandList(pi_queue Queue, // the command lists, and later are then added to the command queue. // Each command list is paired with an associated fence to track when the // command list is available for reuse. - _pi_result pi_result = PI_OUT_OF_RESOURCES; + _pi_result pi_result = PI_ERROR_OUT_OF_RESOURCES; ZeStruct ZeFenceDesc; // Initally, we need to check if a command list has already been created // on this device that is available for use. If so, then reuse that @@ -1490,7 +1490,7 @@ pi_result _pi_queue::executeCommandList(pi_command_list_ptr_t CommandList, this->Healthy = false; if (ZeResult == ZE_RESULT_ERROR_UNKNOWN) { // Turn into a more informative end-user error. - return PI_COMMAND_EXECUTION_FAILURE; + return PI_ERROR_COMMAND_EXECUTION_FAILURE; } return mapError(ZeResult); } @@ -1697,7 +1697,7 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList( if (EventListLength > 0) { for (pi_uint32 I = 0; I < EventListLength; I++) { - PI_ASSERT(EventList[I] != nullptr, PI_INVALID_VALUE); + PI_ASSERT(EventList[I] != nullptr, PI_ERROR_INVALID_VALUE); { std::shared_lock Lock(EventList[I]->Mutex); if (EventList[I]->Completed) @@ -1798,7 +1798,7 @@ pi_result _pi_ze_event_list_t::createAndRetainPiZeEventList( this->Length = TmpListLength; } catch (...) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } for (pi_uint32 I = 0; I < this->Length; I++) { @@ -2003,16 +2003,16 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, } }); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } if (NumEntries == 0 && Platforms != nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (Platforms == nullptr && NumPlatforms == nullptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // Setting these environment variables before running zeInit will enable the @@ -2038,7 +2038,7 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, // Absorb the ZE_RESULT_ERROR_UNINITIALIZED and just return 0 Platforms. if (ZeResult == ZE_RESULT_ERROR_UNINITIALIZED) { - PI_ASSERT(NumPlatforms != 0, PI_INVALID_VALUE); + PI_ASSERT(NumPlatforms != 0, PI_ERROR_INVALID_VALUE); *NumPlatforms = 0; return PI_SUCCESS; } @@ -2080,7 +2080,7 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, PiPlatformCachePopulated = true; } } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -2088,7 +2088,8 @@ pi_result piPlatformsGet(pi_uint32 NumEntries, pi_platform *Platforms, // Populate returned platforms from the cache. if (Platforms) { - PI_ASSERT(NumEntries <= PiPlatformsCache->size(), PI_INVALID_PLATFORM); + PI_ASSERT(NumEntries <= PiPlatformsCache->size(), + PI_ERROR_INVALID_PLATFORM); std::copy_n(PiPlatformsCache->begin(), NumEntries, Platforms); } @@ -2108,7 +2109,7 @@ pi_result piPlatformGetInfo(pi_platform Platform, pi_platform_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Platform, PI_INVALID_PLATFORM); + PI_ASSERT(Platform, PI_ERROR_INVALID_PLATFORM); zePrint("==========================\n"); zePrint("SYCL over Level-Zero %s\n", Platform->ZeDriverVersion.c_str()); @@ -2148,7 +2149,7 @@ pi_result piPlatformGetInfo(pi_platform Platform, pi_platform_info ParamName, return ReturnValue(Platform->ZeDriverApiVersion.c_str()); default: zePrint("piPlatformGetInfo: unrecognized ParamName\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -2156,8 +2157,8 @@ pi_result piPlatformGetInfo(pi_platform Platform, pi_platform_info ParamName, pi_result piextPlatformGetNativeHandle(pi_platform Platform, pi_native_handle *NativeHandle) { - PI_ASSERT(Platform, PI_INVALID_PLATFORM); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Platform, PI_ERROR_INVALID_PLATFORM); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeDriver = pi_cast(NativeHandle); // Extract the Level Zero driver handle from the given PI platform @@ -2167,8 +2168,8 @@ pi_result piextPlatformGetNativeHandle(pi_platform Platform, pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle, pi_platform *Platform) { - PI_ASSERT(Platform, PI_INVALID_PLATFORM); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Platform, PI_ERROR_INVALID_PLATFORM); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeDriver = pi_cast(NativeHandle); @@ -2195,7 +2196,7 @@ pi_result piextPlatformCreateWithNativeHandle(pi_native_handle NativeHandle, } } - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // Get the cached PI device created for the L0 device handle. @@ -2228,7 +2229,7 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType, pi_uint32 NumEntries, pi_device *Devices, pi_uint32 *NumDevices) { - PI_ASSERT(Platform, PI_INVALID_PLATFORM); + PI_ASSERT(Platform, PI_ERROR_INVALID_PLATFORM); pi_result Res = Platform->populateDeviceCacheIfNeeded(); if (Res != PI_SUCCESS) { @@ -2275,13 +2276,13 @@ pi_result piDevicesGet(pi_platform Platform, pi_device_type DeviceType, if (NumEntries == 0) { // Devices should be nullptr when querying the number of devices. - PI_ASSERT(Devices == nullptr, PI_INVALID_VALUE); + PI_ASSERT(Devices == nullptr, PI_ERROR_INVALID_VALUE); return PI_SUCCESS; } // Return the devices from the cache. if (Devices) { - PI_ASSERT(NumEntries <= ZeDeviceCount, PI_INVALID_DEVICE); + PI_ASSERT(NumEntries <= ZeDeviceCount, PI_ERROR_INVALID_DEVICE); std::copy_n(MatchedDevices.begin(), NumEntries, Devices); } @@ -2390,7 +2391,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() { PiDevicesCache.push_back(std::move(Device)); } } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -2399,7 +2400,7 @@ pi_result _pi_platform::populateDeviceCacheIfNeeded() { } pi_result piDeviceRetain(pi_device Device) { - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); // The root-device ref-count remains unchanged (always 1). if (Device->isSubDevice()) { @@ -2409,7 +2410,7 @@ pi_result piDeviceRetain(pi_device Device) { } pi_result piDeviceRelease(pi_device Device) { - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); // Root devices are destroyed during the piTearDown process. if (Device->isSubDevice()) { @@ -2425,7 +2426,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); ze_device_handle_t ZeDevice = Device->ZeDevice; @@ -2443,7 +2444,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, return ReturnValue(PI_DEVICE_TYPE_ACC); default: zePrint("This device type is not supported\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } case PI_DEVICE_INFO_PARENT_DEVICE: @@ -2899,7 +2900,7 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, case PI_DEVICE_INFO_PCI_ADDRESS: { if (getenv("ZES_ENABLE_SYSMAN") == nullptr) { zePrint("Set SYCL_ENABLE_PCI=1 to obtain PCI data.\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } ZesStruct ZeDevicePciProperties; ZE_CALL(zesDevicePciGetProperties, (ZeDevice, &ZeDevicePciProperties)); @@ -2933,14 +2934,14 @@ pi_result piDeviceGetInfo(pi_device Device, pi_device_info ParamName, return ReturnValue(pi_uint32{Device->ZeDeviceProperties->numThreadsPerEU}); case PI_DEVICE_INFO_MAX_MEM_BANDWIDTH: // currently not supported in level zero runtime - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; // TODO: Implement. case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: default: zePrint("Unsupported ParamName in piGetDeviceInfo\n"); zePrint("ParamName=%d(0x%x)\n", ParamName, ParamName); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -2954,10 +2955,10 @@ pi_result piDevicePartition(pi_device Device, if (Properties[0] != PI_DEVICE_PARTITION_BY_AFFINITY_DOMAIN || (Properties[1] != PI_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE && Properties[1] != PI_DEVICE_AFFINITY_DOMAIN_NUMA)) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); // Devices cache is normally created in piDevicesGet but still make // sure that cache is populated. @@ -2976,7 +2977,7 @@ pi_result piDevicePartition(pi_device Device, // Currently supported partitioning (by affinity domain/numa) would always // partition to all sub-devices. // - PI_ASSERT(NumDevices == Device->SubDevices.size(), PI_INVALID_VALUE); + PI_ASSERT(NumDevices == Device->SubDevices.size(), PI_ERROR_INVALID_VALUE); for (uint32_t I = 0; I < NumDevices; I++) { OutDevices[I] = Device->SubDevices[I]; @@ -2992,9 +2993,9 @@ piextDeviceSelectBinary(pi_device Device, // TODO: does this need to be context? pi_device_binary *Binaries, pi_uint32 NumBinaries, pi_uint32 *SelectedBinaryInd) { - PI_ASSERT(Device, PI_INVALID_DEVICE); - PI_ASSERT(SelectedBinaryInd, PI_INVALID_VALUE); - PI_ASSERT(NumBinaries == 0 || Binaries, PI_INVALID_VALUE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); + PI_ASSERT(SelectedBinaryInd, PI_ERROR_INVALID_VALUE); + PI_ASSERT(NumBinaries == 0 || Binaries, PI_ERROR_INVALID_VALUE); // TODO: this is a bare-bones implementation for choosing a device image // that would be compatible with the targeted device. An AOT-compiled @@ -3004,7 +3005,7 @@ piextDeviceSelectBinary(pi_device Device, // TODO: does this need to be context? // // Real implementation will use the same mechanism OpenCL ICD dispatcher // uses. Something like: - // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_INVALID_CONTEXT); + // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_ERROR_INVALID_CONTEXT); // return context->dispatch->piextDeviceSelectIR( // ctx, images, num_images, selected_image); // where context->dispatch is set to the dispatch table provided by PI @@ -3031,13 +3032,13 @@ piextDeviceSelectBinary(pi_device Device, // TODO: does this need to be context? return PI_SUCCESS; // No image can be loaded for the given device - return PI_INVALID_BINARY; + return PI_ERROR_INVALID_BINARY; } pi_result piextDeviceGetNativeHandle(pi_device Device, pi_native_handle *NativeHandle) { - PI_ASSERT(Device, PI_INVALID_DEVICE); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeDevice = pi_cast(NativeHandle); // Extract the Level Zero module handle from the given PI device @@ -3048,8 +3049,8 @@ pi_result piextDeviceGetNativeHandle(pi_device Device, pi_result piextDeviceCreateWithNativeHandle(pi_native_handle NativeHandle, pi_platform Platform, pi_device *Device) { - PI_ASSERT(Device, PI_INVALID_DEVICE); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeDevice = pi_cast(NativeHandle); @@ -3061,7 +3062,7 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle NativeHandle, // // TODO: maybe we should populate cache of platforms if it wasn't already. // For now assert that is was populated. - PI_ASSERT(PiPlatformCachePopulated, PI_INVALID_VALUE); + PI_ASSERT(PiPlatformCachePopulated, PI_ERROR_INVALID_VALUE); const std::lock_guard Lock{*PiPlatformsCacheMutex}; pi_device Dev = nullptr; @@ -3069,13 +3070,14 @@ pi_result piextDeviceCreateWithNativeHandle(pi_native_handle NativeHandle, Dev = ThePlatform->getDeviceFromNativeHandle(ZeDevice); if (Dev) { // Check that the input Platform, if was given, matches the found one. - PI_ASSERT(!Platform || Platform == ThePlatform, PI_INVALID_PLATFORM); + PI_ASSERT(!Platform || Platform == ThePlatform, + PI_ERROR_INVALID_PLATFORM); break; } } if (Dev == nullptr) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; *Device = Dev; return PI_SUCCESS; @@ -3090,9 +3092,9 @@ pi_result piContextCreate(const pi_context_properties *Properties, (void)Properties; (void)PFnNotify; (void)UserData; - PI_ASSERT(NumDevices, PI_INVALID_VALUE); - PI_ASSERT(Devices, PI_INVALID_DEVICE); - PI_ASSERT(RetContext, PI_INVALID_VALUE); + PI_ASSERT(NumDevices, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Devices, PI_ERROR_INVALID_DEVICE); + PI_ASSERT(RetContext, PI_ERROR_INVALID_VALUE); pi_platform Platform = (*Devices)->Platform; ZeStruct ContextDesc; @@ -3108,7 +3110,7 @@ pi_result piContextCreate(const pi_context_properties *Properties, Platform->Contexts.push_back(*RetContext); } } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -3120,7 +3122,7 @@ pi_result piContextGetInfo(pi_context Context, pi_context_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); switch (ParamName) { @@ -3153,8 +3155,8 @@ pi_result piextContextSetExtendedDeleter(pi_context Context, pi_result piextContextGetNativeHandle(pi_context Context, pi_native_handle *NativeHandle) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeContext = pi_cast(NativeHandle); // Extract the Level Zero queue handle from the given PI queue @@ -3167,17 +3169,17 @@ pi_result piextContextCreateWithNativeHandle(pi_native_handle NativeHandle, const pi_device *Devices, bool OwnNativeHandle, pi_context *RetContext) { - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); - PI_ASSERT(Devices, PI_INVALID_DEVICE); - PI_ASSERT(RetContext, PI_INVALID_VALUE); - PI_ASSERT(NumDevices, PI_INVALID_VALUE); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Devices, PI_ERROR_INVALID_DEVICE); + PI_ASSERT(RetContext, PI_ERROR_INVALID_VALUE); + PI_ASSERT(NumDevices, PI_ERROR_INVALID_VALUE); try { *RetContext = new _pi_context(pi_cast(NativeHandle), NumDevices, Devices, OwnNativeHandle); (*RetContext)->initialize(); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -3187,7 +3189,7 @@ pi_result piextContextCreateWithNativeHandle(pi_native_handle NativeHandle, pi_result piContextRetain(pi_context Context) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); Context->RefCount.increment(); return PI_SUCCESS; @@ -3198,7 +3200,7 @@ pi_result piContextRetain(pi_context Context) { // from the list of tracked contexts. pi_result ContextReleaseHelper(pi_context Context) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); if (!Context->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -3248,15 +3250,15 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, PI_ASSERT(!(Properties & ~(PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE | PI_QUEUE_PROFILING_ENABLE | PI_QUEUE_ON_DEVICE | PI_QUEUE_ON_DEVICE_DEFAULT)), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); if (std::find(Context->Devices.begin(), Context->Devices.end(), Device) == Context->Devices.end()) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } // Create placeholder queues in the compute queue group. @@ -3284,7 +3286,7 @@ pi_result piQueueCreate(pi_context Context, pi_device Device, *Queue = new _pi_queue(ZeComputeCommandQueues, ZeCopyCommandQueues, Context, Device, true, Properties); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -3295,7 +3297,7 @@ pi_result piQueueGetInfo(pi_queue Queue, pi_queue_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); // TODO: consider support for queue properties and size @@ -3318,7 +3320,7 @@ pi_result piQueueGetInfo(pi_queue Queue, pi_queue_info ParamName, default: zePrint("Unsupported ParamName in piQueueGetInfo: ParamName=%d(0x%x)\n", ParamName, ParamName); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -3334,7 +3336,7 @@ pi_result piQueueRetain(pi_queue Queue) { } pi_result piQueueRelease(pi_queue Queue) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::vector EventListToCleanup; { @@ -3394,7 +3396,7 @@ pi_result piQueueRelease(pi_queue Queue) { } static pi_result piQueueReleaseInternal(pi_queue Queue) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); if (!Queue->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -3426,7 +3428,7 @@ static pi_result piQueueReleaseInternal(pi_queue Queue) { pi_result piQueueFinish(pi_queue Queue) { // Wait until command lists attached to the command queue are executed. - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); if (UseImmediateCommandLists) { // Lock automatically releases when this goes out of scope. @@ -3494,8 +3496,8 @@ pi_result piQueueFlush(pi_queue Queue) { pi_result piextQueueGetNativeHandle(pi_queue Queue, pi_native_handle *NativeHandle) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); // Lock automatically releases when this goes out of scope. std::scoped_lock lock(Queue->Mutex); @@ -3510,9 +3512,9 @@ pi_result piextQueueCreateWithNativeHandle(pi_native_handle NativeHandle, pi_context Context, pi_device Device, bool OwnNativeHandle, pi_queue *Queue) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); auto ZeQueue = pi_cast(NativeHandle); // Assume this is the "0" index queue in the compute command-group. @@ -3612,8 +3614,8 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, "but not other accesses (such as write-only) yet."); } - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(RetMem, PI_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(RetMem, PI_ERROR_INVALID_VALUE); if (properties != nullptr) { die("piMemBufferCreate: no mem properties goes to Level-Zero RT yet"); @@ -3658,7 +3660,7 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, try { Buffer = new _pi_buffer(Context, Size, HostPtrOrNull, HostPtrImported); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -3694,9 +3696,9 @@ pi_result piMemBufferCreate(pi_context Context, pi_mem_flags Flags, size_t Size, pi_result piMemGetInfo(pi_mem Mem, pi_mem_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Mem, PI_INVALID_VALUE); + PI_ASSERT(Mem, PI_ERROR_INVALID_VALUE); // piMemImageGetInfo must be used for images - PI_ASSERT(!Mem->isImage(), PI_INVALID_VALUE); + PI_ASSERT(!Mem->isImage(), PI_ERROR_INVALID_VALUE); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); @@ -3716,7 +3718,7 @@ pi_result piMemGetInfo(pi_mem Mem, pi_mem_info ParamName, size_t ParamValueSize, } pi_result piMemRetain(pi_mem Mem) { - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); Mem->RefCount.increment(); return PI_SUCCESS; @@ -3759,7 +3761,7 @@ static pi_result USMFreeHelper(pi_context Context, void *Ptr, bool OwnZeMemHandle); pi_result piMemRelease(pi_mem Mem) { - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); if (!Mem->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -3787,71 +3789,71 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, die("piMemImageCreate: Level-Zero implements only read-write buffer," "no read-only or write-only yet."); } - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(RetImage, PI_INVALID_VALUE); - PI_ASSERT(ImageFormat, PI_INVALID_IMAGE_FORMAT_DESCRIPTOR); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(RetImage, PI_ERROR_INVALID_VALUE); + PI_ASSERT(ImageFormat, PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR); ze_image_format_type_t ZeImageFormatType; size_t ZeImageFormatTypeSize; switch (ImageFormat->image_channel_data_type) { - case CL_FLOAT: + case PI_IMAGE_CHANNEL_TYPE_FLOAT: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_FLOAT; ZeImageFormatTypeSize = 32; break; - case CL_HALF_FLOAT: + case PI_IMAGE_CHANNEL_TYPE_HALF_FLOAT: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_FLOAT; ZeImageFormatTypeSize = 16; break; - case CL_UNSIGNED_INT32: + case PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT32: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_UINT; ZeImageFormatTypeSize = 32; break; - case CL_UNSIGNED_INT16: + case PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT16: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_UINT; ZeImageFormatTypeSize = 16; break; - case CL_UNSIGNED_INT8: + case PI_IMAGE_CHANNEL_TYPE_UNSIGNED_INT8: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_UINT; ZeImageFormatTypeSize = 8; break; - case CL_UNORM_INT16: + case PI_IMAGE_CHANNEL_TYPE_UNORM_INT16: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_UNORM; ZeImageFormatTypeSize = 16; break; - case CL_UNORM_INT8: + case PI_IMAGE_CHANNEL_TYPE_UNORM_INT8: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_UNORM; ZeImageFormatTypeSize = 8; break; - case CL_SIGNED_INT32: + case PI_IMAGE_CHANNEL_TYPE_SIGNED_INT32: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_SINT; ZeImageFormatTypeSize = 32; break; - case CL_SIGNED_INT16: + case PI_IMAGE_CHANNEL_TYPE_SIGNED_INT16: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_SINT; ZeImageFormatTypeSize = 16; break; - case CL_SIGNED_INT8: + case PI_IMAGE_CHANNEL_TYPE_SIGNED_INT8: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_SINT; ZeImageFormatTypeSize = 8; break; - case CL_SNORM_INT16: + case PI_IMAGE_CHANNEL_TYPE_SNORM_INT16: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_SNORM; ZeImageFormatTypeSize = 16; break; - case CL_SNORM_INT8: + case PI_IMAGE_CHANNEL_TYPE_SNORM_INT8: ZeImageFormatType = ZE_IMAGE_FORMAT_TYPE_SNORM; ZeImageFormatTypeSize = 8; break; default: zePrint("piMemImageCreate: unsupported image data type: data type = %d\n", ImageFormat->image_channel_data_type); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // TODO: populate the layout mapping ze_image_format_layout_t ZeImageFormatLayout; switch (ImageFormat->image_channel_order) { - case CL_RGBA: + case PI_IMAGE_CHANNEL_ORDER_RGBA: switch (ZeImageFormatTypeSize) { case 8: ZeImageFormatLayout = ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8; @@ -3864,7 +3866,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, break; default: zePrint("piMemImageCreate: unexpected data type Size\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } break; default: @@ -3898,7 +3900,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, break; default: zePrint("piMemImageCreate: unsupported image type\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } ZeStruct ZeImageDesc; @@ -3938,7 +3940,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, *RetImage = ZePIImage; } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -3946,7 +3948,7 @@ pi_result piMemImageCreate(pi_context Context, pi_mem_flags Flags, } pi_result piextMemGetNativeHandle(pi_mem Mem, pi_native_handle *NativeHandle) { - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); std::shared_lock Guard(Mem->Mutex); char *ZeHandle; PI_CALL(Mem->getZeHandle(ZeHandle, _pi_mem::read_write)); @@ -3957,16 +3959,16 @@ pi_result piextMemGetNativeHandle(pi_mem Mem, pi_native_handle *NativeHandle) { pi_result piextMemCreateWithNativeHandle(pi_native_handle NativeHandle, pi_context Context, bool ownNativeHandle, pi_mem *Mem) { - PI_ASSERT(Mem, PI_INVALID_VALUE); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Mem, PI_ERROR_INVALID_VALUE); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); // Get base of the allocation void *Base; size_t Size; void *Ptr = pi_cast(NativeHandle); ZE_CALL(zeMemGetAddressRange, (Context->ZeContext, Ptr, &Base, &Size)); - PI_ASSERT(Ptr == Base, PI_INVALID_VALUE); + PI_ASSERT(Ptr == Base, PI_ERROR_INVALID_VALUE); ZeStruct ZeMemProps; ze_device_handle_t ZeDevice = nullptr; @@ -3981,7 +3983,7 @@ pi_result piextMemCreateWithNativeHandle(pi_native_handle NativeHandle, break; case ZE_MEMORY_TYPE_UNKNOWN: // Memory allocation is unrelated to the context - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; default: die("Unexpected memory type"); } @@ -3992,7 +3994,7 @@ pi_result piextMemCreateWithNativeHandle(pi_native_handle NativeHandle, // Check that the device is present in this context. if (std::find(Context->Devices.begin(), Context->Devices.end(), Device) == Context->Devices.end()) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } } @@ -4015,7 +4017,7 @@ pi_result piextMemCreateWithNativeHandle(pi_native_handle NativeHandle, std::forward_as_tuple(Context, ownNativeHandle)); } } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4045,9 +4047,9 @@ pi_result piextMemCreateWithNativeHandle(pi_native_handle NativeHandle, pi_result piProgramCreate(pi_context Context, const void *ILBytes, size_t Length, pi_program *Program) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(ILBytes && Length, PI_INVALID_VALUE); - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(ILBytes && Length, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); // NOTE: the Level Zero module creation is also building the program, so we // are deferring it until the program is ready to be built. @@ -4055,7 +4057,7 @@ pi_result piProgramCreate(pi_context Context, const void *ILBytes, try { *Program = new _pi_program(_pi_program::IL, Context, ILBytes, Length); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4070,20 +4072,20 @@ pi_result piProgramCreateWithBinary( (void)Metadata; (void)NumMetadataEntries; - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(DeviceList && NumDevices, PI_INVALID_VALUE); - PI_ASSERT(Binaries && Lengths, PI_INVALID_VALUE); - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(DeviceList && NumDevices, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Binaries && Lengths, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); // For now we support only one device. if (NumDevices != 1) { zePrint("piProgramCreateWithBinary: level_zero supports only one device."); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } if (!Binaries[0] || !Lengths[0]) { if (BinaryStatus) - *BinaryStatus = PI_INVALID_VALUE; - return PI_INVALID_VALUE; + *BinaryStatus = PI_ERROR_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } size_t Length = Lengths[0]; @@ -4103,7 +4105,7 @@ pi_result piProgramCreateWithBinary( try { *Program = new _pi_program(_pi_program::Native, Context, Binary, Length); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4124,14 +4126,14 @@ pi_result piclProgramCreateWithSource(pi_context Context, pi_uint32 Count, (void)Lengths; (void)RetProgram; zePrint("piclProgramCreateWithSource: not supported in Level Zero\n"); - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); switch (ParamName) { @@ -4153,7 +4155,7 @@ pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, } else if (Program->State == _pi_program::Exe) { ZE_CALL(zeModuleGetNativeBinary, (Program->ZeModule, &SzBinary, nullptr)); } else { - return PI_INVALID_PROGRAM; + return PI_ERROR_INVALID_PROGRAM; } // This is an array of 1 element, initialized as if it were scalar. return ReturnValue(size_t{SzBinary}); @@ -4177,7 +4179,7 @@ pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, ZE_CALL(zeModuleGetNativeBinary, (Program->ZeModule, &SzBinary, PBinary[0])); } else { - return PI_INVALID_PROGRAM; + return PI_ERROR_INVALID_PROGRAM; } break; } @@ -4187,13 +4189,13 @@ pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, if (Program->State == _pi_program::IL || Program->State == _pi_program::Native || Program->State == _pi_program::Object) { - return PI_INVALID_PROGRAM_EXECUTABLE; + return PI_ERROR_INVALID_PROGRAM_EXECUTABLE; } else if (Program->State == _pi_program::Exe) { NumKernels = 0; ZE_CALL(zeModuleGetKernelNames, (Program->ZeModule, &NumKernels, nullptr)); } else { - return PI_INVALID_PROGRAM; + return PI_ERROR_INVALID_PROGRAM; } return ReturnValue(size_t{NumKernels}); } @@ -4204,7 +4206,7 @@ pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, if (Program->State == _pi_program::IL || Program->State == _pi_program::Native || Program->State == _pi_program::Object) { - return PI_INVALID_PROGRAM_EXECUTABLE; + return PI_ERROR_INVALID_PROGRAM_EXECUTABLE; } else if (Program->State == _pi_program::Exe) { uint32_t Count = 0; ZE_CALL(zeModuleGetKernelNames, (Program->ZeModule, &Count, nullptr)); @@ -4216,11 +4218,11 @@ pi_result piProgramGetInfo(pi_program Program, pi_program_info ParamName, PINames += PNames[I]; } } else { - return PI_INVALID_PROGRAM; + return PI_ERROR_INVALID_PROGRAM; } return ReturnValue(PINames.c_str()); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4240,7 +4242,7 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, // We only support one device with Level Zero currently. if (NumDevices != 1) { zePrint("piProgramLink: level_zero supports only one device."); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // We do not support any link flags at this time because the Level Zero API @@ -4253,20 +4255,20 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, pi_program Program = new _pi_program(_pi_program::Invalid, Context, ErrorMessage); *RetProgram = Program; - return PI_LINK_PROGRAM_FAILURE; + return PI_ERROR_LINK_PROGRAM_FAILURE; } // Validate input parameters. - PI_ASSERT(DeviceList, PI_INVALID_DEVICE); + PI_ASSERT(DeviceList, PI_ERROR_INVALID_DEVICE); { auto DeviceEntry = find(Context->Devices.begin(), Context->Devices.end(), DeviceList[0]); if (DeviceEntry == Context->Devices.end()) - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } - PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE); + PI_ASSERT(!PFnNotify && !UserData, PI_ERROR_INVALID_VALUE); if (NumInputPrograms == 0 || InputPrograms == nullptr) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; pi_result PiResult = PI_SUCCESS; try { @@ -4286,7 +4288,7 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, std::shared_lock Guard(InputPrograms[I]->Mutex); Guards[I].swap(Guard); if (InputPrograms[I]->State != _pi_program::Object) { - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } } @@ -4357,7 +4359,7 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, } else { zePrint("piProgramLink: level_zero driver does not have static linking " "support."); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } @@ -4389,7 +4391,7 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, if (ZeResult == ZE_RESULT_SUCCESS) { ZeResult = checkUnresolvedSymbols(ZeModule, &ZeBuildLog); if (ZeResult == ZE_RESULT_ERROR_MODULE_LINK_FAILURE) { - PiResult = PI_LINK_PROGRAM_FAILURE; + PiResult = PI_ERROR_LINK_PROGRAM_FAILURE; } else if (ZeResult != ZE_RESULT_SUCCESS) { return mapError(ZeResult); } @@ -4399,7 +4401,7 @@ pi_result piProgramLink(pi_context Context, pi_uint32 NumDevices, (PiResult == PI_SUCCESS) ? _pi_program::Exe : _pi_program::Invalid; *RetProgram = new _pi_program(State, Context, ZeModule, ZeBuildLog); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4415,13 +4417,13 @@ pi_result piProgramCompile( (void)InputHeaders; (void)HeaderIncludeNames; - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); if ((NumDevices && !DeviceList) || (!NumDevices && DeviceList)) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; // These aren't supported. - PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE); + PI_ASSERT(!PFnNotify && !UserData, PI_ERROR_INVALID_VALUE); std::scoped_lock Guard(Program->Mutex); @@ -4431,7 +4433,7 @@ pi_result piProgramCompile( // The OpenCL spec says that the header parameters are ignored when compiling // IL programs, so we don't validate them. if (Program->State != _pi_program::IL) - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; // We don't compile anything now. Instead, we delay compilation until // piProgramLink, where we do both compilation and linking as a single step. @@ -4450,38 +4452,38 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices, void (*PFnNotify)(pi_program Program, void *UserData), void *UserData) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); if ((NumDevices && !DeviceList) || (!NumDevices && DeviceList)) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; // We only support build to one device with Level Zero now. // TODO: we should eventually build to the possibly multiple root // devices in the context. if (NumDevices != 1) { zePrint("piProgramBuild: level_zero supports only one device."); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // These aren't supported. - PI_ASSERT(!PFnNotify && !UserData, PI_INVALID_VALUE); + PI_ASSERT(!PFnNotify && !UserData, PI_ERROR_INVALID_VALUE); std::scoped_lock Guard(Program->Mutex); // Check if device belongs to associated context. - PI_ASSERT(Program->Context, PI_INVALID_PROGRAM); + PI_ASSERT(Program->Context, PI_ERROR_INVALID_PROGRAM); { auto DeviceEntry = find(Program->Context->Devices.begin(), Program->Context->Devices.end(), DeviceList[0]); if (DeviceEntry == Program->Context->Devices.end()) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // It is legal to build a program created from either IL or from native // device code. if (Program->State != _pi_program::IL && Program->State != _pi_program::Native) - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; // We should have either IL or native device code. - PI_ASSERT(Program->Code, PI_INVALID_PROGRAM); + PI_ASSERT(Program->Code, PI_ERROR_INVALID_PROGRAM); // Ask Level Zero to build and load the native code onto the device. ZeStruct ZeModuleDesc; @@ -4519,7 +4521,7 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices, if (ZeResult != ZE_RESULT_SUCCESS) { Program->State = _pi_program::Invalid; Result = (ZeResult == ZE_RESULT_ERROR_MODULE_LINK_FAILURE) - ? PI_BUILD_PROGRAM_FAILURE + ? PI_ERROR_BUILD_PROGRAM_FAILURE : mapError(ZeResult); } } @@ -4531,30 +4533,30 @@ pi_result piProgramBuild(pi_program Program, pi_uint32 NumDevices, } pi_result piProgramGetBuildInfo(pi_program Program, pi_device Device, - cl_program_build_info ParamName, + pi_program_build_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { (void)Device; std::shared_lock Guard(Program->Mutex); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); - if (ParamName == CL_PROGRAM_BINARY_TYPE) { - cl_program_binary_type Type = CL_PROGRAM_BINARY_TYPE_NONE; + if (ParamName == PI_PROGRAM_BUILD_INFO_BINARY_TYPE) { + pi_program_binary_type Type = PI_PROGRAM_BINARY_TYPE_NONE; if (Program->State == _pi_program::Object) { - Type = CL_PROGRAM_BINARY_TYPE_COMPILED_OBJECT; + Type = PI_PROGRAM_BINARY_TYPE_COMPILED_OBJECT; } else if (Program->State == _pi_program::Exe) { - Type = CL_PROGRAM_BINARY_TYPE_EXECUTABLE; + Type = PI_PROGRAM_BINARY_TYPE_EXECUTABLE; } - return ReturnValue(cl_program_binary_type{Type}); + return ReturnValue(pi_program_binary_type{Type}); } - if (ParamName == CL_PROGRAM_BUILD_OPTIONS) { + if (ParamName == PI_PROGRAM_BUILD_INFO_OPTIONS) { // TODO: how to get module build options out of Level Zero? // For the programs that we compiled we can remember the options // passed with piProgramCompile/piProgramBuild, but what can we // return for programs that were built outside and registered // with piProgramRegister? return ReturnValue(""); - } else if (ParamName == CL_PROGRAM_BUILD_LOG) { + } else if (ParamName == PI_PROGRAM_BUILD_INFO_LOG) { // Check first to see if the plugin code recorded an error message. if (!Program->ErrorMessage.empty()) { return ReturnValue(Program->ErrorMessage.c_str()); @@ -4577,19 +4579,19 @@ pi_result piProgramGetBuildInfo(pi_program Program, pi_device Device, return ReturnValue(""); } else { zePrint("piProgramGetBuildInfo: unsupported ParamName\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } pi_result piProgramRetain(pi_program Program) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); Program->RefCount.increment(); return PI_SUCCESS; } pi_result piProgramRelease(pi_program Program) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); if (!Program->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -4601,8 +4603,8 @@ pi_result piProgramRelease(pi_program Program) { pi_result piextProgramGetNativeHandle(pi_program Program, pi_native_handle *NativeHandle) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeModule = pi_cast(NativeHandle); @@ -4614,7 +4616,7 @@ pi_result piextProgramGetNativeHandle(pi_program Program, } default: - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } return PI_SUCCESS; @@ -4624,9 +4626,9 @@ pi_result piextProgramCreateWithNativeHandle(pi_native_handle NativeHandle, pi_context Context, bool ownNativeHandle, pi_program *Program) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); auto ZeModule = pi_cast(NativeHandle); @@ -4638,7 +4640,7 @@ pi_result piextProgramCreateWithNativeHandle(pi_native_handle NativeHandle, *Program = new _pi_program(_pi_program::Exe, Context, ZeModule, ownNativeHandle); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4695,13 +4697,13 @@ checkUnresolvedSymbols(ze_module_handle_t ZeModule, pi_result piKernelCreate(pi_program Program, const char *KernelName, pi_kernel *RetKernel) { - PI_ASSERT(Program, PI_INVALID_PROGRAM); - PI_ASSERT(RetKernel, PI_INVALID_VALUE); - PI_ASSERT(KernelName, PI_INVALID_VALUE); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); + PI_ASSERT(RetKernel, PI_ERROR_INVALID_VALUE); + PI_ASSERT(KernelName, PI_ERROR_INVALID_VALUE); std::shared_lock Guard(Program->Mutex); if (Program->State != _pi_program::Exe) { - return PI_INVALID_PROGRAM_EXECUTABLE; + return PI_ERROR_INVALID_PROGRAM_EXECUTABLE; } ZeStruct ZeKernelDesc; @@ -4714,7 +4716,7 @@ pi_result piKernelCreate(pi_program Program, const char *KernelName, try { *RetKernel = new _pi_kernel(ZeKernel, true, Program); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4763,7 +4765,7 @@ pi_result piKernelSetArg(pi_kernel Kernel, pi_uint32 ArgIndex, size_t ArgSize, ArgValue = nullptr; } - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); std::scoped_lock Guard(Kernel->Mutex); ZE_CALL(zeKernelSetArgumentValue, @@ -4782,7 +4784,7 @@ pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, // RT pass that directly to the regular piKernelSetArg (and // then remove this piextKernelSetArgMemObj). - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); // We don't yet know the device where this kernel will next be run on. // Thus we can't know the actual memory allocation that needs to be used. @@ -4803,7 +4805,7 @@ pi_result piextKernelSetArgMemObj(pi_kernel Kernel, pi_uint32 ArgIndex, // Special version of piKernelSetArg to accept pi_sampler. pi_result piextKernelSetArgSampler(pi_kernel Kernel, pi_uint32 ArgIndex, const pi_sampler *ArgValue) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); std::scoped_lock Guard(Kernel->Mutex); ZE_CALL(zeKernelSetArgumentValue, @@ -4817,7 +4819,7 @@ pi_result piextKernelSetArgSampler(pi_kernel Kernel, pi_uint32 ArgIndex, pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); @@ -4832,7 +4834,7 @@ pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName, std::string &KernelName = *Kernel->ZeKernelName.operator->(); return ReturnValue(static_cast(KernelName.c_str())); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -4851,14 +4853,14 @@ pi_result piKernelGetInfo(pi_kernel Kernel, pi_kernel_info ParamName, delete[] attributes; return Res; } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } default: zePrint("Unsupported ParamName in piKernelGetInfo: ParamName=%d(0x%x)\n", ParamName, ParamName); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -4868,8 +4870,8 @@ pi_result piKernelGetGroupInfo(pi_kernel Kernel, pi_device Device, pi_kernel_group_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); @@ -4913,7 +4915,7 @@ pi_result piKernelGetGroupInfo(pi_kernel Kernel, pi_device Device, default: zePrint("Unknown ParamName in piKernelGetGroupInfo: ParamName=%d(0x%x)\n", ParamName, ParamName); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } @@ -4947,14 +4949,14 @@ pi_result piKernelGetSubGroupInfo(pi_kernel Kernel, pi_device Device, pi_result piKernelRetain(pi_kernel Kernel) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); Kernel->RefCount.increment(); return PI_SUCCESS; } pi_result piKernelRelease(pi_kernel Kernel) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); if (IndirectAccessTrackingEnabled) { // piKernelRelease is called by CleanupCompletedEvent(Event) as soon as @@ -4999,17 +5001,17 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, const size_t *GlobalWorkSize, const size_t *LocalWorkSize, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); - PI_ASSERT((WorkDim > 0) && (WorkDim < 4), PI_INVALID_WORK_DIMENSION); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); + PI_ASSERT((WorkDim > 0) && (WorkDim < 4), PI_ERROR_INVALID_WORK_DIMENSION); // Lock automatically releases when this goes out of scope. std::scoped_lock Lock(Queue->Mutex, Kernel->Mutex, Kernel->Program->Mutex); if (GlobalWorkOffset != NULL) { if (!PiDriverGlobalOffsetExtensionFound) { zePrint("No global offset extension found on this driver\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } ZE_CALL(zeKernelSetGlobalOffsetExp, @@ -5031,8 +5033,8 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, uint32_t WG[3]; // global_work_size of unused dimensions must be set to 1 - PI_ASSERT(WorkDim == 3 || GlobalWorkSize[2] == 1, PI_INVALID_VALUE); - PI_ASSERT(WorkDim >= 2 || GlobalWorkSize[1] == 1, PI_INVALID_VALUE); + PI_ASSERT(WorkDim == 3 || GlobalWorkSize[2] == 1, PI_ERROR_INVALID_VALUE); + PI_ASSERT(WorkDim >= 2 || GlobalWorkSize[1] == 1, PI_ERROR_INVALID_VALUE); if (LocalWorkSize) { WG[0] = pi_cast(LocalWorkSize[0]); @@ -5069,24 +5071,24 @@ piEnqueueKernelLaunch(pi_queue Queue, pi_kernel Kernel, pi_uint32 WorkDim, default: zePrint("piEnqueueKernelLaunch: unsupported work_dim\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // Error handling for non-uniform group size case if (GlobalWorkSize[0] != (ZeThreadGroupDimensions.groupCountX * WG[0])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " "multiple of the group size in the 1st dimension\n"); - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[1] != (ZeThreadGroupDimensions.groupCountY * WG[1])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " "multiple of the group size in the 2nd dimension\n"); - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } if (GlobalWorkSize[2] != (ZeThreadGroupDimensions.groupCountZ * WG[2])) { zePrint("piEnqueueKernelLaunch: invalid work_dim. The range is not a " "multiple of the group size in the 3rd dimension\n"); - return PI_INVALID_WORK_GROUP_SIZE; + return PI_ERROR_INVALID_WORK_GROUP_SIZE; } ZE_CALL(zeKernelSetGroupSize, (Kernel->ZeKernel, WG[0], WG[1], WG[2])); @@ -5173,10 +5175,10 @@ pi_result piextKernelCreateWithNativeHandle(pi_native_handle NativeHandle, pi_program Program, bool OwnNativeHandle, pi_kernel *Kernel) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(Program, PI_INVALID_PROGRAM); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); - PI_ASSERT(Kernel, PI_INVALID_KERNEL); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); auto ZeKernel = pi_cast(NativeHandle); *Kernel = new _pi_kernel(ZeKernel, OwnNativeHandle, Program); @@ -5186,8 +5188,8 @@ pi_result piextKernelCreateWithNativeHandle(pi_native_handle NativeHandle, pi_result piextKernelGetNativeHandle(pi_kernel Kernel, pi_native_handle *NativeHandle) { - PI_ASSERT(Kernel, PI_INVALID_KERNEL); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); std::shared_lock Guard(Kernel->Mutex); auto *ZeKernel = pi_cast(NativeHandle); @@ -5200,7 +5202,7 @@ pi_result piextKernelGetNativeHandle(pi_kernel Kernel, // pi_result _pi_event::getOrCreateHostVisibleEvent(ze_event_handle_t &ZeHostVisibleEvent) { - PI_ASSERT(Queue, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_EVENT); std::scoped_lock Lock(Queue->Mutex, this->Mutex); @@ -5280,12 +5282,12 @@ static pi_result EventCreate(pi_context Context, pi_queue Queue, ZE_CALL(zeEventCreate, (ZeEventPool, &ZeEventDesc, &ZeEvent)); try { - PI_ASSERT(RetEvent, PI_INVALID_VALUE); + PI_ASSERT(RetEvent, PI_ERROR_INVALID_VALUE); *RetEvent = new _pi_event(ZeEvent, ZeEventPool, Context, PI_COMMAND_TYPE_USER, true); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -5305,7 +5307,7 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); ReturnHelper ReturnValue(ParamValueSize, ParamValue, ParamValueSizeRet); switch (ParamName) { @@ -5341,8 +5343,8 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName, // Level Zero has a much more explicit notion of command submission than // OpenCL. It doesn't happen unless the user submits a command list. We've - // done it just above so the status is at least CL_RUNNING. - pi_int32 Result = CL_RUNNING; + // done it just above so the status is at least PI_EVENT_RUNNING. + pi_int32 Result = PI_EVENT_RUNNING; // Make sure that we query a host-visible event only. // If one wasn't yet created then don't create it here as well, and @@ -5350,13 +5352,13 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName, std::shared_lock EventLock(Event->Mutex); auto HostVisibleEvent = Event->HostVisibleEvent; if (Event->Completed) { - Result = CL_COMPLETE; + Result = PI_EVENT_COMPLETE; } else if (HostVisibleEvent) { ze_result_t ZeResult; ZeResult = ZE_CALL_NOCHECK(zeEventQueryStatus, (HostVisibleEvent->ZeEvent)); if (ZeResult == ZE_RESULT_SUCCESS) { - Result = CL_COMPLETE; + Result = PI_EVENT_COMPLETE; } } return ReturnValue(pi_cast(Result)); @@ -5366,7 +5368,7 @@ pi_result piEventGetInfo(pi_event Event, pi_event_info ParamName, default: zePrint("Unsupported ParamName in piEventGetInfo: ParamName=%d(%x)\n", ParamName, ParamName); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -5376,12 +5378,12 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); std::shared_lock EventLock(Event->Mutex); if (Event->Queue && (Event->Queue->Properties & PI_QUEUE_PROFILING_ENABLE) == 0) { - return PI_PROFILING_INFO_NOT_AVAILABLE; + return PI_ERROR_PROFILING_INFO_NOT_AVAILABLE; } uint64_t ZeTimerResolution = @@ -5434,7 +5436,7 @@ pi_result piEventGetProfilingInfo(pi_event Event, pi_profiling_info ParamName, return ReturnValue(uint64_t{0}); default: zePrint("piEventGetProfilingInfo: not supported ParamName\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -5542,7 +5544,7 @@ extern "C" { pi_result piEventsWait(pi_uint32 NumEvents, const pi_event *EventList) { if (NumEvents && !EventList) { - return PI_INVALID_EVENT; + return PI_ERROR_INVALID_EVENT; } if (EventsScope == OnDemandHostVisibleProxy) { // Make sure to add all host-visible "proxy" event signals if needed. @@ -5622,7 +5624,7 @@ pi_result piEventRetain(pi_event Event) { } pi_result piEventRelease(pi_event Event) { - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); if (!Event->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -5663,8 +5665,8 @@ pi_result piEventRelease(pi_event Event) { pi_result piextEventGetNativeHandle(pi_event Event, pi_native_handle *NativeHandle) { - PI_ASSERT(Event, PI_INVALID_EVENT); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); { std::shared_lock Lock(Event->Mutex); @@ -5691,9 +5693,9 @@ pi_result piextEventCreateWithNativeHandle(pi_native_handle NativeHandle, pi_context Context, bool OwnNativeHandle, pi_event *Event) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(Event, PI_INVALID_EVENT); - PI_ASSERT(NativeHandle, PI_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); + PI_ASSERT(NativeHandle, PI_ERROR_INVALID_VALUE); auto ZeEvent = pi_cast(NativeHandle); *Event = new _pi_event(ZeEvent, nullptr /* ZeEventPool */, Context, @@ -5720,8 +5722,8 @@ pi_result piSamplerCreate(pi_context Context, const pi_sampler_properties *SamplerProperties, pi_sampler *RetSampler) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(RetSampler, PI_INVALID_VALUE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(RetSampler, PI_ERROR_INVALID_VALUE); // Have the "0" device in context to own the sampler. Rely on Level-Zero // drivers to perform migration as necessary for sharing it across multiple @@ -5760,7 +5762,7 @@ pi_result piSamplerCreate(pi_context Context, else { zePrint("piSamplerCreate: unsupported " "PI_SAMPLER_NORMALIZED_COORDS value\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } break; @@ -5803,7 +5805,7 @@ pi_result piSamplerCreate(pi_context Context, zePrint("piSamplerCreate: unsupported PI_SAMPLER_ADDRESSING_MODE " "value\n"); zePrint("PI_SAMPLER_ADDRESSING_MODE=%d\n", CurValueAddressingMode); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } break; @@ -5820,7 +5822,7 @@ pi_result piSamplerCreate(pi_context Context, zePrint("PI_SAMPLER_FILTER_MODE=%d\n", CurValueFilterMode); zePrint( "piSamplerCreate: unsupported PI_SAMPLER_FILTER_MODE value\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } } break; @@ -5838,7 +5840,7 @@ pi_result piSamplerCreate(pi_context Context, try { *RetSampler = new _pi_sampler(ZeSampler); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -5859,14 +5861,14 @@ pi_result piSamplerGetInfo(pi_sampler Sampler, pi_sampler_info ParamName, } pi_result piSamplerRetain(pi_sampler Sampler) { - PI_ASSERT(Sampler, PI_INVALID_SAMPLER); + PI_ASSERT(Sampler, PI_ERROR_INVALID_SAMPLER); Sampler->RefCount.increment(); return PI_SUCCESS; } pi_result piSamplerRelease(pi_sampler Sampler) { - PI_ASSERT(Sampler, PI_INVALID_SAMPLER); + PI_ASSERT(Sampler, PI_ERROR_INVALID_SAMPLER); if (!Sampler->RefCount.decrementAndTest()) return PI_SUCCESS; @@ -5883,11 +5885,11 @@ pi_result piSamplerRelease(pi_sampler Sampler) { pi_result piEnqueueEventsWait(pi_queue Queue, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); if (EventWaitList) { - PI_ASSERT(NumEventsInWaitList > 0, PI_INVALID_VALUE); + PI_ASSERT(NumEventsInWaitList > 0, PI_ERROR_INVALID_VALUE); bool UseCopyEngine = false; @@ -5956,8 +5958,8 @@ pi_result piEnqueueEventsWaitWithBarrier(pi_queue Queue, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); // Lock automatically releases when this goes out of scope. std::scoped_lock lock(Queue->Mutex); @@ -5999,8 +6001,8 @@ pi_result piEnqueueMemBufferRead(pi_queue Queue, pi_mem Src, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Src, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Src, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::shared_lock SrcLock(Src->Mutex, std::defer_lock); std::scoped_lock LockAll(SrcLock, Queue->Mutex); @@ -6020,8 +6022,8 @@ pi_result piEnqueueMemBufferReadRect( pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Buffer, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Buffer, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::shared_lock SrcLock(Buffer->Mutex, std::defer_lock); std::scoped_lock LockAll(SrcLock, Queue->Mutex); @@ -6096,8 +6098,8 @@ static pi_result enqueueMemCopyHelper(pi_command_type CommandType, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); bool UseCopyEngine = Queue->useCopyEngine(PreferCopyEngine); @@ -6157,8 +6159,8 @@ static pi_result enqueueMemCopyRectHelper( size_t DstSlicePitch, pi_bool Blocking, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine) { - PI_ASSERT(Region && SrcOrigin && DstOrigin && Queue, PI_INVALID_VALUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Region && SrcOrigin && DstOrigin && Queue, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); bool UseCopyEngine = Queue->useCopyEngine(PreferCopyEngine); @@ -6254,8 +6256,8 @@ pi_result piEnqueueMemBufferWrite(pi_queue Queue, pi_mem Buffer, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Buffer, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Buffer, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock Lock(Queue->Mutex, Buffer->Mutex); @@ -6276,8 +6278,8 @@ pi_result piEnqueueMemBufferWriteRect( pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Buffer, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Buffer, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock Lock(Queue->Mutex, Buffer->Mutex); @@ -6296,11 +6298,11 @@ pi_result piEnqueueMemBufferCopy(pi_queue Queue, pi_mem SrcMem, pi_mem DstMem, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(SrcMem && DstMem, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(SrcMem && DstMem, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); - PI_ASSERT(!SrcMem->isImage(), PI_INVALID_MEM_OBJECT); - PI_ASSERT(!DstMem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(!SrcMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(!DstMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto SrcBuffer = pi_cast(SrcMem); auto DstBuffer = pi_cast(DstMem); @@ -6334,11 +6336,11 @@ pi_result piEnqueueMemBufferCopyRect( size_t SrcRowPitch, size_t SrcSlicePitch, size_t DstRowPitch, size_t DstSlicePitch, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(SrcMem && DstMem, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(SrcMem && DstMem, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); - PI_ASSERT(!SrcMem->isImage(), PI_INVALID_MEM_OBJECT); - PI_ASSERT(!DstMem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(!SrcMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(!DstMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto SrcBuffer = pi_cast(SrcMem); auto DstBuffer = pi_cast(DstMem); @@ -6372,11 +6374,11 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr, const void *Pattern, size_t PatternSize, size_t Size, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); // Pattern size must be a power of two. PI_ASSERT((PatternSize > 0) && ((PatternSize & (PatternSize - 1)) == 0), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); auto &Device = Queue->Device; @@ -6407,7 +6409,7 @@ enqueueMemFillHelper(pi_command_type CommandType, pi_queue Queue, void *Ptr, PI_ASSERT(PatternSize <= Device->QueueGroup[_pi_device::queue_group_info_t::Compute] .ZeProperties.maxMemoryFillPatternSize, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } _pi_ze_event_list_t TmpWaitList; @@ -6464,8 +6466,8 @@ pi_result piEnqueueMemBufferFill(pi_queue Queue, pi_mem Buffer, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Buffer, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Buffer, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock Lock(Queue->Mutex, Buffer->Mutex); @@ -6489,11 +6491,11 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, // TODO: we don't implement read-only or write-only, always read-write. // assert((map_flags & PI_MAP_READ) != 0); // assert((map_flags & PI_MAP_WRITE) != 0); - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); - PI_ASSERT(!Mem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(!Mem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto Buffer = pi_cast(Mem); ze_event_handle_t ZeEvent = nullptr; @@ -6529,7 +6531,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, } else if (MapFlags & PI_MAP_WRITE) AccessMode = _pi_mem::write_only; } - PI_ASSERT(AccessMode != _pi_mem::unknown, PI_INVALID_VALUE); + PI_ASSERT(AccessMode != _pi_mem::unknown, PI_ERROR_INVALID_VALUE); // TODO: Level Zero is missing the memory "mapping" capabilities, so we are // left to doing new memory allocation and a copy (read) on discrete devices. @@ -6583,7 +6585,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, // because mapping already exists. if (!Res.second) { zePrint("piEnqueueMemBufferMap: duplicate mapping detected\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } // Signal this event @@ -6640,7 +6642,7 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, // because mapping already exists. if (!Res.second) { zePrint("piEnqueueMemBufferMap: duplicate mapping detected\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } @@ -6648,11 +6650,11 @@ pi_result piEnqueueMemBufferMap(pi_queue Queue, pi_mem Mem, pi_bool BlockingMap, pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem Mem, void *MappedPtr, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); - PI_ASSERT(!Mem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(!Mem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto Buffer = pi_cast(Mem); bool UseCopyEngine = false; @@ -6683,7 +6685,7 @@ pi_result piEnqueueMemUnmap(pi_queue Queue, pi_mem Mem, void *MappedPtr, auto It = Buffer->Mappings.find(MappedPtr); if (It == Buffer->Mappings.end()) { zePrint("piEnqueueMemUnmap: unknown memory mapping\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } MapInfo = It->second; Buffer->Mappings.erase(It); @@ -6786,11 +6788,11 @@ static pi_result getImageRegionHelper(pi_mem Mem, pi_image_offset Origin, pi_image_region Region, ze_image_region_t &ZeRegion) { - PI_ASSERT(Mem, PI_INVALID_MEM_OBJECT); - PI_ASSERT(Origin, PI_INVALID_VALUE); + PI_ASSERT(Mem, PI_ERROR_INVALID_MEM_OBJECT); + PI_ASSERT(Origin, PI_ERROR_INVALID_VALUE); #ifndef NDEBUG - PI_ASSERT(Mem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(Mem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto Image = static_cast<_pi_image *>(Mem); ze_image_desc_t &ZeImageDesc = Image->ZeImageDesc; @@ -6799,16 +6801,17 @@ static pi_result getImageRegionHelper(pi_mem Mem, pi_image_offset Origin, (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Origin->z == 0) || (ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Origin->z == 0) || (ZeImageDesc.type == ZE_IMAGE_TYPE_3D), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); - PI_ASSERT(Region->width && Region->height && Region->depth, PI_INVALID_VALUE); + PI_ASSERT(Region->width && Region->height && Region->depth, + PI_ERROR_INVALID_VALUE); PI_ASSERT( (ZeImageDesc.type == ZE_IMAGE_TYPE_1D && Region->height == 1 && Region->depth == 1) || (ZeImageDesc.type == ZE_IMAGE_TYPE_1DARRAY && Region->depth == 1) || (ZeImageDesc.type == ZE_IMAGE_TYPE_2D && Region->depth == 1) || (ZeImageDesc.type == ZE_IMAGE_TYPE_3D), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); #endif // !NDEBUG uint32_t OriginX = pi_cast(Origin->x); @@ -6835,8 +6838,8 @@ static pi_result enqueueMemImageCommandHelper( pi_image_region Region, size_t RowPitch, size_t SlicePitch, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event, bool PreferCopyEngine = false) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); bool UseCopyEngine = Queue->useCopyEngine(PreferCopyEngine); @@ -6882,7 +6885,7 @@ static pi_result enqueueMemImageCommandHelper( (void)RowPitch; (void)SlicePitch; #ifndef NDEBUG - PI_ASSERT(SrcMem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(SrcMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto SrcImage = static_cast<_pi_image *>(SrcMem); const ze_image_desc_t &ZeImageDesc = SrcImage->ZeImageDesc; @@ -6895,9 +6898,9 @@ static pi_result enqueueMemImageCommandHelper( RowPitch == 4 * 2 * ZeSrcRegion.width) || (ZeImageDesc.format.layout == ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8 && RowPitch == 4 * ZeSrcRegion.width), - PI_INVALID_IMAGE_SIZE); + PI_ERROR_INVALID_IMAGE_SIZE); PI_ASSERT(SlicePitch == 0 || SlicePitch == RowPitch * ZeSrcRegion.height, - PI_INVALID_IMAGE_SIZE); + PI_ERROR_INVALID_IMAGE_SIZE); #endif // !NDEBUG char *ZeHandleSrc; @@ -6916,7 +6919,7 @@ static pi_result enqueueMemImageCommandHelper( // TODO: Level Zero does not support row_pitch/slice_pitch for images yet. // Check that SYCL RT did not want pitch larger than default. #ifndef NDEBUG - PI_ASSERT(DstMem->isImage(), PI_INVALID_MEM_OBJECT); + PI_ASSERT(DstMem->isImage(), PI_ERROR_INVALID_MEM_OBJECT); auto DstImage = static_cast<_pi_image *>(DstMem); const ze_image_desc_t &ZeImageDesc = DstImage->ZeImageDesc; @@ -6929,9 +6932,9 @@ static pi_result enqueueMemImageCommandHelper( RowPitch == 4 * 2 * ZeDstRegion.width) || (ZeImageDesc.format.layout == ZE_IMAGE_FORMAT_LAYOUT_8_8_8_8 && RowPitch == 4 * ZeDstRegion.width), - PI_INVALID_IMAGE_SIZE); + PI_ERROR_INVALID_IMAGE_SIZE); PI_ASSERT(SlicePitch == 0 || SlicePitch == RowPitch * ZeDstRegion.height, - PI_INVALID_IMAGE_SIZE); + PI_ERROR_INVALID_IMAGE_SIZE); #endif // !NDEBUG char *ZeHandleDst; @@ -6966,7 +6969,7 @@ static pi_result enqueueMemImageCommandHelper( &ZeSrcRegion, ZeEvent, 0, nullptr)); } else { zePrint("enqueueMemImageUpdate: unsupported image command type\n"); - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } if (auto Res = Queue->executeCommandList(CommandList, IsBlocking, OkToBatch)) @@ -6984,7 +6987,7 @@ pi_result piEnqueueMemImageRead(pi_queue Queue, pi_mem Image, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::shared_lock SrcLock(Image->Mutex, std::defer_lock); std::scoped_lock LockAll(SrcLock, Queue->Mutex); @@ -7006,7 +7009,7 @@ pi_result piEnqueueMemImageWrite(pi_queue Queue, pi_mem Image, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock Lock(Queue->Mutex, Image->Mutex); return enqueueMemImageCommandHelper(PI_COMMAND_TYPE_IMAGE_WRITE, Queue, @@ -7026,7 +7029,7 @@ piEnqueueMemImageCopy(pi_queue Queue, pi_mem SrcImage, pi_mem DstImage, pi_image_region Region, pi_uint32 NumEventsInWaitList, const pi_event *EventWaitList, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::shared_lock SrcLock(SrcImage->Mutex, std::defer_lock); std::scoped_lock LockAll(SrcLock, DstImage->Mutex, Queue->Mutex); @@ -7057,7 +7060,7 @@ pi_result piEnqueueMemImageFill(pi_queue Queue, pi_mem Image, (void)EventWaitList; (void)Event; - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); // Lock automatically releases when this goes out of scope. std::scoped_lock Lock(Queue->Mutex, Image->Mutex); @@ -7072,11 +7075,11 @@ pi_result piMemBufferPartition(pi_mem Buffer, pi_mem_flags Flags, PI_ASSERT(Buffer && !Buffer->isImage() && !(static_cast(Buffer))->isSubBuffer(), - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); PI_ASSERT(BufferCreateType == PI_BUFFER_CREATE_TYPE_REGION && BufferCreateInfo && RetMem, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); std::shared_lock Guard(Buffer->Mutex); @@ -7087,15 +7090,15 @@ pi_result piMemBufferPartition(pi_mem Buffer, pi_mem_flags Flags, auto Region = (pi_buffer_region)BufferCreateInfo; - PI_ASSERT(Region->size != 0u, PI_INVALID_BUFFER_SIZE); + PI_ASSERT(Region->size != 0u, PI_ERROR_INVALID_BUFFER_SIZE); PI_ASSERT(Region->origin <= (Region->origin + Region->size), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); try { *RetMem = new _pi_buffer(static_cast(Buffer), Region->origin, Region->size); } catch (const std::bad_alloc &) { - return PI_OUT_OF_HOST_MEMORY; + return PI_ERROR_OUT_OF_HOST_MEMORY; } catch (...) { return PI_ERROR_UNKNOWN; } @@ -7120,7 +7123,7 @@ pi_result piEnqueueNativeKernel(pi_queue Queue, void (*UserFunc)(void *), (void)EventWaitList; (void)Event; - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); // Lock automatically releases when this goes out of scope. std::scoped_lock lock(Queue->Mutex); @@ -7160,11 +7163,11 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, const char *FunctionName, pi_uint64 *FunctionPointerRet) { (void)Device; - PI_ASSERT(Program, PI_INVALID_PROGRAM); + PI_ASSERT(Program, PI_ERROR_INVALID_PROGRAM); std::shared_lock Guard(Program->Mutex); if (Program->State != _pi_program::Exe) { - return PI_INVALID_PROGRAM_EXECUTABLE; + return PI_ERROR_INVALID_PROGRAM_EXECUTABLE; } ze_result_t ZeResult = @@ -7178,8 +7181,8 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, // TODO: remove when this is no longer the case // If zeModuleGetFunctionPointer returns invalid argument, // fallback to searching through kernel list and return - // PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE if the function exists - // or PI_INVALID_KERNEL_NAME if the function does not exist. + // PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE if the function exists + // or PI_ERROR_INVALID_KERNEL_NAME if the function does not exist. // FunctionPointerRet should always be 0 if (ZeResult == ZE_RESULT_ERROR_INVALID_ARGUMENT) { size_t Size; @@ -7196,14 +7199,14 @@ pi_result piextGetDeviceFunctionPointer(pi_device Device, pi_program Program, // exists ClResult.pop_back(); if (is_in_separated_string(ClResult, ';', std::string(FunctionName))) - return PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; + return PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; - return PI_INVALID_KERNEL_NAME; + return PI_ERROR_INVALID_KERNEL_NAME; } if (ZeResult == ZE_RESULT_ERROR_INVALID_FUNCTION_NAME) { *FunctionPointerRet = 0; - return PI_INVALID_KERNEL_NAME; + return PI_ERROR_INVALID_KERNEL_NAME; } return mapError(ZeResult); @@ -7220,13 +7223,13 @@ static pi_result USMDeviceAllocImpl(void **ResultPtr, pi_context Context, pi_device Device, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); // Check that incorrect bits are not set in the properties. PI_ASSERT(!Properties || (*Properties == PI_MEM_ALLOC_FLAGS && *(Properties + 2) == 0), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // TODO: translate PI properties to Level Zero flags ZeStruct ZeDesc; @@ -7245,7 +7248,7 @@ static pi_result USMDeviceAllocImpl(void **ResultPtr, pi_context Context, PI_ASSERT(Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return PI_SUCCESS; } @@ -7255,8 +7258,8 @@ static pi_result USMSharedAllocImpl(void **ResultPtr, pi_context Context, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment) { (void)Properties; - PI_ASSERT(Context, PI_INVALID_CONTEXT); - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); // TODO: translate PI properties to Level Zero flags ZeStruct ZeHostDesc; @@ -7277,7 +7280,7 @@ static pi_result USMSharedAllocImpl(void **ResultPtr, pi_context Context, PI_ASSERT(Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return PI_SUCCESS; } @@ -7285,12 +7288,12 @@ static pi_result USMSharedAllocImpl(void **ResultPtr, pi_context Context, static pi_result USMHostAllocImpl(void **ResultPtr, pi_context Context, pi_usm_mem_properties *Properties, size_t Size, pi_uint32 Alignment) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); // Check that incorrect bits are not set in the properties. PI_ASSERT(!Properties || (*Properties == PI_MEM_ALLOC_FLAGS && *(Properties + 2) == 0), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); // TODO: translate PI properties to Level Zero flags ZeStruct ZeHostDesc; @@ -7300,7 +7303,7 @@ static pi_result USMHostAllocImpl(void **ResultPtr, pi_context Context, PI_ASSERT(Alignment == 0 || reinterpret_cast(*ResultPtr) % Alignment == 0, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return PI_SUCCESS; } @@ -7396,7 +7399,7 @@ pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. if (Alignment > 65536) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; pi_platform Plt = Device->Platform; std::unique_lock ContextsLock(Plt->ContextsMutex, @@ -7432,7 +7435,7 @@ pi_result piextUSMDeviceAlloc(void **ResultPtr, pi_context Context, try { auto It = Context->DeviceMemAllocContexts.find(Device); if (It == Context->DeviceMemAllocContexts.end()) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; *ResultPtr = It->second.allocate(Size, Alignment); if (IndirectAccessTrackingEnabled) { @@ -7461,14 +7464,14 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context, // Check that incorrect bits are not set in the properties. if (Properties && *Properties != 0) { PI_ASSERT(*(Properties) == PI_MEM_ALLOC_FLAGS && *(Properties + 2) == 0, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); DeviceReadOnly = *(Properties + 1) & PI_MEM_ALLOC_DEVICE_READ_ONLY; } // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. if (Alignment > 65536) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; pi_platform Plt = Device->Platform; std::unique_lock ContextsLock(Plt->ContextsMutex, @@ -7506,7 +7509,7 @@ pi_result piextUSMSharedAlloc(void **ResultPtr, pi_context Context, : Context->SharedMemAllocContexts); auto It = Allocator.find(Device); if (It == Allocator.end()) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; *ResultPtr = It->second.allocate(Size, Alignment); if (DeviceReadOnly) { @@ -7534,7 +7537,7 @@ pi_result piextUSMHostAlloc(void **ResultPtr, pi_context Context, // L0 supports alignment up to 64KB and silently ignores higher values. // We flag alignment > 64KB as an invalid value. if (Alignment > 65536) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; pi_platform Plt = Context->getPlatform(); std::unique_lock ContextsLock(Plt->ContextsMutex, @@ -7649,17 +7652,17 @@ static pi_result USMFreeHelper(pi_context Context, void *Ptr, // if the memory is not known to the driver. We should not ever get // this either, probably. PI_ASSERT(ZeMemoryAllocationProperties.type == ZE_MEMORY_TYPE_UNKNOWN, - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } else { pi_device Device; if (Context->Devices.size() == 1) { Device = Context->Devices[0]; - PI_ASSERT(Device->ZeDevice == ZeDeviceHandle, PI_INVALID_DEVICE); + PI_ASSERT(Device->ZeDevice == ZeDeviceHandle, PI_ERROR_INVALID_DEVICE); } else { // All devices in the context are of the same platform. auto Platform = Context->getPlatform(); Device = Platform->getDeviceFromNativeHandle(ZeDeviceHandle); - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); } auto DeallocationHelper = @@ -7668,7 +7671,7 @@ static pi_result USMFreeHelper(pi_context Context, void *Ptr, try { auto It = AllocContextMap.find(Device); if (It == AllocContextMap.end()) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; // The right context is found, deallocate the pointer It->second.deallocate(Ptr, OwnZeMemHandle); @@ -7738,10 +7741,10 @@ pi_result piextUSMEnqueueMemset(pi_queue Queue, void *Ptr, pi_int32 Value, const pi_event *EventsWaitlist, pi_event *Event) { if (!Ptr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock Lock(Queue->Mutex); return enqueueMemFillHelper( @@ -7772,10 +7775,10 @@ pi_result piextUSMEnqueueMemcpy(pi_queue Queue, pi_bool Blocking, void *DstPtr, pi_event *Event) { if (!DstPtr) { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } - PI_ASSERT(Queue, PI_INVALID_QUEUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); std::scoped_lock lock(Queue->Mutex); @@ -7809,9 +7812,9 @@ pi_result piextUSMEnqueuePrefetch(pi_queue Queue, const void *Ptr, size_t Size, pi_event *Event) { // flags is currently unused so fail if set - PI_ASSERT(Flags == 0, PI_INVALID_VALUE); - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Flags == 0, PI_ERROR_INVALID_VALUE); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); // Lock automatically releases when this goes out of scope. std::scoped_lock lock(Queue->Mutex); @@ -7876,8 +7879,8 @@ pi_result piextUSMEnqueuePrefetch(pi_queue Queue, const void *Ptr, size_t Size, pi_result piextUSMEnqueueMemAdvise(pi_queue Queue, const void *Ptr, size_t Length, pi_mem_advice Advice, pi_event *Event) { - PI_ASSERT(Queue, PI_INVALID_QUEUE); - PI_ASSERT(Event, PI_INVALID_EVENT); + PI_ASSERT(Queue, PI_ERROR_INVALID_QUEUE); + PI_ASSERT(Event, PI_ERROR_INVALID_EVENT); // Lock automatically releases when this goes out of scope. std::scoped_lock lock(Queue->Mutex); @@ -7949,7 +7952,7 @@ pi_result piextUSMGetMemAllocInfo(pi_context Context, const void *Ptr, pi_mem_alloc_info ParamName, size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - PI_ASSERT(Context, PI_INVALID_CONTEXT); + PI_ASSERT(Context, PI_ERROR_INVALID_CONTEXT); ze_device_handle_t ZeDeviceHandle; ZeStruct ZeMemoryAllocationProperties; @@ -7977,7 +7980,7 @@ pi_result piextUSMGetMemAllocInfo(pi_context Context, const void *Ptr, break; default: zePrint("piextUSMGetMemAllocInfo: unexpected usm memory type\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return ReturnValue(MemAllocaType); } @@ -7985,9 +7988,9 @@ pi_result piextUSMGetMemAllocInfo(pi_context Context, const void *Ptr, if (ZeDeviceHandle) { auto Platform = Context->getPlatform(); auto Device = Platform->getDeviceFromNativeHandle(ZeDeviceHandle); - return Device ? ReturnValue(Device) : PI_INVALID_VALUE; + return Device ? ReturnValue(Device) : PI_ERROR_INVALID_VALUE; } else { - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } case PI_MEM_ALLOC_BASE_PTR: { void *Base; @@ -8001,7 +8004,7 @@ pi_result piextUSMGetMemAllocInfo(pi_context Context, const void *Ptr, } default: zePrint("piextUSMGetMemAllocInfo: unsupported ParamName\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; } @@ -8009,8 +8012,8 @@ pi_result piextUSMGetMemAllocInfo(pi_context Context, const void *Ptr, pi_result piKernelSetExecInfo(pi_kernel Kernel, pi_kernel_exec_info ParamName, size_t ParamValueSize, const void *ParamValue) { (void)ParamValueSize; - PI_ASSERT(Kernel, PI_INVALID_KERNEL); - PI_ASSERT(ParamValue, PI_INVALID_VALUE); + PI_ASSERT(Kernel, PI_ERROR_INVALID_KERNEL); + PI_ASSERT(ParamValue, PI_ERROR_INVALID_VALUE); std::scoped_lock Guard(Kernel->Mutex); if (ParamName == PI_USM_INDIRECT_ACCESS && @@ -8025,7 +8028,7 @@ pi_result piKernelSetExecInfo(pi_kernel Kernel, pi_kernel_exec_info ParamName, ZE_CALL(zeKernelSetIndirectAccess, (Kernel->ZeKernel, IndirectFlags)); } else { zePrint("piKernelSetExecInfo: unsupported ParamName\n"); - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } return PI_SUCCESS; @@ -8048,12 +8051,13 @@ pi_result piextProgramSetSpecializationConstant(pi_program Prog, } pi_result piPluginInit(pi_plugin *PluginInit) { - PI_ASSERT(PluginInit, PI_INVALID_VALUE); + PI_ASSERT(PluginInit, PI_ERROR_INVALID_VALUE); // TODO: handle versioning/targets properly. size_t PluginVersionSize = sizeof(PluginInit->PluginVersion); - PI_ASSERT(strlen(_PI_H_VERSION_STRING) < PluginVersionSize, PI_INVALID_VALUE); + PI_ASSERT(strlen(_PI_H_VERSION_STRING) < PluginVersionSize, + PI_ERROR_INVALID_VALUE); strncpy(PluginInit->PluginVersion, _PI_H_VERSION_STRING, PluginVersionSize); @@ -8167,7 +8171,7 @@ pi_result piTearDown(void *PluginParameter) { ZeCallCount = nullptr; } if (LeakFound) - return PI_INVALID_MEM_OBJECT; + return PI_ERROR_INVALID_MEM_OBJECT; disableZeTracing(); return PI_SUCCESS; @@ -8208,7 +8212,7 @@ pi_result _pi_buffer::getZeHandle(char *&ZeHandle, access_mode_t AccessMode, if (!Device) Device = LastDeviceWithValidAllocation; - PI_ASSERT(Device, PI_INVALID_DEVICE); + PI_ASSERT(Device, PI_ERROR_INVALID_DEVICE); auto &Allocation = Allocations[Device]; diff --git a/sycl/plugins/opencl/CMakeLists.txt b/sycl/plugins/opencl/CMakeLists.txt index 80e16f55c6fe3..2e5b5d789e6d4 100644 --- a/sycl/plugins/opencl/CMakeLists.txt +++ b/sycl/plugins/opencl/CMakeLists.txt @@ -19,3 +19,5 @@ add_sycl_plugin(opencl ) set_target_properties(pi_opencl PROPERTIES LINKER_LANGUAGE CXX) + +target_compile_definitions(pi_opencl PRIVATE PI_OPENCL_AVAILABLE) diff --git a/sycl/plugins/opencl/pi_opencl.cpp b/sycl/plugins/opencl/pi_opencl.cpp index 97491bc2380e2..6580c312cfb96 100644 --- a/sycl/plugins/opencl/pi_opencl.cpp +++ b/sycl/plugins/opencl/pi_opencl.cpp @@ -71,7 +71,7 @@ CONSTFIX char clGetDeviceFunctionPointerName[] = #undef CONSTFIX -// Global variables for PI_PLUGIN_SPECIFIC_ERROR +// Global variables for PI_ERROR_PLUGIN_SPECIFIC_ERROR constexpr size_t MaxMessageSize = 256; thread_local pi_result ErrorMessageCode = PI_SUCCESS; thread_local char ErrorMessage[MaxMessageSize]; @@ -100,9 +100,9 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) { // if cached, return cached FuncPtr if (auto F = FuncPtrs[context]) { // if cached that extension is not available return nullptr and - // PI_INVALID_VALUE + // PI_ERROR_INVALID_VALUE *fptr = F; - return F ? PI_SUCCESS : PI_INVALID_VALUE; + return F ? PI_SUCCESS : PI_ERROR_INVALID_VALUE; } cl_uint deviceCount; @@ -111,7 +111,7 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) { sizeof(cl_uint), &deviceCount, nullptr); if (ret_err != CL_SUCCESS || deviceCount < 1) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } std::vector devicesInCtx(deviceCount); @@ -120,7 +120,7 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) { devicesInCtx.data(), nullptr); if (ret_err != CL_SUCCESS) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } cl_platform_id curPlatform; @@ -128,7 +128,7 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) { sizeof(cl_platform_id), &curPlatform, nullptr); if (ret_err != CL_SUCCESS) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } T FuncPtr = @@ -137,7 +137,7 @@ static pi_result getExtFuncFromContext(pi_context context, T *fptr) { if (!FuncPtr) { // Cache that the extension is not available FuncPtrs[context] = nullptr; - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; } *fptr = FuncPtr; @@ -214,7 +214,7 @@ pi_result piDeviceGetInfo(pi_device device, pi_device_info paramName, case PI_DEVICE_INFO_UUID: case PI_DEVICE_INFO_ATOMIC_MEMORY_ORDER_CAPABILITIES: case PI_DEVICE_INFO_ATOMIC_MEMORY_SCOPE_CAPABILITIES: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; case PI_DEVICE_INFO_ATOMIC_64: { size_t extSize; cl_bool result = clGetDeviceInfo( @@ -323,7 +323,7 @@ pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *images, // for the given device, and simply picks the first one compatible // Real implementation will use the same mechanism OpenCL ICD dispatcher // uses. Something like: - // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_INVALID_CONTEXT); + // PI_VALIDATE_HANDLE_RETURN_HANDLE(ctx, PI_ERROR_INVALID_CONTEXT); // return context->dispatch->piextDeviceSelectIR( // ctx, images, num_images, selected_image); // where context->dispatch is set to the dispatch table provided by PI @@ -380,7 +380,7 @@ pi_result piextDeviceSelectBinary(pi_device device, pi_device_binary *images, if ((*selected_image_ind = fallback) != invalid_ind) return PI_SUCCESS; // No image can be loaded for the given device - return PI_INVALID_BINARY; + return PI_ERROR_INVALID_BINARY; } pi_result piextDeviceCreateWithNativeHandle(pi_native_handle nativeHandle, @@ -513,7 +513,7 @@ pi_result piProgramCreate(pi_context context, const void *il, size_t length, *res_program = cast( funcPtr(cast(context), il, length, cast(&err))); else - err = PI_INVALID_VALUE; + err = PI_ERROR_INVALID_VALUE; return err; } @@ -652,21 +652,21 @@ pi_result piextGetDeviceFunctionPointer(pi_device device, pi_program program, // exists ClResult.pop_back(); if (!is_in_separated_string(ClResult, ';', func_name)) - return PI_INVALID_KERNEL_NAME; + return PI_ERROR_INVALID_KERNEL_NAME; - pi_ret_err = PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; + pi_ret_err = PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; // If clGetDeviceFunctionPointer is in list of extensions if (FuncT) { pi_ret_err = cast(FuncT(cast(device), cast(program), func_name, function_pointer_ret)); - // GPU runtime sometimes returns PI_INVALID_ARG_VALUE if func address cannot - // be found even if kernel exits. As the kernel does exist return that the - // address is not available + // GPU runtime sometimes returns PI_ERROR_INVALID_ARG_VALUE if func address + // cannot be found even if kernel exits. As the kernel does exist return + // that the address is not available if (pi_ret_err == CL_INVALID_ARG_VALUE) { *function_pointer_ret = 0; - return PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; + return PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE; } } return pi_ret_err; @@ -678,7 +678,7 @@ pi_result piContextCreate(const pi_context_properties *properties, const void *private_info, size_t cb, void *user_data1), void *user_data, pi_context *retcontext) { - pi_result ret = PI_INVALID_OPERATION; + pi_result ret = PI_ERROR_INVALID_OPERATION; *retcontext = cast( clCreateContext(properties, cast(num_devices), cast(devices), pfn_notify, @@ -704,7 +704,7 @@ pi_result piextContextCreateWithNativeHandle(pi_native_handle nativeHandle, pi_result piMemBufferCreate(pi_context context, pi_mem_flags flags, size_t size, void *host_ptr, pi_mem *ret_mem, const pi_mem_properties *properties) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; if (properties) { // TODO: need to check if all properties are supported by OpenCL RT and // ignore unsupported @@ -731,7 +731,7 @@ pi_result piMemImageCreate(pi_context context, pi_mem_flags flags, const pi_image_format *image_format, const pi_image_desc *image_desc, void *host_ptr, pi_mem *ret_mem) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_mem = cast( clCreateImage(cast(context), cast(flags), cast(image_format), @@ -745,7 +745,7 @@ pi_result piMemBufferPartition(pi_mem buffer, pi_mem_flags flags, pi_buffer_create_type buffer_create_type, void *buffer_create_info, pi_mem *ret_mem) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_mem = cast( clCreateSubBuffer(cast(buffer), cast(flags), cast(buffer_create_type), @@ -768,7 +768,7 @@ pi_result piclProgramCreateWithSource(pi_context context, pi_uint32 count, const size_t *lengths, pi_program *ret_program) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_program = cast( clCreateProgramWithSource(cast(context), cast(count), strings, lengths, cast(&ret_err))); @@ -783,7 +783,7 @@ pi_result piProgramCreateWithBinary( (void)metadata; (void)num_metadata_entries; - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_program = cast(clCreateProgramWithBinary( cast(context), cast(num_devices), cast(device_list), lengths, binaries, @@ -798,7 +798,7 @@ pi_result piProgramLink(pi_context context, pi_uint32 num_devices, void (*pfn_notify)(pi_program program, void *user_data), void *user_data, pi_program *ret_program) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_program = cast( clLinkProgram(cast(context), cast(num_devices), cast(device_list), options, @@ -812,7 +812,7 @@ pi_result piProgramLink(pi_context context, pi_uint32 num_devices, pi_result piKernelCreate(pi_program program, const char *kernel_name, pi_kernel *ret_kernel) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_kernel = cast(clCreateKernel( cast(program), kernel_name, cast(&ret_err))); return ret_err; @@ -823,12 +823,12 @@ pi_result piKernelGetGroupInfo(pi_kernel kernel, pi_device device, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { if (kernel == nullptr) { - return PI_INVALID_KERNEL; + return PI_ERROR_INVALID_KERNEL; } switch (param_name) { case PI_KERNEL_GROUP_INFO_NUM_REGS: - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; default: cl_int result = clGetKernelWorkGroupInfo( cast(kernel), cast(device), @@ -863,7 +863,7 @@ pi_result piKernelGetSubGroupInfo(pi_kernel kernel, pi_device device, pi_result piEventCreate(pi_context context, pi_event *ret_event) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_event = cast( clCreateUserEvent(cast(context), cast(&ret_err))); return ret_err; @@ -892,7 +892,7 @@ pi_result piEnqueueMemBufferMap(pi_queue command_queue, pi_mem buffer, const pi_event *event_wait_list, pi_event *event, void **ret_map) { - pi_result ret_err = PI_INVALID_OPERATION; + pi_result ret_err = PI_ERROR_INVALID_OPERATION; *ret_map = cast(clEnqueueMapBuffer( cast(command_queue), cast(buffer), cast(blocking_map), map_flags, offset, size, @@ -918,7 +918,7 @@ pi_result piextUSMHostAlloc(void **result_ptr, pi_context context, pi_uint32 alignment) { void *Ptr = nullptr; - pi_result RetVal = PI_INVALID_OPERATION; + pi_result RetVal = PI_ERROR_INVALID_OPERATION; // First we need to look up the function pointer clHostMemAllocINTEL_fn FuncPtr = nullptr; @@ -955,7 +955,7 @@ pi_result piextUSMDeviceAlloc(void **result_ptr, pi_context context, pi_uint32 alignment) { void *Ptr = nullptr; - pi_result RetVal = PI_INVALID_OPERATION; + pi_result RetVal = PI_ERROR_INVALID_OPERATION; // First we need to look up the function pointer clDeviceMemAllocINTEL_fn FuncPtr = nullptr; @@ -993,7 +993,7 @@ pi_result piextUSMSharedAlloc(void **result_ptr, pi_context context, pi_uint32 alignment) { void *Ptr = nullptr; - pi_result RetVal = PI_INVALID_OPERATION; + pi_result RetVal = PI_ERROR_INVALID_OPERATION; // First we need to look up the function pointer clSharedMemAllocINTEL_fn FuncPtr = nullptr; @@ -1039,7 +1039,7 @@ pi_result piextUSMFree(pi_context context, void *ptr) { sizeof(cl_uint), &deviceCount, nullptr); if (ret_err != CL_SUCCESS || deviceCount < 1) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } std::vector devicesInCtx(deviceCount); @@ -1048,7 +1048,7 @@ pi_result piextUSMFree(pi_context context, void *ptr) { devicesInCtx.data(), nullptr); if (ret_err != CL_SUCCESS) { - return PI_INVALID_CONTEXT; + return PI_ERROR_INVALID_CONTEXT; } bool useBlockingFree = true; @@ -1057,12 +1057,12 @@ pi_result piextUSMFree(pi_context context, void *ptr) { ret_err = clGetDeviceInfo(dev, CL_DEVICE_TYPE, sizeof(cl_device_type), &devType, nullptr); if (ret_err != CL_SUCCESS) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } useBlockingFree &= devType == CL_DEVICE_TYPE_GPU; } - pi_result RetVal = PI_INVALID_OPERATION; + pi_result RetVal = PI_ERROR_INVALID_OPERATION; if (useBlockingFree) RetVal = getExtFuncFromContext( @@ -1214,7 +1214,7 @@ pi_result piextUSMEnqueuePrefetch(pi_queue queue, const void *ptr, size_t size, // flags is currently unused so fail if set if (flags != 0) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; return cast(clEnqueueMarkerWithWaitList( cast(queue), num_events_in_waitlist, @@ -1373,7 +1373,7 @@ pi_result piextProgramSetSpecializationConstant(pi_program prog, decltype(F)>(cast(Ctx), &F); if (!F || Res != CL_SUCCESS) - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; Res = F(ClProg, spec_id, spec_size, spec_value); return cast(Res); } @@ -1438,13 +1438,13 @@ pi_result piPluginInit(pi_plugin *PluginInit) { if (CompareVersions < 0) { // PI interface supports lower version of PI. // TODO: Take appropriate actions. - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } // PI interface supports higher version or the same version. size_t PluginVersionSize = sizeof(PluginInit->PluginVersion); if (strlen(SupportedVersion) >= PluginVersionSize) - return PI_INVALID_VALUE; + return PI_ERROR_INVALID_VALUE; strncpy(PluginInit->PluginVersion, SupportedVersion, PluginVersionSize); #define _PI_CL(pi_api, ocl_api) \ diff --git a/sycl/source/backend.cpp b/sycl/source/backend.cpp index de6ed35795f7a..b19cb9abb30f7 100644 --- a/sycl/source/backend.cpp +++ b/sycl/source/backend.cpp @@ -36,7 +36,8 @@ static const plugin &getPlugin(backend Backend) { case backend::ext_oneapi_level_zero: return pi::getPlugin(); default: - throw sycl::runtime_error{"Unsupported backend", PI_INVALID_OPERATION}; + throw sycl::runtime_error{"Unsupported backend", + PI_ERROR_INVALID_OPERATION}; } } @@ -179,7 +180,7 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext, // TODO SYCL2020 exception throw sycl::runtime_error(errc::invalid, "Program and kernel_bundle state mismatch", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (State == bundle_state::executable) Plugin.call( ContextImpl->getHandleRef(), 1, &Dev, nullptr, 1, &PiProgram, @@ -190,7 +191,7 @@ make_kernel_bundle(pi_native_handle NativeHandle, const context &TargetContext, // TODO SYCL2020 exception throw sycl::runtime_error(errc::invalid, "Program and kernel_bundle state mismatch", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); break; } } @@ -246,7 +247,7 @@ kernel make_kernel(const context &TargetContext, if (KernelBundleImpl->size() != 1) throw sycl::runtime_error{ "make_kernel: kernel_bundle must have single program image", - PI_INVALID_PROGRAM}; + PI_ERROR_INVALID_PROGRAM}; const device_image &DeviceImage = *KernelBundle.begin(); diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index dc887af21ddd1..9e19d608f69ae 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -54,7 +54,8 @@ context::context(const std::vector &DeviceList, context::context(const std::vector &DeviceList, async_handler AsyncHandler, const property_list &PropList) { if (DeviceList.empty()) { - throw invalid_parameter_error("DeviceList is empty.", PI_INVALID_VALUE); + throw invalid_parameter_error("DeviceList is empty.", + PI_ERROR_INVALID_VALUE); } auto NonHostDeviceIter = std::find_if_not( DeviceList.begin(), DeviceList.end(), @@ -75,7 +76,7 @@ context::context(const std::vector &DeviceList, })) throw invalid_parameter_error( "Can't add devices across platforms to a single context.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); else impl = std::make_shared(DeviceList, AsyncHandler, PropList); diff --git a/sycl/source/detail/allowlist.cpp b/sycl/source/detail/allowlist.cpp index 49b210a69f5da..c88781e336a80 100644 --- a/sycl/source/detail/allowlist.cpp +++ b/sycl/source/detail/allowlist.cpp @@ -75,7 +75,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { "details, please refer to " "https://github.com/intel/llvm/blob/sycl/sycl/" "doc/EnvironmentVariables.md", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); const std::string &DeprecatedKeyNameDeviceName = DeviceNameKeyName; const std::string &DeprecatedKeyNamePlatformName = PlatformNameKeyName; @@ -99,7 +99,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { "refer to " "https://github.com/intel/llvm/blob/sycl/sycl/doc/" "EnvironmentVariables.md", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } if (Key == DeprecatedKeyNameDeviceName) { @@ -154,7 +154,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { "SYCL_DEVICE_ALLOWLIST. For details, please refer to " "https://github.com/intel/llvm/blob/sycl/sycl/doc/" "EnvironmentVariables.md", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } }; @@ -174,7 +174,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { "details, please refer to " "https://github.com/intel/llvm/blob/sycl/sycl/doc/" "EnvironmentVariables.md", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } } @@ -190,7 +190,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { " of SYCL_DEVICE_ALLOWLIST should have " "value which starts with " + Prefix, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } // cut off prefix from the value ValueStart += Prefix.length(); @@ -209,7 +209,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { " of SYCL_DEVICE_ALLOWLIST should have " "value which ends with " + Postfix, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } size_t NextExpectedDelimiterPos = ValueEnd + Postfix.length(); // if it is not the end of the string, check that symbol next to a @@ -224,7 +224,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { AllowListRaw[NextExpectedDelimiterPos] + ". Should be either " + DelimiterBtwItemsInDeviceDesc + " or " + DelimiterBtwDeviceDescs, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (AllowListRaw[NextExpectedDelimiterPos] == DelimiterBtwDeviceDescs) ShouldAllocateNewDeviceDescMap = true; @@ -243,7 +243,7 @@ AllowListParsedT parseAllowList(const std::string &AllowListRaw) { throw sycl::runtime_error("Re-definition of key " + Key + " is not allowed in " "SYCL_DEVICE_ALLOWLIST", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); KeyStart = ValueEnd; if (KeyStart != std::string::npos) diff --git a/sycl/source/detail/common.cpp b/sycl/source/detail/common.cpp index 417389c0531c5..4f4bd54af0608 100644 --- a/sycl/source/detail/common.cpp +++ b/sycl/source/detail/common.cpp @@ -216,11 +216,11 @@ const char *stringifyErrorCode(cl_int error) { case CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR: return "CL_DX9_MEDIA_SURFACE_NOT_ACQUIRED_KHR"; */ - case PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE: + case PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE: return "Function exists but address is not available"; - case PI_PLUGIN_SPECIFIC_ERROR: + case PI_ERROR_PLUGIN_SPECIFIC_ERROR: return "The plugin has emitted a backend specific error"; - case PI_COMMAND_EXECUTION_FAILURE: + case PI_ERROR_COMMAND_EXECUTION_FAILURE: return "Command failed to enqueue/execute"; default: return "Unknown OpenCL error code"; diff --git a/sycl/source/detail/config.hpp b/sycl/source/detail/config.hpp index f0009e0405465..c3cc38430d8b2 100644 --- a/sycl/source/detail/config.hpp +++ b/sycl/source/detail/config.hpp @@ -362,14 +362,14 @@ template <> class SYCLConfig { throw invalid_parameter_error( "Invalid value for SYCL_QUEUE_THREAD_POOL_SIZE environment " "variable: value should be a number", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } if (Result < 1) throw invalid_parameter_error( "Invalid value for SYCL_QUEUE_THREAD_POOL_SIZE environment " "variable: value should be larger than zero", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return Result; }(); diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index c10188b83fc15..43bb9bc64c438 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -107,7 +107,7 @@ cl_context context_impl::get() const { if (MHostContext) { throw invalid_object_error( "This instance of context doesn't support OpenCL interoperability.", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); } // TODO catch an exception and put it to list of asynchronous exceptions getPlugin().call(MContext); diff --git a/sycl/source/detail/device_filter.cpp b/sycl/source/detail/device_filter.cpp index f1a12d8fd5ac2..67cc128331529 100644 --- a/sycl/source/detail/device_filter.cpp +++ b/sycl/source/detail/device_filter.cpp @@ -94,7 +94,7 @@ device_filter::device_filter(const std::string &FilterString) { "{host,opencl,level_zero,cuda,hip,esimd_emulator,*}.\n" "Possible device types are {host,cpu,gpu,acc,*}.\n" "Device number should be an non-negative integer.\n"; - throw cl::sycl::invalid_parameter_error(Message, PI_INVALID_VALUE); + throw cl::sycl::invalid_parameter_error(Message, PI_ERROR_INVALID_VALUE); } } } diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 38d843a7743a0..2232e9063ce99 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -95,7 +95,7 @@ cl_device_id device_impl::get() const { if (MIsHostDevice) { throw invalid_object_error( "This instance of device doesn't support OpenCL interoperability.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } // TODO catch an exception and put it to list of asynchronous exceptions getPlugin().call(MDevice); @@ -158,7 +158,7 @@ std::vector device_impl::create_sub_devices(size_t ComputeUnits) const { // TODO: implement host device partitioning throw runtime_error( "Partitioning to subdevices of the host device is not implemented yet", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); if (!is_partition_supported(info::partition_property::partition_equally)) { throw cl::sycl::feature_not_supported(); @@ -184,7 +184,7 @@ device_impl::create_sub_devices(const std::vector &Counts) const { // TODO: implement host device partitioning throw runtime_error( "Partitioning to subdevices of the host device is not implemented yet", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); if (!is_partition_supported(info::partition_property::partition_by_counts)) { throw cl::sycl::feature_not_supported(); @@ -229,7 +229,7 @@ std::vector device_impl::create_sub_devices( // TODO: implement host device partitioning throw runtime_error( "Partitioning to subdevices of the host device is not implemented yet", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); if (!is_partition_supported( info::partition_property::partition_by_affinity_domain) || @@ -376,7 +376,7 @@ bool device_impl::has(aspect Aspect) const { } default: throw runtime_error("This device aspect has not been implemented yet.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } } diff --git a/sycl/source/detail/device_impl.hpp b/sycl/source/detail/device_impl.hpp index 91af40d86b3e5..7f0046cd3f0a6 100644 --- a/sycl/source/detail/device_impl.hpp +++ b/sycl/source/detail/device_impl.hpp @@ -63,7 +63,7 @@ class device_impl { RT::PiDevice &getHandleRef() { if (MIsHostDevice) throw invalid_object_error("This instance of device is a host instance", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); return MDevice; } @@ -76,7 +76,7 @@ class device_impl { const RT::PiDevice &getHandleRef() const { if (MIsHostDevice) throw invalid_object_error("This instance of device is a host instance", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); return MDevice; } diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 9193825c9f4ba..3543ae296a605 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -557,7 +557,7 @@ template <> struct get_device_info { if (result == nullptr) throw invalid_object_error( "No parent for device because it is not a subdevice", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); // Get the platform of this device std::shared_ptr Platform = @@ -1068,7 +1068,7 @@ template <> inline device get_device_info_host() { // TODO: implement host device partitioning throw invalid_object_error( "Partitioning to subdevices of the host device is not implemented yet", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> @@ -1114,7 +1114,7 @@ template <> inline cl_uint get_device_info_host() { // TODO update once subgroups are enabled throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> @@ -1122,7 +1122,7 @@ inline std::vector get_device_info_host() { // TODO update once subgroups are enabled throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> @@ -1130,7 +1130,7 @@ inline bool get_device_info_host() { // TODO update once subgroups are enabled throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> @@ -1142,7 +1142,7 @@ template <> inline std::string get_device_info_host() { throw runtime_error( "Backend version feature is not supported on HOST device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> @@ -1260,53 +1260,53 @@ template <> inline std::string get_device_info_host() { throw runtime_error( "Obtaining the PCI address is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error("Obtaining the EU count is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the EU SIMD width is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the number of slices is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error("Obtaining the number of subslices per slice is not " "supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the EU count per subslice is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_uint get_device_info_host() { throw runtime_error( "Obtaining the HW threads count per EU is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline cl_ulong get_device_info_host() { throw runtime_error( "Obtaining the maximum memory bandwidth is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } template <> inline bool get_device_info_host() { return false; @@ -1317,7 +1317,7 @@ inline detail::uuid_type get_device_info_host() { throw runtime_error( "Obtaining the device uuid is not supported on HOST device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } } // namespace detail diff --git a/sycl/source/detail/error_handling/enqueue_kernel.cpp b/sycl/source/detail/error_handling/enqueue_kernel.cpp index c72f683cd89cc..f2a2f649e5f7d 100644 --- a/sycl/source/detail/error_handling/enqueue_kernel.cpp +++ b/sycl/source/detail/error_handling/enqueue_kernel.cpp @@ -44,7 +44,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, std::to_string(MaxThreadsPerBlock[0]) + ", " + std::to_string(MaxThreadsPerBlock[1]) + ", " + std::to_string(MaxThreadsPerBlock[2]) + "} for this device", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } } } @@ -68,17 +68,17 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, if (CompileWGSize[0] != 0) { // OpenCL 1.x && 2.0: - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is NULL and the + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is NULL and the // reqd_work_group_size attribute is used to declare the work-group size // for kernel in the program source. if (!HasLocalSize && (IsOpenCLV1x || IsOpenCLV20)) { throw sycl::nd_range_error( "OpenCL 1.x and 2.0 requires to pass local size argument even if " "required work-group size was specified in the program source", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and does not - // match the required work-group size for kernel in the program source. + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and does + // not match the required work-group size for kernel in the program source. if (NDRDesc.LocalSize[0] != CompileWGSize[0] || NDRDesc.LocalSize[1] != CompileWGSize[1] || NDRDesc.LocalSize[2] != CompileWGSize[2]) @@ -91,13 +91,13 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, std::to_string(CompileWGSize[0]) + ", " + std::to_string(CompileWGSize[1]) + ", " + std::to_string(CompileWGSize[2]) + "}", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } if (IsOpenCL) { if (IsOpenCLV1x) { // OpenCL 1.x: - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the - // total number of work-items in the work-group computed as + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and + // the total number of work-items in the work-group computed as // local_work_size[0] * ... * local_work_size[work_dim - 1] is greater // than the value specified by PI_DEVICE_MAX_WORK_GROUP_SIZE in // table 4.3 @@ -111,11 +111,11 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, throw sycl::nd_range_error( "Total number of work-items in a work-group cannot exceed " + std::to_string(MaxWGSize), - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } else { // OpenCL 2.x: - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the - // total number of work-items in the work-group computed as + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and + // the total number of work-items in the work-group computed as // local_work_size[0] * ... * local_work_size[work_dim - 1] is greater // than the value specified by PI_KERNEL_GROUP_INFO_WORK_GROUP_SIZE in // table 5.21. @@ -129,7 +129,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, throw sycl::nd_range_error( "Total number of work-items in a work-group cannot exceed " + std::to_string(KernelWGSize) + " for this kernel", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } } else { // TODO: Should probably have something similar for the other backends @@ -155,22 +155,22 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, if (NonUniformWGs) { if (IsOpenCLV1x) { // OpenCL 1.x: - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and - // number of workitems specified by global_work_size is not evenly + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified + // and number of workitems specified by global_work_size is not evenly // divisible by size of work-group given by local_work_size if (LocalExceedsGlobal) throw sycl::nd_range_error("Local workgroup size cannot be greater " "than global range in any dimension", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); else throw sycl::nd_range_error( "Global_work_size must be evenly divisible by local_work_size. " "Non-uniform work-groups are not supported by the target " "device", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } else { // OpenCL 2.x: - // PI_INVALID_WORK_GROUP_SIZE if the program was compiled with + // PI_ERROR_INVALID_WORK_GROUP_SIZE if the program was compiled with // –cl-uniform-work-group-size and the number of work-items specified // by global_work_size is not evenly divisible by size of work-group // given by local_work_size @@ -214,7 +214,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, "OpenCL 2.x implementation supports this feature " "and to enable " "it, build device program with -cl-std=CL2.0"), - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); else if (RequiresUniformWGSize) throw sycl::nd_range_error( message.append( @@ -224,7 +224,7 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, "is " "being " "disabled by -cl-uniform-work-group-size build flag"), - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); // else unknown. fallback (below) } } @@ -233,15 +233,15 @@ void handleInvalidWorkGroupSize(const device_impl &DeviceImpl, pi_kernel Kernel, } throw sycl::nd_range_error( "Non-uniform work-groups are not supported by the target device", - PI_INVALID_WORK_GROUP_SIZE); + PI_ERROR_INVALID_WORK_GROUP_SIZE); } // TODO: required number of sub-groups, OpenCL 2.1: - // PI_INVALID_WORK_GROUP_SIZE if local_work_size is specified and is not + // PI_ERROR_INVALID_WORK_GROUP_SIZE if local_work_size is specified and is not // consistent with the required number of sub-groups for kernel in the // program source. // Fallback - constexpr pi_result Error = PI_INVALID_WORK_GROUP_SIZE; + constexpr pi_result Error = PI_ERROR_INVALID_WORK_GROUP_SIZE; throw runtime_error( "PI backend failed. PI backend returns: " + codeToString(Error), Error); } @@ -263,7 +263,7 @@ void handleInvalidWorkItemSize(const device_impl &DeviceImpl, "Number of work-items in a work-group exceed limit for dimension " + std::to_string(I) + " : " + std::to_string(NDRDesc.LocalSize[I]) + " > " + std::to_string(MaxWISize[I]), - PI_INVALID_WORK_ITEM_SIZE); + PI_ERROR_INVALID_WORK_ITEM_SIZE); } } @@ -283,11 +283,11 @@ void handleInvalidValue(const device_impl &DeviceImpl, "Number of work-groups exceed limit for dimension " + std::to_string(I) + " : " + std::to_string(NWgs) + " > " + std::to_string(MaxNWGs[I]), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } // fallback - constexpr pi_result Error = PI_INVALID_VALUE; + constexpr pi_result Error = PI_ERROR_INVALID_VALUE; throw runtime_error( "Native API failed. Native API returns: " + codeToString(Error), Error); } @@ -297,57 +297,57 @@ void handleErrorOrWarning(pi_result Error, const device_impl &DeviceImpl, assert(Error != PI_SUCCESS && "Success is expected to be handled on caller side"); switch (Error) { - case PI_INVALID_WORK_GROUP_SIZE: + case PI_ERROR_INVALID_WORK_GROUP_SIZE: return handleInvalidWorkGroupSize(DeviceImpl, Kernel, NDRDesc); - case PI_INVALID_KERNEL_ARGS: + case PI_ERROR_INVALID_KERNEL_ARGS: throw sycl::nd_range_error( "The kernel argument values have not been specified " " OR " "a kernel argument declared to be a pointer to a type.", - PI_INVALID_KERNEL_ARGS); + PI_ERROR_INVALID_KERNEL_ARGS); - case PI_INVALID_WORK_ITEM_SIZE: + case PI_ERROR_INVALID_WORK_ITEM_SIZE: return handleInvalidWorkItemSize(DeviceImpl, NDRDesc); - case PI_IMAGE_FORMAT_NOT_SUPPORTED: + case PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: throw sycl::nd_range_error( "image object is specified as an argument value" " and the image format is not supported by device associated" " with queue", - PI_IMAGE_FORMAT_NOT_SUPPORTED); + PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED); - case PI_MISALIGNED_SUB_BUFFER_OFFSET: + case PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: throw sycl::nd_range_error( "a sub-buffer object is specified as the value for an argument " " that is a buffer object and the offset specified " "when the sub-buffer object is created is not aligned " "to CL_DEVICE_MEM_BASE_ADDR_ALIGN value for device associated" " with queue", - PI_MISALIGNED_SUB_BUFFER_OFFSET); + PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET); - case PI_MEM_OBJECT_ALLOCATION_FAILURE: + case PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: throw sycl::nd_range_error( "failure to allocate memory for data store associated with image" " or buffer objects specified as arguments to kernel", - PI_MEM_OBJECT_ALLOCATION_FAILURE); + PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE); - case PI_INVALID_IMAGE_SIZE: + case PI_ERROR_INVALID_IMAGE_SIZE: throw sycl::nd_range_error( "image object is specified as an argument value and the image " "dimensions (image width, height, specified or compute row and/or " "slice pitch) are not supported by device associated with queue", - PI_INVALID_IMAGE_SIZE); + PI_ERROR_INVALID_IMAGE_SIZE); - case PI_INVALID_VALUE: + case PI_ERROR_INVALID_VALUE: return handleInvalidValue(DeviceImpl, NDRDesc); - case PI_PLUGIN_SPECIFIC_ERROR: + case PI_ERROR_PLUGIN_SPECIFIC_ERROR: // checkPiResult does all the necessary handling for - // PI_PLUGIN_SPECIFIC_ERROR, making sure an error is thrown or not, - // depending on whether PI_PLUGIN_SPECIFIC_ERROR contains an error or a - // warning. It also ensures that the contents of the error message buffer - // (used only by PI_PLUGIN_SPECIFIC_ERROR) get handled correctly. + // PI_ERROR_PLUGIN_SPECIFIC_ERROR, making sure an error is thrown or not, + // depending on whether PI_ERROR_PLUGIN_SPECIFIC_ERROR contains an error or + // a warning. It also ensures that the contents of the error message buffer + // (used only by PI_ERROR_PLUGIN_SPECIFIC_ERROR) get handled correctly. return DeviceImpl.getPlugin().checkPiResult(Error); // TODO: Handle other error codes diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 32476dcf926a4..9c49dc0b0636c 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -39,7 +39,7 @@ cl_event event_impl::get() const { if (!MOpenCLInterop) { throw invalid_object_error( "This instance of event doesn't support OpenCL interoperability.", - PI_INVALID_EVENT); + PI_ERROR_INVALID_EVENT); } getPlugin().call(MEvent); return pi::cast(MEvent); @@ -110,7 +110,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " "clEvent.", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); } RT::PiContext TempContext; @@ -121,7 +121,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " "clEvent.", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); } } @@ -134,7 +134,7 @@ event_impl::event_impl(const QueueImplPtr &Queue) if (Queue->has_property()) { MHostProfilingInfo.reset(new HostProfilingInfo()); if (!MHostProfilingInfo) - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); } return; } @@ -269,7 +269,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_PROFILING_INFO_NOT_AVAILABLE); + PI_ERROR_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getStartTime(); } @@ -286,7 +286,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_PROFILING_INFO_NOT_AVAILABLE); + PI_ERROR_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getStartTime(); } @@ -302,7 +302,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_PROFILING_INFO_NOT_AVAILABLE); + PI_ERROR_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getEndTime(); } diff --git a/sycl/source/detail/filter_selector_impl.cpp b/sycl/source/detail/filter_selector_impl.cpp index e6dc012280aac..1adfee4316c3a 100644 --- a/sycl/source/detail/filter_selector_impl.cpp +++ b/sycl/source/detail/filter_selector_impl.cpp @@ -59,7 +59,7 @@ filter create_filter(const std::string &Input) { // There should only be up to 3 tokens. // BE:Device Type:Device Num if (Tokens.size() > 3) - throw sycl::runtime_error(Error, PI_INVALID_VALUE); + throw sycl::runtime_error(Error, PI_ERROR_INVALID_VALUE); for (const std::string &Token : Tokens) { if (Token == "cpu" && !Result.HasDeviceType) { @@ -91,17 +91,17 @@ filter create_filter(const std::string &Input) { // We already set everything earlier or it's an error. throw sycl::runtime_error( "Cannot specify host device with non-host backend.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } } else if (std::regex_match(Token, IntegerExpr) && !Result.HasDeviceNum) { try { Result.DeviceNum = std::stoi(Token); } catch (std::logic_error &) { - throw sycl::runtime_error(Error, PI_INVALID_VALUE); + throw sycl::runtime_error(Error, PI_ERROR_INVALID_VALUE); } Result.HasDeviceNum = true; } else { - throw sycl::runtime_error(Error, PI_INVALID_VALUE); + throw sycl::runtime_error(Error, PI_ERROR_INVALID_VALUE); } } @@ -169,7 +169,7 @@ int filter_selector_impl::operator()(const device &Dev) const { if ((mNumDevicesSeen == mNumTotalDevices) && !mMatchFound) { throw sycl::runtime_error( "Could not find a device that matches the specified filter(s)!", - PI_DEVICE_NOT_FOUND); + PI_ERROR_DEVICE_NOT_FOUND); } return Score; diff --git a/sycl/source/detail/force_device.cpp b/sycl/source/detail/force_device.cpp index 052d6bbd1fb25..6a8fb6646febc 100644 --- a/sycl/source/detail/force_device.cpp +++ b/sycl/source/detail/force_device.cpp @@ -40,7 +40,7 @@ info::device_type get_forced_type() { } throw cl::sycl::runtime_error("SYCL_DEVICE_TYPE is not recognized. Must " "be GPU, CPU, ACC or HOST.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } return info::device_type::all; } diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index c4fbfa8dba28e..2150fa2e66b22 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -330,7 +330,7 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error( "For a 1D/2D image/image array, the width must be a Value >= 1 and " "<= info::device::image2d_max_width", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange( @@ -338,7 +338,7 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error( "For a 3D image, the width must be a Value >= 1 and <= " "info::device::image3d_max_width", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE2D, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -347,7 +347,7 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error("For a 2D image or image array, the height " "must be a Value >= 1 and <= " "info::device::image2d_max_height", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange( @@ -355,7 +355,7 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error( "For a 3D image, the heightmust be a Value >= 1 and <= " "info::device::image3d_max_height", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange( @@ -363,7 +363,7 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error( "For a 3D image, the depth must be a Value >= 1 and <= " "info::device::image2d_max_depth", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE1D_ARRAY, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -372,29 +372,31 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, throw invalid_parameter_error( "For a 1D and 2D image array, the array_size must be a " "Value >= 1 and <= info::device::image_max_array_size.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if ((nullptr == UserPtr) && (0 != Desc.image_row_pitch)) throw invalid_parameter_error( - "The row_pitch must be 0 if host_ptr is nullptr.", PI_INVALID_VALUE); + "The row_pitch must be 0 if host_ptr is nullptr.", + PI_ERROR_INVALID_VALUE); if ((nullptr == UserPtr) && (0 != Desc.image_slice_pitch)) throw invalid_parameter_error( - "The slice_pitch must be 0 if host_ptr is nullptr.", PI_INVALID_VALUE); + "The slice_pitch must be 0 if host_ptr is nullptr.", + PI_ERROR_INVALID_VALUE); if (0 != Desc.num_mip_levels) throw invalid_parameter_error("The mip_levels must be 0.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (0 != Desc.num_samples) throw invalid_parameter_error("The num_samples must be 0.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (nullptr != Desc.buffer) throw invalid_parameter_error( "The buffer must be nullptr, because SYCL does not support " "image creation from memory objects.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return true; } @@ -414,7 +416,7 @@ bool image_impl::checkImageFormat( "CL_INTENSITY or CL_LUMINANCE format can only be used if channel " "data type = CL_UNORM_INT8, CL_UNORM_INT16, CL_SNORM_INT8, " "CL_SNORM_INT16, CL_HALF_FLOAT, or CL_FLOAT.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Format.image_channel_data_type, PI_IMAGE_CHANNEL_TYPE_UNORM_SHORT_565, @@ -427,7 +429,7 @@ bool image_impl::checkImageFormat( "CL_UNORM_INT_101010." "These channel types can only be used with CL_RGB or CL_RGBx channel " "order.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (checkAny(Format.image_channel_order, PI_IMAGE_CHANNEL_ORDER_ARGB, PI_IMAGE_CHANNEL_ORDER_BGRA, PI_IMAGE_CHANNEL_ORDER_ABGR) && @@ -439,7 +441,7 @@ bool image_impl::checkImageFormat( "CL_ARGB, CL_BGRA, CL_ABGR These formats can only be used if " "channel data type = CL_UNORM_INT8, CL_SNORM_INT8, CL_SIGNED_INT8 " "or CL_UNSIGNED_INT8.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); return true; } diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index cc8bf4b38249f..2e0d19295a84b 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -146,7 +146,7 @@ class kernel_bundle_impl { case bundle_state::input: throw sycl::runtime_error( "Internal error. The target state should not be input", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); break; } } diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 653d750f34b86..8d981e37f0fd5 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -50,7 +50,7 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl, if (ContextImpl->getHandleRef() != Context) throw cl::sycl::invalid_parameter_error( "Input context must be the same as the context of cl_kernel", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); MIsInterop = MProgramImpl->isInterop(); } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index d1d71b1339526..7696bf8a0a8a1 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -100,7 +100,7 @@ class kernel_impl { if (is_host()) { throw invalid_object_error( "This instance of kernel doesn't support OpenCL interoperability.", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } getPlugin().call(MKernel); return pi::cast(MKernel); @@ -263,7 +263,7 @@ kernel_impl::get_info( Value) const { if (is_host()) { throw runtime_error("Sub-group feature is not supported on HOST device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); } return get_kernel_device_specific_info_with_input::get( this->getHandleRef(), getSyclObjImpl(Device)->getHandleRef(), Value, diff --git a/sycl/source/detail/kernel_info.hpp b/sycl/source/detail/kernel_info.hpp index 6ada88952cf1d..3d82b850ae98b 100644 --- a/sycl/source/detail/kernel_info.hpp +++ b/sycl/source/detail/kernel_info.hpp @@ -115,7 +115,7 @@ template <> inline cl::sycl::range<3> get_kernel_device_specific_info_host< info::kernel_device_specific::global_work_size>(const cl::sycl::device &) { throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } template <> @@ -158,7 +158,7 @@ inline uint32_t get_kernel_device_specific_info_host< info::kernel_device_specific::max_num_sub_groups>( const cl::sycl::device &) { throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } template <> @@ -166,7 +166,7 @@ inline uint32_t get_kernel_device_specific_info_host< info::kernel_device_specific::compile_num_sub_groups>( const cl::sycl::device &) { throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } template <> @@ -174,7 +174,7 @@ inline uint32_t get_kernel_device_specific_info_host< info::kernel_device_specific::compile_sub_group_size>( const cl::sycl::device &) { throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_KERNEL); + PI_ERROR_INVALID_KERNEL); } template diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 2a966439776ca..134567de154c1 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -248,7 +248,8 @@ void MemoryManager::releaseImageBuffer(ContextImplPtr TargetContext, (void)TargetContext; (void)ImageBuf; // TODO remove when ABI breaking changes are allowed. - throw runtime_error("Deprecated release operation", PI_INVALID_OPERATION); + throw runtime_error("Deprecated release operation", + PI_ERROR_INVALID_OPERATION); } void MemoryManager::releaseMemObj(ContextImplPtr TargetContext, @@ -287,7 +288,8 @@ void *MemoryManager::wrapIntoImageBuffer(ContextImplPtr TargetContext, (void)MemBuf; (void)MemObj; // TODO remove when ABI breaking changes are allowed. - throw runtime_error("Deprecated allocation operation", PI_INVALID_OPERATION); + throw runtime_error("Deprecated allocation operation", + PI_ERROR_INVALID_OPERATION); } void *MemoryManager::allocateHostMemory(SYCLMemObjI *MemObj, void *UserPtr, @@ -439,11 +441,11 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, Error = Plugin.call_nocheck( pi::cast(ParentMemObj), PI_MEM_FLAGS_ACCESS_RW, PI_BUFFER_CREATE_TYPE_REGION, &Region, &NewMem); - if (Error == PI_MISALIGNED_SUB_BUFFER_OFFSET) + 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_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (Error != PI_SUCCESS) { Plugin.reportPiError(Error, "allocateMemSubBuffer()"); @@ -715,7 +717,7 @@ static void copyH2H(SYCLMemObjI *, char *SrcMem, QueueImplPtr, (SrcOffset != id<3>{0, 0, 0} || DstOffset != id<3>{0, 0, 0} || SrcSize != SrcAccessRange || DstSize != DstAccessRange)) { throw runtime_error("Not supported configuration of memcpy requested", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } SrcMem += SrcOffset[0] * SrcElemSize; @@ -789,7 +791,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, return; } throw runtime_error("Not supported configuration of fill requested", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } else { Plugin.call( Queue->getHandleRef(), pi::cast(Mem), Pattern, &Offset[0], @@ -805,7 +807,7 @@ void *MemoryManager::map(SYCLMemObjI *, void *Mem, QueueImplPtr Queue, RT::PiEvent &OutEvent) { if (Queue->is_host()) { throw runtime_error("Not supported configuration of map requested", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } pi_map_flags Flags = 0; @@ -872,7 +874,7 @@ void MemoryManager::copy_usm(const void *SrcMem, QueueImplPtr SrcQueue, if (!SrcMem || !DstMem) throw runtime_error("NULL pointer argument in memory copy operation.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (Context.is_host()) { std::memcpy(DstMem, SrcMem, Len); @@ -900,7 +902,7 @@ void MemoryManager::fill_usm(void *Mem, QueueImplPtr Queue, size_t Length, if (!Mem) throw runtime_error("NULL pointer argument in memory fill operation.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); if (Context.is_host()) { std::memset(Mem, Pattern, Length); diff --git a/sycl/source/detail/persistent_device_code_cache.cpp b/sycl/source/detail/persistent_device_code_cache.cpp index da72e49d0a213..698e967a37c12 100644 --- a/sycl/source/detail/persistent_device_code_cache.cpp +++ b/sycl/source/detail/persistent_device_code_cache.cpp @@ -374,7 +374,7 @@ static bool parsePersistentCacheConfig() { std::string{"Invalid value for bool configuration variable "} + SYCLConfig::getName() + std::string{": "} + RawVal; - throw runtime_error(Msg, PI_INVALID_OPERATION); + throw runtime_error(Msg, PI_ERROR_INVALID_OPERATION); } } PersistentDeviceCodeCache::trace(Ret ? "enabled" : "disabled"); diff --git a/sycl/source/detail/pi.cpp b/sycl/source/detail/pi.cpp index 34f830de3cacc..abd052f035ec6 100644 --- a/sycl/source/detail/pi.cpp +++ b/sycl/source/detail/pi.cpp @@ -521,7 +521,7 @@ template const plugin &getPlugin() { } throw runtime_error("pi::getPlugin couldn't find plugin", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } template __SYCL_EXPORT const plugin &getPlugin(); diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index bb2343f57d653..248a3b9340b3e 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -80,7 +80,7 @@ class platform_impl { if (is_host()) { throw invalid_object_error( "This instance of platform doesn't support OpenCL interoperability.", - PI_INVALID_PLATFORM); + PI_ERROR_INVALID_PLATFORM); } return pi::cast(MPlatform); } @@ -95,7 +95,7 @@ class platform_impl { const RT::PiPlatform &getHandleRef() const { if (is_host()) throw invalid_object_error("This instance of platform is a host instance", - PI_INVALID_PLATFORM); + PI_ERROR_INVALID_PLATFORM); return MPlatform; } diff --git a/sycl/source/detail/platform_util.cpp b/sycl/source/detail/platform_util.cpp index 1ba46fd66aef3..9c3afa41c1a11 100644 --- a/sycl/source/detail/platform_util.cpp +++ b/sycl/source/detail/platform_util.cpp @@ -38,7 +38,7 @@ static void cpuid(uint32_t *CPUInfo, uint32_t Type, uint32_t SubType = 0) { uint32_t PlatformUtil::getMaxClockFrequency() { throw runtime_error( "max_clock_frequency parameter is not supported for host device", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); #if defined(__x86_64__) || defined(__i386__) uint32_t CPUInfo[4]; std::string Buff(sizeof(CPUInfo) * 3 + 1, 0); diff --git a/sycl/source/detail/plugin.hpp b/sycl/source/detail/plugin.hpp index 34787a22e746a..ef67ec261bc6d 100644 --- a/sycl/source/detail/plugin.hpp +++ b/sycl/source/detail/plugin.hpp @@ -115,7 +115,7 @@ class plugin { template void checkPiResult(RT::PiResult pi_result) const { char *message = nullptr; - if (pi_result == PI_PLUGIN_SPECIFIC_ERROR) { + if (pi_result == PI_ERROR_PLUGIN_SPECIFIC_ERROR) { pi_result = call_nocheck(&message); // If the warning level is greater then 2 emit the message @@ -131,7 +131,7 @@ class plugin { /// \throw SYCL 2020 exception(errc) if pi_result is not PI_SUCCESS template void checkPiResult(RT::PiResult pi_result) const { - if (pi_result == PI_PLUGIN_SPECIFIC_ERROR) { + if (pi_result == PI_ERROR_PLUGIN_SPECIFIC_ERROR) { char *message = nullptr; pi_result = call_nocheck(&message); diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index e05fa6088301a..66c8b7f152f5e 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -39,7 +39,7 @@ program_impl::program_impl(ContextImplPtr Context, throw feature_not_supported( "multiple devices within a context are not supported with " "sycl::program and sycl::kernel", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } } @@ -51,7 +51,7 @@ program_impl::program_impl( // Verify arguments if (ProgramList.empty()) { throw runtime_error("Non-empty vector of programs expected", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } // Sort the programs to avoid deadlocks due to locking multiple mutexes & @@ -60,7 +60,7 @@ program_impl::program_impl( auto It = std::unique(ProgramList.begin(), ProgramList.end()); if (It != ProgramList.end()) { throw runtime_error("Attempting to link a program with itself", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } MContext = ProgramList[0]->MContext; @@ -68,7 +68,7 @@ program_impl::program_impl( throw feature_not_supported( "multiple devices within a context are not supported with " "sycl::program and sycl::kernel", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } MDevices = ProgramList[0]->MDevices; std::vector DevicesSorted; @@ -83,7 +83,7 @@ program_impl::program_impl( if (Prg->MContext != MContext) { throw invalid_object_error( "Not all programs are associated with the same context", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } if (!is_host()) { std::vector PrgDevicesSorted = @@ -91,7 +91,7 @@ program_impl::program_impl( if (PrgDevicesSorted != DevicesSorted) { throw invalid_object_error( "Not all programs are associated with the same devices", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } } } @@ -164,21 +164,21 @@ program_impl::program_impl(ContextImplPtr Context, // TODO check build for each device instead cl_program_binary_type BinaryType; Plugin.call( - MProgram, Device, CL_PROGRAM_BINARY_TYPE, sizeof(cl_program_binary_type), - &BinaryType, nullptr); + MProgram, Device, PI_PROGRAM_BUILD_INFO_BINARY_TYPE, + sizeof(cl_program_binary_type), &BinaryType, nullptr); if (BinaryType == CL_PROGRAM_BINARY_TYPE_NONE) { throw invalid_object_error( "The native program passed to the program constructor has to be either " "compiled or linked", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } size_t Size = 0; Plugin.call( - MProgram, Device, CL_PROGRAM_BUILD_OPTIONS, 0, nullptr, &Size); + MProgram, Device, PI_PROGRAM_BUILD_INFO_OPTIONS, 0, nullptr, &Size); std::vector OptionsVector(Size); - Plugin.call(MProgram, Device, - CL_PROGRAM_BUILD_OPTIONS, Size, - OptionsVector.data(), nullptr); + Plugin.call( + MProgram, Device, PI_PROGRAM_BUILD_INFO_OPTIONS, Size, + OptionsVector.data(), nullptr); std::string Options(OptionsVector.begin(), OptionsVector.end()); switch (BinaryType) { case CL_PROGRAM_BINARY_TYPE_NONE: @@ -217,7 +217,7 @@ cl_program program_impl::get() const { if (is_host()) { throw invalid_object_error( "This instance of program doesn't support OpenCL interoperability.", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } getPlugin().call(MProgram); return pi::cast(MProgram); @@ -319,12 +319,13 @@ bool program_impl::has_kernel(std::string KernelName, for (RT::PiDevice Device : Devices) { Err = Plugin.call_nocheck( Device, MProgram, KernelName.c_str(), &function_ptr); - if (Err != PI_SUCCESS && Err != PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE && - Err != PI_INVALID_KERNEL_NAME) + if (Err != PI_SUCCESS && + Err != PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE && + Err != PI_ERROR_INVALID_KERNEL_NAME) throw runtime_error( "Error from piextGetDeviceFunctionPointer when called by program", Err); - if (Err == PI_SUCCESS || Err == PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE) + if (Err == PI_SUCCESS || Err == PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE) return true; } @@ -338,7 +339,7 @@ kernel program_impl::get_kernel(std::string KernelName, if (is_host()) { if (IsCreatedFromSource) throw invalid_object_error("This instance of program is a host instance", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); return createSyclObjFromImpl( std::make_shared(MContext, PtrToSelf)); @@ -380,10 +381,10 @@ void program_impl::create_cl_program_with_source(const std::string &Source) { Plugin.call_nocheck( MContext->getHandleRef(), 1, &Src, &Size, &MProgram); - if (Err == PI_INVALID_OPERATION) { + if (Err == PI_ERROR_INVALID_OPERATION) { throw feature_not_supported( "program::compile_with_source is not supported by the selected backend", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } if (Err != PI_SUCCESS) { @@ -452,7 +453,7 @@ RT::PiKernel program_impl::get_pi_kernel(const std::string &KernelName) const { const detail::plugin &Plugin = getPlugin(); RT::PiResult Err = Plugin.call_nocheck( MProgram, KernelName.c_str(), &Kernel); - if (Err == PI_INVALID_KERNEL_NAME) { + if (Err == PI_ERROR_INVALID_KERNEL_NAME) { throw invalid_object_error( "This instance of program does not contain the kernel requested", Err); @@ -480,13 +481,15 @@ program_impl::sort_devices_by_cl_device_id(std::vector Devices) { void program_impl::throw_if_state_is(program_state State) const { if (MState == State) { - throw invalid_object_error("Invalid program state", PI_INVALID_PROGRAM); + throw invalid_object_error("Invalid program state", + PI_ERROR_INVALID_PROGRAM); } } void program_impl::throw_if_state_is_not(program_state State) const { if (MState != State) { - throw invalid_object_error("Invalid program state", PI_INVALID_PROGRAM); + throw invalid_object_error("Invalid program state", + PI_ERROR_INVALID_PROGRAM); } } @@ -505,7 +508,7 @@ template <> cl_uint program_impl::get_info() const { if (is_host()) { throw invalid_object_error("This instance of program is a host instance", - PI_INVALID_PROGRAM); + PI_ERROR_INVALID_PROGRAM); } pi_uint32 Result; const detail::plugin &Plugin = getPlugin(); @@ -528,7 +531,7 @@ void program_impl::set_spec_constant_impl(const char *Name, const void *ValAddr, size_t ValSize) { if (MState != program_state::none) throw cl::sycl::ext::oneapi::experimental::spec_const_error( - "Invalid program state", PI_INVALID_PROGRAM); + "Invalid program state", PI_ERROR_INVALID_PROGRAM); // Reuse cached programs lock as opposed to introducing a new lock. auto LockGuard = MContext->getKernelProgramCache().acquireCachedPrograms(); spec_constant_impl &SC = SpecConstRegistry[Name]; diff --git a/sycl/source/detail/program_impl.hpp b/sycl/source/detail/program_impl.hpp index fb5ad5e7daddb..a94924ad73545 100644 --- a/sycl/source/detail/program_impl.hpp +++ b/sycl/source/detail/program_impl.hpp @@ -364,7 +364,7 @@ class program_impl { if (!Device.get_info()) { throw feature_not_supported( "Online compilation is not supported by this device", - PI_COMPILER_NOT_AVAILABLE); + PI_ERROR_COMPILER_NOT_AVAILABLE); } } } diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index d98f0b86dcbb5..660b4462b3d96 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -315,11 +315,11 @@ RT::PiProgram ProgramManager::createPIProgram(const RTDeviceBinaryImage &Img, // perform minimal sanity checks on the device image and the descriptor if (RawImg.BinaryEnd < RawImg.BinaryStart) { throw runtime_error("Malformed device program image descriptor", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } if (RawImg.BinaryEnd == RawImg.BinaryStart) { throw runtime_error("Invalid device program image: size is zero", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } size_t ImgSize = Img.getSize(); @@ -339,7 +339,7 @@ RT::PiProgram ProgramManager::createPIProgram(const RTDeviceBinaryImage &Img, if (!isDeviceBinaryTypeSupported(Context, Format)) throw feature_not_supported( "SPIR-V online compilation is not supported in this context", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); // Get program metadata from properties auto ProgMetadata = Img.getProgramMetadata(); @@ -689,12 +689,12 @@ std::string ProgramManager::getProgramBuildLog(const RT::PiProgram &Program, std::string DeviceBuildInfoString; size_t DeviceBuildInfoStrSize = 0; Plugin.call( - Program, Device, CL_PROGRAM_BUILD_LOG, 0, nullptr, + Program, Device, PI_PROGRAM_BUILD_INFO_LOG, 0, nullptr, &DeviceBuildInfoStrSize); if (DeviceBuildInfoStrSize > 0) { std::vector DeviceBuildInfo(DeviceBuildInfoStrSize); Plugin.call( - Program, Device, CL_PROGRAM_BUILD_LOG, DeviceBuildInfoStrSize, + Program, Device, PI_PROGRAM_BUILD_INFO_LOG, DeviceBuildInfoStrSize, DeviceBuildInfo.data(), nullptr); DeviceBuildInfoString = std::string(DeviceBuildInfo.data()); } @@ -756,7 +756,7 @@ static const char *getDeviceLibFilename(DeviceLibExt Extension) { return "libsycl-fallback-cstring.spv"; } throw compile_program_error("Unhandled (new?) device library extension", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { @@ -775,7 +775,7 @@ static const char *getDeviceLibExtensionStr(DeviceLibExt Extension) { return "cl_intel_devicelib_cstring"; } throw compile_program_error("Unhandled (new?) device library extension", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } static RT::PiProgram loadDeviceLibFallback(const ContextImplPtr Context, @@ -798,7 +798,7 @@ static RT::PiProgram loadDeviceLibFallback(const ContextImplPtr Context, if (!loadDeviceLib(Context, LibFileName, LibProg)) { CachedLibPrograms.erase(LibProgIt); throw compile_program_error(std::string("Failed to load ") + LibFileName, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } const detail::plugin &Plugin = Context->getPlugin(); @@ -833,7 +833,7 @@ ProgramManager::ProgramManager() { if (!File.is_open()) throw runtime_error(std::string("Can't open file specified via ") + UseSpvEnv + ": " + SpvFile, - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); File.seekg(0, std::ios::end); size_t Size = File.tellg(); std::unique_ptr Data(new char[Size]); @@ -843,7 +843,7 @@ ProgramManager::ProgramManager() { if (!File.good()) throw runtime_error(std::string("read from ") + SpvFile + std::string(" failed"), - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); auto ImgPtr = make_unique_ptr( std::move(Data), Size, OSUtil::DummyModuleHandle); @@ -903,7 +903,7 @@ ProgramManager::getDeviceImage(OSModuleHandle M, KernelSetId KSId, (strcmp(RawImg.DeviceTargetSpec, __SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA) == 0)) { throw feature_not_supported("Recompiling AOT image is not supported", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } } @@ -1295,7 +1295,7 @@ ProgramManager::getKernelSetId(OSModuleHandle M, return ModuleKSIdIt->second; throw runtime_error("No kernel named " + KernelName + " was found", - PI_INVALID_KERNEL_NAME); + PI_ERROR_INVALID_KERNEL_NAME); } void ProgramManager::dumpImage(const RTDeviceBinaryImage &Img, @@ -1346,7 +1346,7 @@ void ProgramManager::flushSpecConstants(const program_impl &Prg, if (It == NativePrograms.end()) throw sycl::ext::oneapi::experimental::spec_const_error( "spec constant is set in a program w/o a binary image", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); Img = It->second; } if (!Img->supportsSpecConstants()) { @@ -1443,8 +1443,9 @@ static bool compatibleWithDevice(RTDeviceBinaryImage *BinImage, RT::PiResult Error = Plugin.call_nocheck( PIDeviceHandle, &DevBin, /*num bin images = */ (cl_uint)1, &SuitableImageID); - if (Error != PI_SUCCESS && Error != PI_INVALID_BINARY) - throw runtime_error("Invalid binary image or device", PI_INVALID_VALUE); + if (Error != PI_SUCCESS && Error != PI_ERROR_INVALID_BINARY) + throw runtime_error("Invalid binary image or device", + PI_ERROR_INVALID_VALUE); return (0 == SuitableImageID); } @@ -1455,7 +1456,7 @@ kernel_id ProgramManager::getSYCLKernelID(const std::string &KernelName) { auto KernelID = m_KernelName2KernelIDs.find(KernelName); if (KernelID == m_KernelName2KernelIDs.end()) throw runtime_error("No kernel found with the specified name", - PI_INVALID_KERNEL_NAME); + PI_ERROR_INVALID_KERNEL_NAME); return KernelID->second; } @@ -1698,7 +1699,7 @@ ProgramManager::compile(const device_image_plain &DeviceImage, sycl::runtime_error( "Creating a program from AOT binary for multiple device is not " "supported", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); // Device is not used when creating program from SPIRV, so passing only one // device is OK. @@ -1858,7 +1859,7 @@ device_image_plain ProgramManager::build(const device_image_plain &DeviceImage, sycl::runtime_error( "Creating a program from AOT binary for multiple device is not " "supported", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); // Device is not used when creating program from SPIRV, so passing only one // device is OK. diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 0c05db22d126a..9a74c21f8fd39 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -113,7 +113,7 @@ class queue_impl { throw cl::sycl::invalid_object_error( "Queue cannot be constructed with the given context and device " "as the context does not contain the given device.", - PI_INVALID_DEVICE); + PI_ERROR_INVALID_DEVICE); if (!MHostQueue) { const QueueOrder QOrder = MPropList.has_property() @@ -172,7 +172,7 @@ class queue_impl { if (MHostQueue) { throw invalid_object_error( "This instance of queue doesn't support OpenCL interoperability", - PI_INVALID_QUEUE); + PI_ERROR_INVALID_QUEUE); } getPlugin().call(MQueues[0]); return pi::cast(MQueues[0]); @@ -318,8 +318,8 @@ class queue_impl { // If creating out-of-order queue failed and this property is not // supported (for example, on FPGA), it will return - // PI_INVALID_QUEUE_PROPERTIES and will try to create in-order queue. - if (MSupportOOO && Error == PI_INVALID_QUEUE_PROPERTIES) { + // PI_ERROR_INVALID_QUEUE_PROPERTIES and will try to create in-order queue. + if (MSupportOOO && Error == PI_ERROR_INVALID_QUEUE_PROPERTIES) { MSupportOOO = false; Queue = createQueue(QueueOrder::Ordered); } else { diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index f7a56b56bb78a..00994acf30e1f 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -71,7 +71,7 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) { errcode_ret = Plugin.call_nocheck( getSyclObjImpl(Context)->getHandleRef(), sprops, &resultSampler); - if (errcode_ret == PI_INVALID_OPERATION) + if (errcode_ret == PI_ERROR_INVALID_OPERATION) throw feature_not_supported("Images are not supported by this device.", errcode_ret); diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index c1a8b7c075760..24404c9832e3e 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -710,7 +710,7 @@ bool Command::enqueue(EnqueueResultT &EnqueueResult, BlockingT Blocking, throw sycl::runtime_error( std::string("Waiting for blocked command. Block reason: ") + std::string(getBlockReason()), - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); #ifdef XPTI_ENABLE_INSTRUMENTATION // Scoped trace event notifier that emits a barrier begin and barrier end @@ -1404,7 +1404,8 @@ AllocaCommandBase *ExecCGCommand::getAllocaForReq(Requirement *Req) { if (Dep.MDepRequirement == Req) return Dep.MAllocaCmd; } - throw runtime_error("Alloca for command not found", PI_INVALID_OPERATION); + throw runtime_error("Alloca for command not found", + PI_ERROR_INVALID_OPERATION); } std::vector ExecCGCommand::getStreams() const { @@ -2022,7 +2023,7 @@ static pi_result SetKernelParamsAndLaunch( throw cl::sycl::feature_not_supported( "SYCL2020 specialization constants are not yet supported on host " "device", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } assert(DeviceImageImpl != nullptr); RT::PiMem SpecConstsBuffer = DeviceImageImpl->get_spec_const_buffer_ref(); @@ -2034,7 +2035,7 @@ static pi_result SetKernelParamsAndLaunch( break; } case kernel_param_kind_t::kind_invalid: - throw runtime_error("Invalid kernel param kind", PI_INVALID_VALUE); + throw runtime_error("Invalid kernel param kind", PI_ERROR_INVALID_VALUE); break; } }; @@ -2207,7 +2208,7 @@ cl_int ExecCGCommand::enqueueImp() { case CG::CGTYPE::UpdateHost: { throw runtime_error("Update host should be handled by the Scheduler.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } case CG::CGTYPE::CopyAccToPtr: { CGCopy *Copy = (CGCopy *)MCommandGroup.get(); @@ -2344,7 +2345,7 @@ cl_int ExecCGCommand::enqueueImp() { RawEvents.empty() ? nullptr : RawEvents.data(), Event); switch (Error) { - case PI_INVALID_OPERATION: + case PI_ERROR_INVALID_OPERATION: throw cl::sycl::runtime_error( "Device doesn't support run_on_host_intel tasks.", Error); case PI_SUCCESS: @@ -2486,7 +2487,7 @@ cl_int ExecCGCommand::enqueueImp() { break; } default: - throw runtime_error("Unsupported arg type", PI_INVALID_VALUE); + throw runtime_error("Unsupported arg type", PI_ERROR_INVALID_VALUE); } } @@ -2515,7 +2516,7 @@ cl_int ExecCGCommand::enqueueImp() { throw runtime_error( "Can't get memory object due to no allocation available", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); }; std::for_each(std::begin(HandlerReq), std::end(HandlerReq), ReqToMemConv); std::sort(std::begin(ReqToMem), std::end(ReqToMem)); @@ -2555,9 +2556,9 @@ cl_int ExecCGCommand::enqueueImp() { return PI_SUCCESS; } case CG::CGTYPE::None: - throw runtime_error("CG type not implemented.", PI_INVALID_OPERATION); + throw runtime_error("CG type not implemented.", PI_ERROR_INVALID_OPERATION); } - return PI_INVALID_OPERATION; + return PI_ERROR_INVALID_OPERATION; } bool ExecCGCommand::producesPiEvent() const { diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index 4899e079cbbc6..31edb0bd31e97 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -326,7 +326,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove( AllocaCommandBase *AllocaCmdDst = getOrCreateAllocaForReq(Record, Req, Queue, ToEnqueue); if (!AllocaCmdDst) - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); std::set Deps = findDepsForReq(Record, Req, Queue->getContextImplPtr()); @@ -357,7 +357,8 @@ Command *Scheduler::GraphBuilder::insertMemoryMove( AllocaCmdSrc = (Record->MAllocaCommands.end() != It) ? *It : nullptr; } if (!AllocaCmdSrc) - throw runtime_error("Cannot find buffer allocation", PI_INVALID_VALUE); + throw runtime_error("Cannot find buffer allocation", + PI_ERROR_INVALID_VALUE); // Get parent allocation of sub buffer to perform full copy of whole buffer if (IsSuitableSubReq(Req)) { if (AllocaCmdSrc->getType() == Command::CommandType::ALLOCA_SUB_BUF) @@ -476,7 +477,7 @@ Scheduler::GraphBuilder::addCopyBack(Requirement *Req, SrcAllocaCmd->getQueue(), std::move(HostQueue)); if (!MemCpyCmdUniquePtr) - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); MemCpyCommandHost *MemCpyCmd = MemCpyCmdUniquePtr.release(); @@ -848,7 +849,7 @@ Scheduler::GraphBuilder::addEmptyCmd(Command *Cmd, const std::vector &Reqs, new EmptyCommand(Scheduler::getInstance().getDefaultHostQueue()); if (!EmptyCmd) - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); EmptyCmd->MIsBlockable = true; EmptyCmd->MEnqueueStatus = EnqueueResultT::SyclEnqueueBlocked; @@ -922,7 +923,7 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr CommandGroup, auto NewCmd = std::make_unique(std::move(CommandGroup), Queue); if (!NewCmd) - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); if (MPrintOptionsArray[BeforeAddCG]) printGraphAsDot("before_addCG"); @@ -1315,7 +1316,7 @@ Command *Scheduler::GraphBuilder::connectDepEvent( ConnectCmd = new ExecCGCommand( std::move(ConnectCG), Scheduler::getInstance().getDefaultHostQueue()); } catch (const std::bad_alloc &) { - throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); + throw runtime_error("Out of host memory", PI_ERROR_OUT_OF_HOST_MEMORY); } EmptyCommand *EmptyCmd = nullptr; diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index 6e533df30a09c..2164f4e9d2900 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -35,7 +35,7 @@ void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event, bool Enqueued = enqueueCommand(Cmd, Res, ToCleanUp, BLOCKING); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) // TODO: Reschedule commands. - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", PI_ERROR_INVALID_OPERATION); assert(Cmd->getEvent() == Event); diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 6efdbc25d1b21..2901b7dc30c70 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -37,7 +37,8 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); #ifdef XPTI_ENABLE_INSTRUMENTATION // Capture the dependencies DepCommands.insert(Cmd); @@ -48,7 +49,8 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); #ifdef XPTI_ENABLE_INSTRUMENTATION DepCommands.insert(Cmd); #endif @@ -59,7 +61,8 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record, EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(ReleaseCmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); #ifdef XPTI_ENABLE_INSTRUMENTATION // Report these dependencies to the Command so these dependencies can be // reported as edges @@ -131,7 +134,7 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, try { if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) throw runtime_error("Auxiliary enqueue process failed.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } catch (...) { // enqueueCommand() func and if statement above may throw an exception, // so destroy required resources to avoid memory leak @@ -146,7 +149,8 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, try { bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } catch (...) { // enqueueCommand() func and if statement above may throw an exception, // so destroy required resources to avoid memory leak @@ -192,12 +196,14 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { for (Command *Cmd : AuxiliaryCmds) { Enqueued = GraphProcessor::enqueueCommand(Cmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } catch (...) { NewCmd->getQueue()->reportAsyncException(std::current_exception()); } @@ -321,13 +327,15 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req) { for (Command *Cmd : AuxiliaryCmds) { Enqueued = GraphProcessor::enqueueCommand(Cmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } if (Command *NewCmd = static_cast(NewCmdEvent->getCommand())) { Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } } @@ -359,7 +367,8 @@ void Scheduler::enqueueLeavesOfReqUnlocked(const Requirement *const Req, EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res, ToCleanUp); if (!Enqueued && EnqueueResultT::SyclEnqueueFailed == Res.MResult) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } }; diff --git a/sycl/source/detail/spec_constant_impl.cpp b/sycl/source/detail/spec_constant_impl.cpp index 898fb584f07b7..bca01db8b7822 100644 --- a/sycl/source/detail/spec_constant_impl.cpp +++ b/sycl/source/detail/spec_constant_impl.cpp @@ -22,7 +22,8 @@ namespace detail { void spec_constant_impl::set(size_t Size, const void *Val) { if (0 == Size) - throw sycl::runtime_error("invalid spec constant size", PI_INVALID_VALUE); + throw sycl::runtime_error("invalid spec constant size", + PI_ERROR_INVALID_VALUE); auto *BytePtr = reinterpret_cast(Val); this->Bytes.assign(BytePtr, BytePtr + Size); } diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 29de21ce66531..81643b7ea1f50 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -41,7 +41,7 @@ SYCLMemObjT::SYCLMemObjT(pi_native_handle MemObject, const context &SyclContext, throw cl::sycl::invalid_parameter_error( "Creation of interoperability memory object using host context is " "not allowed", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); RT::PiContext Context = nullptr; const plugin &Plugin = getPlugin(); @@ -60,7 +60,7 @@ SYCLMemObjT::SYCLMemObjT(pi_native_handle MemObject, const context &SyclContext, if (MInteropContext->getHandleRef() != Context) throw cl::sycl::invalid_parameter_error( "Input context must be the same as the context of cl_mem", - PI_INVALID_CONTEXT); + PI_ERROR_INVALID_CONTEXT); if (Plugin.getBackend() == backend::opencl) Plugin.call(MInteropMemObject); diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index 065033d35512c..f7bb8963aa64a 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -78,7 +78,7 @@ void *alignedAllocHost(size_t Alignment, size_t Size, const context &Ctxt, case alloc::shared: case alloc::unknown: { RetVal = nullptr; - Error = PI_INVALID_VALUE; + Error = PI_ERROR_INVALID_VALUE; break; } } @@ -165,7 +165,7 @@ void *alignedAlloc(size_t Alignment, size_t Size, const context &Ctxt, case alloc::host: case alloc::unknown: { RetVal = nullptr; - Error = PI_INVALID_VALUE; + Error = PI_ERROR_INVALID_VALUE; break; } } @@ -451,8 +451,8 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { PICtx, Ptr, PI_MEM_ALLOC_TYPE, sizeof(pi_usm_type), &AllocTy, nullptr); - // PI_INVALID_VALUE means USM doesn't know about this ptr - if (Err == PI_INVALID_VALUE) + // PI_ERROR_INVALID_VALUE means USM doesn't know about this ptr + if (Err == PI_ERROR_INVALID_VALUE) return alloc::unknown; // otherwise PI_SUCCESS is expected if (Err != PI_SUCCESS) { @@ -485,7 +485,8 @@ alloc get_pointer_type(const void *Ptr, const context &Ctxt) { device get_pointer_device(const void *Ptr, const context &Ctxt) { // Check if ptr is a valid USM pointer if (get_pointer_type(Ptr, Ctxt) == alloc::unknown) - throw runtime_error("Ptr not a valid USM allocation!", PI_INVALID_VALUE); + throw runtime_error("Ptr not a valid USM allocation!", + PI_ERROR_INVALID_VALUE); // Just return the host device in the host context if (Ctxt.is_host()) @@ -497,7 +498,8 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { if (get_pointer_type(Ptr, Ctxt) == alloc::host) { auto Devs = CtxImpl->getDevices(); if (Devs.size() == 0) - throw runtime_error("No devices in passed context!", PI_INVALID_VALUE); + throw runtime_error("No devices in passed context!", + PI_ERROR_INVALID_VALUE); // Just return the first device in the context return Devs[0]; @@ -518,7 +520,7 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { } throw runtime_error("Cannot find device associated with USM allocation!", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } // For ABI compatibility diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index f2e09cd1d0e61..b63576f630868 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -24,7 +24,7 @@ void force_type(info::device_type &t, const info::device_type &ft) { t = ft; } else if (ft != info::device_type::all && t != ft) { throw cl::sycl::invalid_parameter_error("No device of forced type.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } } } // namespace detail diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 7bfa93ca7abd9..ab12836314109 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -90,7 +90,7 @@ device device_selector::select_device() const { } throw cl::sycl::runtime_error("No device of requested type available.", - PI_DEVICE_NOT_FOUND); + PI_ERROR_DEVICE_NOT_FOUND); } /// Devices of different kinds are prioritized in the following order: diff --git a/sycl/source/exception.cpp b/sycl/source/exception.cpp index aeeda10dbaec1..12cbafd78a014 100644 --- a/sycl/source/exception.cpp +++ b/sycl/source/exception.cpp @@ -65,7 +65,7 @@ exception::exception(context Ctx, int EV, const std::error_category &ECat) // protected base constructor for all SYCL 2020 constructors exception::exception(std::error_code EC, std::shared_ptr SharedPtrCtx, const std::string &WhatArg) - : MMsg(WhatArg + ReservedForErrorcode), MCLErr(PI_INVALID_VALUE), + : MMsg(WhatArg + ReservedForErrorcode), MCLErr(PI_ERROR_INVALID_VALUE), MContext(SharedPtrCtx) { // For compatibility with previous implementation, we are "hiding" the // std::error_code in the MMsg string, behind the null string terminator diff --git a/sycl/source/function_pointer.cpp b/sycl/source/function_pointer.cpp index d86dc87cfa530..3af7cc66e51d2 100644 --- a/sycl/source/function_pointer.cpp +++ b/sycl/source/function_pointer.cpp @@ -27,10 +27,10 @@ getDeviceFunctionPointerImpl(device &D, program &P, const char *FuncName) { // if the function exists or not. If the return address is not valid throw // error. if (Result != PI_SUCCESS) { - if (Result == PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE) + if (Result == PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE) throw runtime_error("Function exists but address is not available", Result); - if (Result == PI_INVALID_KERNEL_NAME) + if (Result == PI_ERROR_INVALID_KERNEL_NAME) throw runtime_error("Function name is not valid", Result); else throw runtime_error("piextGetDeviceFunctionPointer returned error when " diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index e39e83d1892d0..3e8421cf7cdbd 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -281,14 +281,16 @@ event handler::finalize() { if (DiscardEvent) { if (CL_SUCCESS != EnqueueKernel()) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); } else { NewEvent = std::make_shared(MQueue); NewEvent->setContextImpl(MQueue->getContextImplPtr()); OutEvent = &NewEvent->getHandleRef(); if (CL_SUCCESS != EnqueueKernel()) - throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); + throw runtime_error("Enqueue process failed.", + PI_ERROR_INVALID_OPERATION); else if (NewEvent->is_host() || NewEvent->getHandleRef() == nullptr) NewEvent->setComplete(); @@ -394,7 +396,7 @@ event handler::finalize() { if (!CommandGroup) throw sycl::runtime_error( "Internal Error. Command group cannot be constructed.", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); detail::EventImplPtr Event = detail::Scheduler::getInstance().addCG( std::move(CommandGroup), std::move(MQueue)); @@ -575,7 +577,7 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind, case access::target::host_image: case access::target::host_buffer: { throw cl::sycl::invalid_parameter_error( - "Unsupported accessor target case.", PI_INVALID_OPERATION); + "Unsupported accessor target case.", PI_ERROR_INVALID_OPERATION); break; } } @@ -593,7 +595,7 @@ void handler::processArg(void *Ptr, const detail::kernel_param_kind_t &Kind, break; } case kernel_param_kind_t::kind_invalid: - throw runtime_error("Invalid kernel param kind", PI_INVALID_VALUE); + throw runtime_error("Invalid kernel param kind", PI_ERROR_INVALID_VALUE); break; } } diff --git a/sycl/source/interop_handle.cpp b/sycl/source/interop_handle.cpp index fff99ab730d6d..36da4d8e9c9c4 100644 --- a/sycl/source/interop_handle.cpp +++ b/sycl/source/interop_handle.cpp @@ -29,7 +29,7 @@ pi_native_handle interop_handle::getNativeMem(detail::Requirement *Req) const { if (Iter == std::end(MMemObjs)) { throw invalid_object_error("Invalid memory object used inside interop", - PI_INVALID_MEM_OBJECT); + PI_ERROR_INVALID_MEM_OBJECT); } auto Plugin = MQueue->getPlugin(); diff --git a/sycl/source/stream.cpp b/sycl/source/stream.cpp index e766067f0f090..aeeafee955647 100644 --- a/sycl/source/stream.cpp +++ b/sycl/source/stream.cpp @@ -27,7 +27,7 @@ static size_t CheckMaxStatementSize(const size_t &MaxStatementSize) { throw sycl::invalid_parameter_error( "Maximum statement size exceeds limit of " + std::to_string(MAX_STATEMENT_SIZE) + " bytes.", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); } return MaxStatementSize; } diff --git a/sycl/tools/sycl-trace/pi_trace_collector.cpp b/sycl/tools/sycl-trace/pi_trace_collector.cpp index 3d2fddc1a1e74..d4fe0bcb7f3d6 100644 --- a/sycl/tools/sycl-trace/pi_trace_collector.cpp +++ b/sycl/tools/sycl-trace/pi_trace_collector.cpp @@ -39,80 +39,80 @@ static std::string getResult(pi_result Res) { switch (Res) { case PI_SUCCESS: return "PI_SUCCESS"; - case PI_INVALID_KERNEL_NAME: - return "PI_INVALID_KERNEL_NAME"; - case PI_INVALID_OPERATION: + case PI_ERROR_INVALID_KERNEL_NAME: + return "PI_ERROR_INVALID_KERNEL_NAME"; + case PI_ERROR_INVALID_OPERATION: return "CL_INVALID_OPERATION"; - case PI_INVALID_KERNEL: - return "PI_INVALID_KERNEL"; - case PI_INVALID_QUEUE_PROPERTIES: - return "PI_INVALID_QUEUE_PROPERTIES"; - case PI_INVALID_VALUE: - return "PI_INVALID_VALUE"; - case PI_INVALID_CONTEXT: - return "PI_INVALID_CONTEXT"; - case PI_INVALID_PLATFORM: - return "PI_INVALID_PLATFORM"; - case PI_INVALID_DEVICE: - return "PI_INVALID_DEVICE"; - case PI_INVALID_BINARY: - return "PI_INVALID_BINARY"; - case PI_INVALID_QUEUE: + case PI_ERROR_INVALID_KERNEL: + return "PI_ERROR_INVALID_KERNEL"; + case PI_ERROR_INVALID_QUEUE_PROPERTIES: + return "PI_ERROR_INVALID_QUEUE_PROPERTIES"; + case PI_ERROR_INVALID_VALUE: + return "PI_ERROR_INVALID_VALUE"; + case PI_ERROR_INVALID_CONTEXT: + return "PI_ERROR_INVALID_CONTEXT"; + case PI_ERROR_INVALID_PLATFORM: + return "PI_ERROR_INVALID_PLATFORM"; + case PI_ERROR_INVALID_DEVICE: + return "PI_ERROR_INVALID_DEVICE"; + case PI_ERROR_INVALID_BINARY: + return "PI_ERROR_INVALID_BINARY"; + case PI_ERROR_INVALID_QUEUE: return "PI_INVALID_COMMAND_QUEUE"; - case PI_OUT_OF_HOST_MEMORY: - return "PI_OUT_OF_HOST_MEMORY"; - case PI_INVALID_PROGRAM: - return "PI_INVALID_PROGRAM"; - case PI_INVALID_PROGRAM_EXECUTABLE: - return "PI_INVALID_PROGRAM_EXECUTABLE"; - case PI_INVALID_SAMPLER: - return "PI_INVALID_SAMPLER"; - case PI_INVALID_BUFFER_SIZE: - return "PI_INVALID_BUFFER_SIZE"; - case PI_INVALID_MEM_OBJECT: - return "PI_INVALID_MEM_OBJECT"; - case PI_OUT_OF_RESOURCES: - return "PI_OUT_OF_RESOURCES"; - case PI_INVALID_EVENT: - return "PI_INVALID_EVENT"; - case PI_INVALID_EVENT_WAIT_LIST: - return "PI_INVALID_EVENT_WAIT_LIST"; - case PI_MISALIGNED_SUB_BUFFER_OFFSET: - return "PI_MISALIGNED_SUB_BUFFER_OFFSET"; - case PI_BUILD_PROGRAM_FAILURE: - return "PI_BUILD_PROGRAM_FAILURE"; - case PI_INVALID_WORK_GROUP_SIZE: - return "PI_INVALID_WORK_GROUP_SIZE"; - case PI_COMPILER_NOT_AVAILABLE: - return "PI_COMPILER_NOT_AVAILABLE"; - case PI_PROFILING_INFO_NOT_AVAILABLE: - return "PI_PROFILING_INFO_NOT_AVAILABLE"; - case PI_DEVICE_NOT_FOUND: - return "PI_DEVICE_NOT_FOUND"; - case PI_INVALID_WORK_ITEM_SIZE: - return "PI_INVALID_WORK_ITEM_SIZE"; - case PI_INVALID_WORK_DIMENSION: - return "PI_INVALID_WORK_DIMENSION"; - case PI_INVALID_KERNEL_ARGS: - return "PI_INVALID_KERNEL_ARGS"; - case PI_INVALID_IMAGE_SIZE: - return "PI_INVALID_IMAGE_SIZE"; - case PI_INVALID_ARG_VALUE: - return "PI_INVALID_ARG_VALUE"; - case PI_INVALID_IMAGE_FORMAT_DESCRIPTOR: - return "PI_INVALID_IMAGE_FORMAT_DESCRIPTOR"; - case PI_IMAGE_FORMAT_NOT_SUPPORTED: - return "PI_IMAGE_FORMAT_NOT_SUPPORTED"; - case PI_MEM_OBJECT_ALLOCATION_FAILURE: - return "PI_MEM_OBJECT_ALLOCATION_FAILURE"; - case PI_LINK_PROGRAM_FAILURE: - return "PI_LINK_PROGRAM_FAILURE"; - case PI_COMMAND_EXECUTION_FAILURE: - return "PI_COMMAND_EXECUTION_FAILURE"; - case PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE: - return "PI_FUNCTION_ADDRESS_IS_NOT_AVAILABLE"; - case PI_PLUGIN_SPECIFIC_ERROR: - return "PI_PLUGIN_SPECIFIC_ERROR"; + case PI_ERROR_OUT_OF_HOST_MEMORY: + return "PI_ERROR_OUT_OF_HOST_MEMORY"; + case PI_ERROR_INVALID_PROGRAM: + return "PI_ERROR_INVALID_PROGRAM"; + case PI_ERROR_INVALID_PROGRAM_EXECUTABLE: + return "PI_ERROR_INVALID_PROGRAM_EXECUTABLE"; + case PI_ERROR_INVALID_SAMPLER: + return "PI_ERROR_INVALID_SAMPLER"; + case PI_ERROR_INVALID_BUFFER_SIZE: + return "PI_ERROR_INVALID_BUFFER_SIZE"; + case PI_ERROR_INVALID_MEM_OBJECT: + return "PI_ERROR_INVALID_MEM_OBJECT"; + case PI_ERROR_OUT_OF_RESOURCES: + return "PI_ERROR_OUT_OF_RESOURCES"; + case PI_ERROR_INVALID_EVENT: + return "PI_ERROR_INVALID_EVENT"; + case PI_ERROR_INVALID_EVENT_WAIT_LIST: + return "PI_ERROR_INVALID_EVENT_WAIT_LIST"; + case PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET: + return "PI_ERROR_MISALIGNED_SUB_BUFFER_OFFSET"; + case PI_ERROR_BUILD_PROGRAM_FAILURE: + return "PI_ERROR_BUILD_PROGRAM_FAILURE"; + case PI_ERROR_INVALID_WORK_GROUP_SIZE: + return "PI_ERROR_INVALID_WORK_GROUP_SIZE"; + case PI_ERROR_COMPILER_NOT_AVAILABLE: + return "PI_ERROR_COMPILER_NOT_AVAILABLE"; + case PI_ERROR_PROFILING_INFO_NOT_AVAILABLE: + return "PI_ERROR_PROFILING_INFO_NOT_AVAILABLE"; + case PI_ERROR_DEVICE_NOT_FOUND: + return "PI_ERROR_DEVICE_NOT_FOUND"; + case PI_ERROR_INVALID_WORK_ITEM_SIZE: + return "PI_ERROR_INVALID_WORK_ITEM_SIZE"; + case PI_ERROR_INVALID_WORK_DIMENSION: + return "PI_ERROR_INVALID_WORK_DIMENSION"; + case PI_ERROR_INVALID_KERNEL_ARGS: + return "PI_ERROR_INVALID_KERNEL_ARGS"; + case PI_ERROR_INVALID_IMAGE_SIZE: + return "PI_ERROR_INVALID_IMAGE_SIZE"; + case PI_ERROR_INVALID_ARG_VALUE: + return "PI_ERROR_INVALID_ARG_VALUE"; + case PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR: + return "PI_ERROR_INVALID_IMAGE_FORMAT_DESCRIPTOR"; + case PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED: + return "PI_ERROR_IMAGE_FORMAT_NOT_SUPPORTED"; + case PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE: + return "PI_ERROR_MEM_OBJECT_ALLOCATION_FAILURE"; + case PI_ERROR_LINK_PROGRAM_FAILURE: + return "PI_ERROR_LINK_PROGRAM_FAILURE"; + case PI_ERROR_COMMAND_EXECUTION_FAILURE: + return "PI_ERROR_COMMAND_EXECUTION_FAILURE"; + case PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE: + return "PI_ERROR_FUNCTION_ADDRESS_IS_NOT_AVAILABLE"; + case PI_ERROR_PLUGIN_SPECIFIC_ERROR: + return "PI_ERROR_PLUGIN_SPECIFIC_ERROR"; case PI_ERROR_UNKNOWN: return "PI_ERROR_UNKNOWN"; } diff --git a/sycl/unittests/assert/assert.cpp b/sycl/unittests/assert/assert.cpp index f2796b1a1b593..94fcdaca7ce75 100644 --- a/sycl/unittests/assert/assert.cpp +++ b/sycl/unittests/assert/assert.cpp @@ -371,12 +371,13 @@ static pi_result redefinedProgramGetInfo(pi_program P, return PI_ERROR_UNKNOWN; } -static pi_result redefinedProgramGetBuildInfo( - pi_program P, pi_device D, - cl_program_build_info ParamName, // TODO: untie from OpenCL - size_t ParamValueSize, void *ParamValue, size_t *ParamValueSizeRet) { - if (CL_PROGRAM_BINARY_TYPE == ParamName) { - static const cl_program_binary_type T = CL_PROGRAM_BINARY_TYPE_EXECUTABLE; +static pi_result redefinedProgramGetBuildInfo(pi_program P, pi_device D, + pi_program_build_info ParamName, + size_t ParamValueSize, + void *ParamValue, + size_t *ParamValueSizeRet) { + if (PI_PROGRAM_BUILD_INFO_BINARY_TYPE == ParamName) { + static const pi_program_binary_type T = PI_PROGRAM_BINARY_TYPE_EXECUTABLE; if (ParamValue) memcpy(ParamValue, &T, sizeof(T)); if (ParamValueSizeRet) @@ -384,7 +385,7 @@ static pi_result redefinedProgramGetBuildInfo( return PI_SUCCESS; } - if (CL_PROGRAM_BUILD_OPTIONS == ParamName) { + if (PI_PROGRAM_BUILD_INFO_OPTIONS == ParamName) { if (ParamValueSizeRet) *ParamValueSizeRet = 0; return PI_SUCCESS; diff --git a/sycl/unittests/pi/EnqueueMemTest.cpp b/sycl/unittests/pi/EnqueueMemTest.cpp index 5e001acc2ba9c..84f07a7b64fd4 100644 --- a/sycl/unittests/pi/EnqueueMemTest.cpp +++ b/sycl/unittests/pi/EnqueueMemTest.cpp @@ -41,7 +41,7 @@ class EnqueueMemTest : public testing::TestWithParam { platform, PI_DEVICE_TYPE_DEFAULT, 1, &_device, nullptr)), PI_SUCCESS); - pi_result result = PI_INVALID_VALUE; + pi_result result = PI_ERROR_INVALID_VALUE; result = plugin.call_nocheck( nullptr, 1u, &_device, nullptr, nullptr, &_context); ASSERT_EQ(result, PI_SUCCESS); diff --git a/sycl/unittests/pi/PiMock.cpp b/sycl/unittests/pi/PiMock.cpp index cfba6ee480334..3c046634c498a 100644 --- a/sycl/unittests/pi/PiMock.cpp +++ b/sycl/unittests/pi/PiMock.cpp @@ -17,11 +17,11 @@ using namespace cl::sycl; pi_result piProgramBuildRedefine(pi_program, pi_uint32, const pi_device *, const char *, void (*)(pi_program, void *), void *) { - return PI_INVALID_BINARY; + return PI_ERROR_INVALID_BINARY; } pi_result piKernelCreateRedefine(pi_program, const char *, pi_kernel *) { - return PI_INVALID_DEVICE; + return PI_ERROR_INVALID_DEVICE; } TEST(PiMockTest, ConstructFromQueue) { diff --git a/sycl/unittests/program_manager/BuildLog.cpp b/sycl/unittests/program_manager/BuildLog.cpp index 8dec1cda62cdb..4553265329e91 100644 --- a/sycl/unittests/program_manager/BuildLog.cpp +++ b/sycl/unittests/program_manager/BuildLog.cpp @@ -31,7 +31,7 @@ static constexpr auto WarningLevelEnvVar = "SYCL_RT_WARNING_LEVEL"; static bool LogRequested = false; static pi_result redefinedProgramGetBuildInfo( - pi_program program, pi_device device, cl_program_build_info param_name, + pi_program program, pi_device device, pi_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret) { if (param_value_size_ret) { diff --git a/sycl/unittests/program_manager/EliminatedArgMask.cpp b/sycl/unittests/program_manager/EliminatedArgMask.cpp index 2fcb0750e13af..1e83d0d52abdd 100644 --- a/sycl/unittests/program_manager/EliminatedArgMask.cpp +++ b/sycl/unittests/program_manager/EliminatedArgMask.cpp @@ -143,7 +143,7 @@ class MockHandler : public sycl::handler { } default: throw sycl::runtime_error("Unhandled type of command group", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } return CommandGroup; diff --git a/sycl/unittests/queue/EventClear.cpp b/sycl/unittests/queue/EventClear.cpp index caf0017df8509..00350b9fc5f0b 100644 --- a/sycl/unittests/queue/EventClear.cpp +++ b/sycl/unittests/queue/EventClear.cpp @@ -31,7 +31,7 @@ pi_result redefinedQueueCreate(pi_context context, pi_device device, // Use in-order queues to force storing events for calling wait on them, // rather than calling piQueueFinish. if (properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { - return PI_INVALID_QUEUE_PROPERTIES; + return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; } diff --git a/sycl/unittests/queue/Wait.cpp b/sycl/unittests/queue/Wait.cpp index 0dc238c70b3a9..ca9da41c2f143 100644 --- a/sycl/unittests/queue/Wait.cpp +++ b/sycl/unittests/queue/Wait.cpp @@ -31,7 +31,7 @@ pi_result redefinedQueueCreate(pi_context context, pi_device device, pi_queue *queue) { if (!TestContext.SupportOOO && properties & PI_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) { - return PI_INVALID_QUEUE_PROPERTIES; + return PI_ERROR_INVALID_QUEUE_PROPERTIES; } return PI_SUCCESS; } diff --git a/sycl/unittests/scheduler/StreamInitDependencyOnHost.cpp b/sycl/unittests/scheduler/StreamInitDependencyOnHost.cpp index ef8c4c0895df8..57d34aa8aeac0 100644 --- a/sycl/unittests/scheduler/StreamInitDependencyOnHost.cpp +++ b/sycl/unittests/scheduler/StreamInitDependencyOnHost.cpp @@ -62,7 +62,7 @@ class MockHandler : public sycl::handler { } default: throw sycl::runtime_error("Unhandled type of command group", - PI_INVALID_OPERATION); + PI_ERROR_INVALID_OPERATION); } return CommandGroup; @@ -81,7 +81,7 @@ static bool ValidateDepCommandsTree(const detail::Command *Cmd, size_t Depth = 0) { if (!Cmd || Depth >= DepCmdsTypes.size()) throw sycl::runtime_error("Command parameters are invalid", - PI_INVALID_VALUE); + PI_ERROR_INVALID_VALUE); for (const detail::DepDesc &Dep : Cmd->MDeps) { if (Dep.MDepCommand &&