From 928351de20a1d00e33e643857cca5ee54ddc8e47 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Tue, 18 Feb 2020 18:13:25 +0300 Subject: [PATCH 1/9] [SYCL] Remove default error code value in exception Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/accessor.hpp | 6 +- sycl/include/CL/sycl/buffer.hpp | 10 ++- sycl/include/CL/sycl/detail/array.hpp | 3 +- sycl/include/CL/sycl/detail/cg.hpp | 6 +- sycl/include/CL/sycl/detail/device_impl.hpp | 6 +- .../CL/sycl/detail/image_accessor_util.hpp | 34 ++++---- sycl/include/CL/sycl/detail/kernel_impl.hpp | 3 +- sycl/include/CL/sycl/detail/pi.h | 4 +- sycl/include/CL/sycl/detail/platform_impl.hpp | 4 +- sycl/include/CL/sycl/detail/program_impl.hpp | 3 +- sycl/include/CL/sycl/detail/queue_impl.hpp | 6 +- .../include/CL/sycl/detail/sycl_mem_obj_t.hpp | 2 +- sycl/include/CL/sycl/exception.hpp | 15 ++-- sycl/include/CL/sycl/handler.hpp | 6 +- .../CL/sycl/intel/function_pointer.hpp | 3 +- sycl/include/CL/sycl/intel/sub_group_host.hpp | 84 ++++++++++++------- sycl/include/CL/sycl/types.hpp | 4 +- sycl/include/CL/sycl/usm/usm_allocator.hpp | 9 +- sycl/source/context.cpp | 5 +- sycl/source/detail/context_impl.cpp | 3 +- sycl/source/detail/device_impl.cpp | 17 ++-- sycl/source/detail/device_info.cpp | 15 ++-- sycl/source/detail/event_impl.cpp | 18 ++-- sycl/source/detail/image_impl.cpp | 32 +++---- sycl/source/detail/kernel_impl.cpp | 9 +- sycl/source/detail/kernel_info.cpp | 3 +- sycl/source/detail/memory_manager.cpp | 11 ++- sycl/source/detail/platform_impl.cpp | 8 +- sycl/source/detail/platform_util.cpp | 3 +- sycl/source/detail/program_impl.cpp | 28 ++++--- .../program_manager/program_manager.cpp | 37 +++++--- sycl/source/detail/sampler_impl.cpp | 3 +- sycl/source/detail/scheduler/commands.cpp | 7 +- .../source/detail/scheduler/graph_builder.cpp | 8 +- .../detail/scheduler/graph_processor.cpp | 2 +- sycl/source/detail/scheduler/scheduler.cpp | 14 ++-- sycl/source/detail/sycl_mem_obj_t.cpp | 7 +- sycl/source/detail/usm/usm_impl.cpp | 7 +- sycl/source/device.cpp | 3 +- sycl/source/device_selector.cpp | 3 +- sycl/source/handler.cpp | 7 +- sycl/source/ordered_queue.cpp | 3 +- sycl/test/sub_group/attributes.cpp | 3 +- sycl/test/sub_group/common_ocl.cpp | 2 +- 44 files changed, 281 insertions(+), 185 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index ae211384f7778..d7683b51a0e15 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -335,7 +335,8 @@ class image_accessor template void checkDeviceFeatureSupported(const device &Device) { if (!Device.get_info()) - throw feature_not_supported("Images are not supported by this device."); + throw feature_not_supported("Images are not supported by this device.", + PI_INVALID_OPERATION); } #ifdef __SYCL_DEVICE_ONLY__ @@ -357,7 +358,8 @@ class image_accessor sycl::vec getRangeInternal() const { // TODO: Implement for host. throw runtime_error( - "image::getRangeInternal() is not implemented for host"); + "image::getRangeInternal() is not implemented for host", + PI_INVALID_OPERATION); return sycl::vec{1}; } diff --git a/sycl/include/CL/sycl/buffer.hpp b/sycl/include/CL/sycl/buffer.hpp index 8181f2628a173..7fd9bd17e45cc 100644 --- a/sycl/include/CL/sycl/buffer.hpp +++ b/sycl/include/CL/sycl/buffer.hpp @@ -180,13 +180,14 @@ class buffer { IsSubBuffer(true) { if (b.is_sub_buffer()) throw cl::sycl::invalid_object_error( - "Cannot create sub buffer from sub buffer."); + "Cannot create sub buffer from sub buffer.", PI_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"); + "Requested sub-buffer size exceeds the size of the parent buffer", + PI_INVALID_VALUE); if (!isContiguousRegion(baseIndex, subRange, b.Range)) throw cl::sycl::invalid_object_error( - "Requested sub-buffer region is not contiguous"); + "Requested sub-buffer region is not contiguous", PI_INVALID_VALUE); } template > @@ -285,7 +286,8 @@ class buffer { throw cl::sycl::invalid_object_error( "Total size in bytes represented by the type and range of the " "reinterpreted SYCL buffer does not equal the total size in bytes " - "represented by the type and range of this SYCL buffer"); + "represented by the type and range of this SYCL buffer", + PI_INVALID_VALUE); return buffer( impl, reinterpretRange, OffsetInBytes, IsSubBuffer); diff --git a/sycl/include/CL/sycl/detail/array.hpp b/sycl/include/CL/sycl/detail/array.hpp index 1a4eaa16820d4..d4aada6d7dd86 100644 --- a/sycl/include/CL/sycl/detail/array.hpp +++ b/sycl/include/CL/sycl/detail/array.hpp @@ -111,7 +111,8 @@ template class array { ALWAYS_INLINE void check_dimension(int dimension) const { #ifndef __SYCL_DEVICE_ONLY__ if (dimension >= dimensions || dimension < 0) { - throw cl::sycl::invalid_parameter_error("Index out of range"); + throw cl::sycl::invalid_parameter_error("Index out of range", + PI_INVALID_VALUE); } #endif } diff --git a/sycl/include/CL/sycl/detail/cg.hpp b/sycl/include/CL/sycl/detail/cg.hpp index 1bc604e0d5a65..7eaa170aa152a 100644 --- a/sycl/include/CL/sycl/detail/cg.hpp +++ b/sycl/include/CL/sycl/detail/cg.hpp @@ -239,7 +239,8 @@ class HostKernel : public HostKernelBase { for (int I = 0; I < Dims; ++I) { if (NDRDesc.LocalSize[I] == 0 || NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0) - throw sycl::nd_range_error("Invalid local size for global size"); + throw sycl::nd_range_error("Invalid local size for global size", + PI_INVALID_VALUE); GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } @@ -280,7 +281,8 @@ class HostKernel : public HostKernelBase { for (int I = 0; I < Dims; ++I) { if (NDRDesc.LocalSize[I] == 0 || NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0) - throw sycl::nd_range_error("Invalid local size for global size"); + throw sycl::nd_range_error("Invalid local size for global size", + PI_INVALID_VALUE); NGroups[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } diff --git a/sycl/include/CL/sycl/detail/device_impl.hpp b/sycl/include/CL/sycl/detail/device_impl.hpp index 30f3006b8790d..41be476c6dd81 100644 --- a/sycl/include/CL/sycl/detail/device_impl.hpp +++ b/sycl/include/CL/sycl/detail/device_impl.hpp @@ -54,7 +54,8 @@ class device_impl { /// @return non-constant reference to PI device RT::PiDevice &getHandleRef() { if (MIsHostDevice) - throw invalid_object_error("This instance of device is a host instance"); + throw invalid_object_error("This instance of device is a host instance", + PI_INVALID_DEVICE); return MDevice; } @@ -66,7 +67,8 @@ class device_impl { /// @return constant reference to PI device const RT::PiDevice &getHandleRef() const { if (MIsHostDevice) - throw invalid_object_error("This instance of device is a host instance"); + throw invalid_object_error("This instance of device is a host instance", + PI_INVALID_DEVICE); return MDevice; } diff --git a/sycl/include/CL/sycl/detail/image_accessor_util.hpp b/sycl/include/CL/sycl/detail/image_accessor_util.hpp index 9d3375f98a453..f7a5a6295d94c 100644 --- a/sycl/include/CL/sycl/detail/image_accessor_util.hpp +++ b/sycl/include/CL/sycl/detail/image_accessor_util.hpp @@ -193,7 +193,8 @@ vec readPixel(T *Ptr, const image_channel_order ChannelOrder, Pixel.x() = Ptr[3]; // r break; default: - throw cl::sycl::invalid_parameter_error("Unhandled image channel order"); + throw cl::sycl::invalid_parameter_error("Unhandled image channel order", + PI_INVALID_VALUE); } return Pixel; @@ -265,7 +266,8 @@ void writePixel(const vec Pixel, T *Ptr, Ptr[3] = Pixel.x(); // r break; default: - throw cl::sycl::invalid_parameter_error("Unhandled image channel order"); + throw cl::sycl::invalid_parameter_error("Unhandled image channel order", + PI_INVALID_VALUE); } } @@ -293,7 +295,7 @@ void convertReadData(const vec PixelData, // unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_uint4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); } } @@ -314,7 +316,7 @@ void convertReadData(const vec PixelData, // signed_int32. throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_int4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); } } @@ -395,7 +397,7 @@ void convertReadData(const vec PixelData, // and signed/unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype of read data - cl_float4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_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. @@ -425,7 +427,7 @@ void convertReadData(const vec PixelData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_half4."); + "to cl_half4.", PI_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -437,14 +439,14 @@ void convertReadData(const vec PixelData, // and signed/unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype to read- cl_half4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); case image_channel_type::fp16: RetData = PixelData.template convert(); break; case image_channel_type::fp32: throw cl::sycl::invalid_parameter_error( "Datatype to read - cl_half4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); default: break; } @@ -484,7 +486,7 @@ convertWriteData(const vec WriteData, // unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_uint4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); } } @@ -516,7 +518,7 @@ convertWriteData(const vec WriteData, // signed_int32. throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_int4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_INVALID_VALUE); } } @@ -554,7 +556,7 @@ convertWriteData(const vec WriteData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_float4."); + "to cl_float4.", PI_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. @@ -596,7 +598,7 @@ convertWriteData(const vec WriteData, // and signed/unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_float4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_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. @@ -624,7 +626,7 @@ convertWriteData(const vec WriteData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_half4."); + "to cl_half4.", PI_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -636,13 +638,13 @@ convertWriteData(const vec WriteData, // and signed/unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype of data to write - cl_float4 is incompatible with the " - "image_channel_type of the image."); + "image_channel_type of the image.", PI_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."); + "image_channel_type of the image.", PI_INVALID_VALUE); default: break; } @@ -1007,7 +1009,7 @@ DataT imageReadSamplerHostImpl(const CoordT &Coords, const sampler &Smpl, throw cl::sycl::feature_not_supported( "Sampler used with unsupported configuration of " "mirrored_repeat/repeat filtering mode with unnormalized " - "coordinates. "); + "coordinates. ", PI_INVALID_OPERATION); case addressing_mode::clamp_to_edge: case addressing_mode::clamp: case addressing_mode::none: diff --git a/sycl/include/CL/sycl/detail/kernel_impl.hpp b/sycl/include/CL/sycl/detail/kernel_impl.hpp index f30450949415a..785f9730e56a4 100644 --- a/sycl/include/CL/sycl/detail/kernel_impl.hpp +++ b/sycl/include/CL/sycl/detail/kernel_impl.hpp @@ -75,7 +75,8 @@ class kernel_impl { /// @return a valid cl_kernel instance cl_kernel get() const { if (is_host()) - throw invalid_object_error("This instance of kernel is a host instance"); + throw invalid_object_error("This instance of kernel is a host instance", + PI_INVALID_DEVICE); getPlugin().call(MKernel); return pi::cast(MKernel); } diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index d5797c5b81ebc..e0ec490348a75 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -62,9 +62,11 @@ typedef enum { PI_INVALID_PLATFORM = CL_INVALID_PLATFORM, PI_INVALID_DEVICE = CL_INVALID_DEVICE, PI_INVALID_BINARY = CL_INVALID_BINARY, + PI_INVALID_KERNEL = CL_INVALID_KERNEL, PI_MISALIGNED_SUB_BUFFER_OFFSET = CL_MISALIGNED_SUB_BUFFER_OFFSET, PI_OUT_OF_HOST_MEMORY = CL_OUT_OF_HOST_MEMORY, - PI_INVALID_WORK_GROUP_SIZE = CL_INVALID_WORK_GROUP_SIZE + PI_INVALID_WORK_GROUP_SIZE = CL_INVALID_WORK_GROUP_SIZE, + PI_INVALID_PROGRAM = CL_INVALID_PROGRAM } _pi_result; typedef enum { diff --git a/sycl/include/CL/sycl/detail/platform_impl.hpp b/sycl/include/CL/sycl/detail/platform_impl.hpp index ef707d5910dbc..51b2743e1c54a 100644 --- a/sycl/include/CL/sycl/detail/platform_impl.hpp +++ b/sycl/include/CL/sycl/detail/platform_impl.hpp @@ -73,7 +73,7 @@ class platform_impl { cl_platform_id get() const { if (is_host()) throw invalid_object_error( - "This instance of platform is a host instance"); + "This instance of platform is a host instance", PI_INVALID_DEVICE); return pi::cast(MPlatform); } @@ -88,7 +88,7 @@ class platform_impl { const RT::PiPlatform &getHandleRef() const { if (is_host()) throw invalid_object_error( - "This instance of platform is a host instance"); + "This instance of platform is a host instance", PI_INVALID_DEVICE); return MPlatform; } diff --git a/sycl/include/CL/sycl/detail/program_impl.hpp b/sycl/include/CL/sycl/detail/program_impl.hpp index e52bbe62935c1..38490e7f7ec2c 100644 --- a/sycl/include/CL/sycl/detail/program_impl.hpp +++ b/sycl/include/CL/sycl/detail/program_impl.hpp @@ -296,7 +296,8 @@ class program_impl { for (const auto &Device : Devices) { if (!Device.get_info()) { throw feature_not_supported( - "Online compilation is not supported by this device"); + "Online compilation is not supported by this device", + PI_INVALID_DEVICE); } } } diff --git a/sycl/include/CL/sycl/detail/queue_impl.hpp b/sycl/include/CL/sycl/detail/queue_impl.hpp index 52210e221817e..49df14cccb1d1 100644 --- a/sycl/include/CL/sycl/detail/queue_impl.hpp +++ b/sycl/include/CL/sycl/detail/queue_impl.hpp @@ -75,7 +75,8 @@ class queue_impl { if (!Context->hasDevice(Device)) throw cl::sycl::invalid_parameter_error( "Queue cannot be constructed with the given context and device " - "as the context does not contain the given device."); + "as the context does not contain the given device.", + PI_INVALID_DEVICE); } /// Constructs a SYCL queue from plugin interoperability handle. @@ -116,7 +117,8 @@ class queue_impl { return pi::cast(MCommandQueue); } throw invalid_object_error( - "This instance of queue doesn't support OpenCL interoperability"); + "This instance of queue doesn't support OpenCL interoperability", + PI_INVALID_DEVICE); } /// @return an associated SYCL context. 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 6337f34eeeedc..df6a66e433909 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -239,7 +239,7 @@ class SYCLMemObjT : public SYCLMemObjI { if (useHostPtr()) throw invalid_parameter_error( "Buffer constructor from a pair of iterator values does not support " - "use_host_ptr property."); + "use_host_ptr property.", PI_INVALID_OPERATION); setAlign(RequiredAlign); MShadowCopy = allocateHostMem(); diff --git a/sycl/include/CL/sycl/exception.hpp b/sycl/include/CL/sycl/exception.hpp index 826f394e99b0d..08811c2aba528 100644 --- a/sycl/include/CL/sycl/exception.hpp +++ b/sycl/include/CL/sycl/exception.hpp @@ -11,6 +11,7 @@ // 4.9.2 Exception Class Interface #include +#include #include #include @@ -37,15 +38,15 @@ class exception: public std::exception { private: string_class MMsg; - cl_int MCLErr = CL_SUCCESS; + cl_int MCLErr; shared_ptr_class MContext; protected: - exception(const char *Msg, const cl_int CLErr = CL_SUCCESS, + exception(const char *Msg, const cl_int CLErr, shared_ptr_class Context = nullptr) : exception(string_class(Msg), CLErr, Context) {} - exception(const string_class &Msg, const cl_int CLErr = CL_SUCCESS, + exception(const string_class &Msg, const cl_int CLErr, shared_ptr_class Context = nullptr) : MMsg(Msg + " " + detail::codeToString(CLErr)), MCLErr(CLErr), MContext(Context) {} @@ -55,10 +56,10 @@ class runtime_error : public exception { public: runtime_error() = default; - runtime_error(const char *Msg, cl_int Err = CL_SUCCESS) + runtime_error(const char *Msg, cl_int Err) : runtime_error(string_class(Msg), Err) {} - runtime_error(const string_class &Msg, cl_int Err = CL_SUCCESS) + runtime_error(const string_class &Msg, cl_int Err) : exception(Msg, Err) {} }; class kernel_error : public runtime_error { @@ -80,10 +81,10 @@ class device_error : public exception { public: device_error() = default; - device_error(const char *Msg, cl_int Err = CL_SUCCESS) + device_error(const char *Msg, cl_int Err) : device_error(string_class(Msg), Err) {} - device_error(const string_class &Msg, cl_int Err = CL_SUCCESS) + device_error(const string_class &Msg, cl_int Err) : exception(Msg, Err) {} }; class compile_program_error : public device_error { diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index 8dbc3fbe5c1e3..e5b6e0f33770d 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -294,10 +294,12 @@ class handler { void verifySyclKernelInvoc(const kernel &SyclKernel) { if (is_host()) { throw invalid_object_error( - "This kernel invocation method cannot be used on the host"); + "This kernel invocation method cannot be used on the host", + PI_INVALID_DEVICE); } if (SyclKernel.is_host()) { - throw invalid_object_error("Invalid kernel type, OpenCL expected"); + throw invalid_object_error("Invalid kernel type, OpenCL expected", + PI_RESULT_INVALID_KERNEL_NAME); } } diff --git a/sycl/include/CL/sycl/intel/function_pointer.hpp b/sycl/include/CL/sycl/intel/function_pointer.hpp index b3faf3f282c16..5fff798de86b0 100644 --- a/sycl/include/CL/sycl/intel/function_pointer.hpp +++ b/sycl/include/CL/sycl/intel/function_pointer.hpp @@ -77,7 +77,8 @@ 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"); + "Program must be built before passing to get_device_func_ptr", + PI_INVALID_OPERATION); } return detail::getDeviceFunctionPointerImpl(D, P, FuncName); diff --git a/sycl/include/CL/sycl/intel/sub_group_host.hpp b/sycl/include/CL/sycl/intel/sub_group_host.hpp index d6fade163b117..432c0f2916983 100644 --- a/sycl/include/CL/sycl/intel/sub_group_host.hpp +++ b/sycl/include/CL/sycl/intel/sub_group_host.hpp @@ -23,138 +23,166 @@ struct sub_group { /* --- common interface members --- */ id<1> get_local_id() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } range<1> get_local_range() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } range<1> get_max_local_range() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } id<1> get_group_id() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } size_t get_group_range() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } size_t get_uniform_group_range() const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- vote / ballot functions --- */ bool any(bool predicate) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } bool all(bool predicate) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- collectives --- */ template T broadcast(T x, id<1> local_id) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T reduce(T x, BinaryOperation op) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T reduce(T x, T init, BinaryOperation op) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T exclusive_scan(T x, BinaryOperation op) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T exclusive_scan(T x, T init, BinaryOperation op) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T inclusive_scan(T x, BinaryOperation op) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T inclusive_scan(T x, BinaryOperation op, T init) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- one - input shuffles --- */ /* indices in [0 , sub - group size ) */ template T shuffle(T x, id<1> local_id) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T shuffle_down(T x, uint32_t delta) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T shuffle_up(T x, uint32_t delta) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T shuffle_xor(T x, id<1> value) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- two - input shuffles --- */ /* indices in [0 , 2* sub - group size ) */ template T shuffle(T x, T y, id<1> local_id) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T shuffle_down(T current, T next, uint32_t delta) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template T shuffle_up(T previous, T current, uint32_t delta) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- sub - group load / stores --- */ /* these can map to SIMD or block read / write hardware where available */ template T load(const multi_ptr src) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template vec load(const multi_ptr src) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template void store(multi_ptr dst, T &x) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } template void store(multi_ptr dst, const vec &x) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } /* --- synchronization functions --- */ void barrier(access::fence_space accessSpace = access::fence_space::global_and_local) const { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } protected: template friend class cl::sycl::nd_item; sub_group() { - throw runtime_error("Subgroups are not supported on host device. "); + throw runtime_error("Subgroups are not supported on host device. ", + PI_INVALID_DEVICE); } }; } // namespace intel diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index efc0eb55e1157..0fb2950dca89b 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -243,11 +243,11 @@ detail::enable_if_t::value, R> convertImpl(T Value) { int OldRoundingDirection = std::fegetround(); int Err = std::fesetround(FE_TONEAREST); if (Err) - throw runtime_error("Unable to set rounding mode to FE_TONEAREST"); + throw std::runtime_error("Unable to set rounding mode to FE_TONEAREST"); R Result = std::rint(Value); Err = std::fesetround(OldRoundingDirection); if (Err) - throw runtime_error("Unable to restore rounding mode."); + throw std::runtime_error("Unable to restore rounding mode."); return Result; } // Round toward zero. diff --git a/sycl/include/CL/sycl/usm/usm_allocator.hpp b/sycl/include/CL/sycl/usm/usm_allocator.hpp index ff6526bc1cbf5..d598d4ec49a12 100644 --- a/sycl/include/CL/sycl/usm/usm_allocator.hpp +++ b/sycl/include/CL/sycl/usm/usm_allocator.hpp @@ -65,7 +65,8 @@ class usm_allocator { typename std::enable_if::type = 0> void construct(pointer Ptr, const_reference Val) { throw feature_not_supported( - "Device pointers do not support construct on host"); + "Device pointers do not support construct on host", + PI_INVALID_OPERATION); } /// Destroys an object. @@ -85,7 +86,7 @@ class usm_allocator { typename std::enable_if::type = 0> void destroy(pointer Ptr) { throw feature_not_supported( - "Device pointers do not support destroy on host"); + "Device pointers do not support destroy on host", PI_INVALID_OPERATION); } /// Note:: AllocKind == alloc::device is not allowed. @@ -104,7 +105,7 @@ class usm_allocator { typename std::enable_if::type = 0> pointer address(reference Val) const { throw feature_not_supported( - "Device pointers do not support address on host"); + "Device pointers do not support address on host", PI_INVALID_OPERATION); } template < @@ -119,7 +120,7 @@ class usm_allocator { typename std::enable_if::type = 0> const_pointer address(const_reference Val) const { throw feature_not_supported( - "Device pointers do not support address on host"); + "Device pointers do not support address on host", PI_INVALID_OPERATION); } /// Allocates memory. diff --git a/sycl/source/context.cpp b/sycl/source/context.cpp index f8b502f81cae3..52986e5498ed9 100644 --- a/sycl/source/context.cpp +++ b/sycl/source/context.cpp @@ -35,7 +35,7 @@ context::context(const platform &Platform, async_handler AsyncHandler) context::context(const vector_class &DeviceList, async_handler AsyncHandler) { if (DeviceList.empty()) { - throw invalid_parameter_error("DeviceList is empty."); + throw invalid_parameter_error("DeviceList is empty.", PI_INVALID_VALUE); } auto NonHostDeviceIter = std::find_if_not( DeviceList.begin(), DeviceList.end(), @@ -53,7 +53,8 @@ context::context(const vector_class &DeviceList, NonHostPlatform)); })) throw invalid_parameter_error( - "Can't add devices across platforms to a single context."); + "Can't add devices across platforms to a single context.", + PI_INVALID_DEVICE); else impl = std::make_shared(DeviceList, AsyncHandler); } diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index 70deee347d11a..6501a585b7c2b 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -80,7 +80,8 @@ cl_context context_impl::get() const { return pi::cast(MContext); } throw invalid_object_error( - "This instance of context doesn't support OpenCL interoperability."); + "This instance of context doesn't support OpenCL interoperability.", + PI_INVALID_DEVICE); } bool context_impl::is_host() const { return MHostContext || !MPluginInterop; } diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index 1a4c4980623bc..7e5034e6f2e0a 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -72,7 +72,8 @@ bool device_impl::is_affinity_supported( cl_device_id device_impl::get() const { if (MIsHostDevice) - throw invalid_object_error("This instance of device is a host instance"); + throw invalid_object_error("This instance of device is a host instance", + PI_INVALID_DEVICE); if (!MIsRootDevice) { // TODO catch an exception and put it to list of asynchronous exceptions @@ -137,7 +138,8 @@ device_impl::create_sub_devices(size_t ComputeUnits) const { if (MIsHostDevice) // TODO: implement host device partitioning throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet"); + "Partitioning to subdevices of the host device is not implemented yet", + PI_INVALID_DEVICE); if (!is_partition_supported(info::partition_property::partition_equally)) { throw cl::sycl::feature_not_supported(); @@ -156,7 +158,8 @@ device_impl::create_sub_devices(const vector_class &Counts) const { if (MIsHostDevice) // TODO: implement host device partitioning throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet"); + "Partitioning to subdevices of the host device is not implemented yet", + PI_INVALID_DEVICE); if (!is_partition_supported( info::partition_property::partition_by_counts)) { @@ -176,12 +179,8 @@ vector_class device_impl::create_sub_devices( if (MIsHostDevice) // TODO: implement host device partitioning throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet"); - - // TODO: implement host device partitioning - if (MIsHostDevice) - throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet"); + "Partitioning to subdevices of the host device is not implemented yet", + PI_INVALID_DEVICE); if (!is_partition_supported( info::partition_property::partition_by_affinity_domain) || diff --git a/sycl/source/detail/device_info.cpp b/sycl/source/detail/device_info.cpp index 948b402585e78..bb7d9732e18f3 100644 --- a/sycl/source/detail/device_info.cpp +++ b/sycl/source/detail/device_info.cpp @@ -34,7 +34,8 @@ device get_device_info::get( sizeof(result), &result, nullptr); if (result == nullptr) throw invalid_object_error( - "No parent for device because it is not a subdevice"); + "No parent for device because it is not a subdevice", + PI_INVALID_DEVICE); return createSyclObjFromImpl( std::make_shared(result, Plugin)); @@ -438,7 +439,8 @@ bool get_device_info_host() { template <> device get_device_info_host() { // TODO: implement host device partitioning throw runtime_error( - "Partitioning to subdevices of the host device is not implemented yet"); + "Partitioning to subdevices of the host device is not implemented yet", + PI_INVALID_DEVICE); } template <> @@ -481,20 +483,23 @@ template <> cl_uint get_device_info_host() { template <> cl_uint get_device_info_host() { // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device."); + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); } template <> vector_class get_device_info_host() { // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device."); + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); } template <> bool get_device_info_host< info::device::sub_group_independent_forward_progress>() { // TODO update once subgroups are enabled - throw runtime_error("Sub-group feature is not supported on HOST device."); + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); } template <> diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 7d18dea1d4c67..f1dc0de2c18b1 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -31,7 +31,8 @@ cl_event event_impl::get() const { return pi::cast(MEvent); } throw invalid_object_error( - "This instance of event doesn't support OpenCL interoperability."); + "This instance of event doesn't support OpenCL interoperability.", + PI_INVALID_DEVICE); } event_impl::~event_impl() { @@ -69,7 +70,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) if (MContext->is_host()) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " - "clEvent."); + "clEvent.", PI_INVALID_DEVICE); } RT::PiContext TempContext; @@ -78,7 +79,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) if (MContext->getHandleRef() != TempContext) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " - "clEvent."); + "clEvent.", PI_INVALID_CONTEXT); } getPlugin().call(MEvent); @@ -89,7 +90,7 @@ event_impl::event_impl(QueueImplPtr Queue) : MQueue(Queue) { Queue->has_property()) { MHostProfilingInfo.reset(new HostProfilingInfo()); if (!MHostProfilingInfo) - throw runtime_error("Out of host memory"); + throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); } } @@ -128,7 +129,8 @@ event_impl::get_profiling_info() const { this->getHandleRef(), this->getPlugin()); } if (!MHostProfilingInfo) - throw invalid_object_error("Profiling info is not available."); + throw invalid_object_error("Profiling info is not available.", + PI_INVALID_DEVICE); return MHostProfilingInfo->getStartTime(); } @@ -140,7 +142,8 @@ event_impl::get_profiling_info() const { this->getHandleRef(), this->getPlugin()); } if (!MHostProfilingInfo) - throw invalid_object_error("Profiling info is not available."); + throw invalid_object_error("Profiling info is not available.", + PI_INVALID_DEVICE); return MHostProfilingInfo->getStartTime(); } @@ -152,7 +155,8 @@ event_impl::get_profiling_info() const { this->getHandleRef(), this->getPlugin()); } if (!MHostProfilingInfo) - throw invalid_object_error("Profiling info is not available."); + throw invalid_object_error("Profiling info is not available.", + PI_INVALID_DEVICE); return MHostProfilingInfo->getEndTime(); } diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index 3c4fc11917f6f..0ff3272f203ba 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -304,14 +304,14 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Desc.image_width)) throw invalid_parameter_error( "For a 1D/2D image/image array, the width must be a Value >= 1 and " - "<= CL_DEVICE_IMAGE2D_MAX_WIDTH."); + "<= CL_DEVICE_IMAGE2D_MAX_WIDTH.", PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange(Context, Desc.image_width)) throw invalid_parameter_error( "For a 3D image, the width must be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_WIDTH"); + "CL_DEVICE_IMAGE3D_MAX_WIDTH", PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE2D, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -319,21 +319,22 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Context, Desc.image_height)) throw invalid_parameter_error("For a 2D image or image array, the height " "must be a Value >= 1 and <= " - "CL_DEVICE_IMAGE2D_MAX_HEIGHT"); + "CL_DEVICE_IMAGE2D_MAX_HEIGHT", + PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange( Context, Desc.image_height)) throw invalid_parameter_error( "For a 3D image, the heightmust be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_HEIGHT"); + "CL_DEVICE_IMAGE3D_MAX_HEIGHT", PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange(Context, Desc.image_depth)) throw invalid_parameter_error( "For a 3D image, the depth must be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_DEPTH"); + "CL_DEVICE_IMAGE3D_MAX_DEPTH", PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE1D_ARRAY, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -341,27 +342,28 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Context, Desc.image_array_size)) throw invalid_parameter_error( "For a 1D and 2D image array, the array_size must be a " - "Value >= 1 and <= " - "CL_DEVICE_IMAGE_MAX_ARRAY_SIZE."); + "Value >= 1 and <= CL_DEVICE_IMAGE_MAX_ARRAY_SIZE.", PI_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."); + "The row_pitch must be 0 if host_ptr is nullptr.", PI_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."); + "The slice_pitch must be 0 if host_ptr is nullptr.", PI_INVALID_VALUE); if (0 != Desc.num_mip_levels) - throw invalid_parameter_error("The mip_levels must be 0."); + throw invalid_parameter_error("The mip_levels must be 0.", + PI_INVALID_VALUE); if (0 != Desc.num_samples) - throw invalid_parameter_error("The num_samples must be 0."); + throw invalid_parameter_error("The num_samples must be 0.", + PI_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."); + "image creation from memory objects.", PI_INVALID_VALUE); return true; } @@ -379,7 +381,7 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "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. "); + "CL_SNORM_INT16, CL_HALF_FLOAT, or CL_FLOAT.", PI_INVALID_VALUE); if (checkAny(Format.image_channel_order, PI_IMAGE_CHANNEL_ORDER_RGB, PI_IMAGE_CHANNEL_ORDER_RGBx) && @@ -390,7 +392,7 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "CL_RGB or CL_RGBx These formats can only be used if channel data " "type = CL_UNORM_SHORT_565, CL_UNORM_SHORT_555 or " - "CL_UNORM_INT_101010. "); + "CL_UNORM_INT_101010.", PI_INVALID_VALUE); if (checkAny(Format.image_channel_order, PI_IMAGE_CHANNEL_ORDER_ARGB, PI_IMAGE_CHANNEL_ORDER_BGRA, PI_IMAGE_CHANNEL_ORDER_ABGR) && @@ -401,7 +403,7 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "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."); + "or CL_UNSIGNED_INT8.", PI_INVALID_VALUE); return true; } diff --git a/sycl/source/detail/kernel_impl.cpp b/sycl/source/detail/kernel_impl.cpp index 2b50fccc67a09..639d9a82af37d 100644 --- a/sycl/source/detail/kernel_impl.cpp +++ b/sycl/source/detail/kernel_impl.cpp @@ -37,7 +37,8 @@ kernel_impl::kernel_impl(RT::PiKernel Kernel, ContextImplPtr ContextImpl, MKernel, CL_KERNEL_CONTEXT, sizeof(Context), &Context, nullptr); if (ContextImpl->getHandleRef() != Context) throw cl::sycl::invalid_parameter_error( - "Input context must be the same as the context of cl_kernel"); + "Input context must be the same as the context of cl_kernel", + PI_INVALID_CONTEXT); getPlugin().call(MKernel); } @@ -88,7 +89,8 @@ template typename info::param_traits::return_type kernel_impl::get_sub_group_info(const device &Device) const { if (is_host()) { - throw runtime_error("Sub-group feature is not supported on HOST device."); + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); } return get_kernel_sub_group_info< typename info::param_traits::return_type, @@ -103,7 +105,8 @@ kernel_impl::get_sub_group_info( typename info::param_traits::input_type Value) const { if (is_host()) { - throw runtime_error("Sub-group feature is not supported on HOST device."); + throw runtime_error("Sub-group feature is not supported on HOST device.", + PI_INVALID_DEVICE); } return get_kernel_sub_group_info_with_input< typename info::param_traits::return_type, diff --git a/sycl/source/detail/kernel_info.cpp b/sycl/source/detail/kernel_info.cpp index 555835296cb07..cf0f18ca4381b 100644 --- a/sycl/source/detail/kernel_info.cpp +++ b/sycl/source/detail/kernel_info.cpp @@ -16,7 +16,8 @@ template <> cl::sycl::range<3> get_kernel_work_group_info_host( const cl::sycl::device &Dev) { - throw invalid_object_error("This instance of kernel is a host instance"); + throw invalid_object_error("This instance of kernel is a host instance", + PI_INVALID_KERNEL); } template <> diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index c44248f86a662..d7421c9d08667 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -200,7 +200,7 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, if (Error == PI_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"); + "multiple of the memory base address alignment", PI_INVALID_VALUE); return NewMem; } @@ -354,7 +354,8 @@ static void copyH2H(SYCLMemObjI *SYCLMemObj, char *SrcMem, (SrcOffset != id<3>{0, 0, 0} || DstOffset != id<3>{0, 0, 0} || SrcSize != SrcAccessRange || DstSize != DstAccessRange)) { assert(!"Not supported configuration of memcpy requested"); - throw runtime_error("Not supported configuration of memcpy requested"); + throw runtime_error("Not supported configuration of memcpy requested", + PI_INVALID_VALUE); } DstOffset[0] *= DstElemSize; @@ -427,7 +428,8 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, return; } assert(!"Not supported configuration of fill requested"); - throw runtime_error("Not supported configuration of fill requested"); + throw runtime_error("Not supported configuration of fill requested", + PI_INVALID_VALUE); } else { Plugin.call( Queue->getHandleRef(), pi::cast(Mem), Pattern, &Offset[0], @@ -443,7 +445,8 @@ void *MemoryManager::map(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, RT::PiEvent &OutEvent) { if (Queue->is_host()) { assert(!"Not supported configuration of map requested"); - throw runtime_error("Not supported configuration of map requested"); + throw runtime_error("Not supported configuration of map requested", + PI_INVALID_VALUE); } cl_map_flags Flags = 0; diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 364ca7158153f..8fc7b59976b44 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -101,13 +101,13 @@ static std::vector getWhiteListDesc() { } if (':' != *str) - throw sycl::runtime_error("Malformed device white list"); + throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); // Skip ':' str += 1; if ('{' != *str || '{' != *(str + 1)) - throw sycl::runtime_error("Malformed device white list"); + throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); // Skip opening sequence "{{" str += 2; @@ -119,7 +119,7 @@ static std::vector getWhiteListDesc() { ++str; if ('\0' == *str) - throw sycl::runtime_error("Malformed device white list"); + throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); *size = str - *valuePtr; @@ -133,7 +133,7 @@ static std::vector getWhiteListDesc() { if ('|' == *str) decDescs.emplace_back(); else if (',' != *str) - throw sycl::runtime_error("Malformed device white list"); + throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); ++str; } diff --git a/sycl/source/detail/platform_util.cpp b/sycl/source/detail/platform_util.cpp index 5929f049e277b..d59f6c4bd5cf5 100644 --- a/sycl/source/detail/platform_util.cpp +++ b/sycl/source/detail/platform_util.cpp @@ -31,7 +31,8 @@ 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"); + "max_clock_frequency parameter is not supported for host device", + PI_INVALID_DEVICE); uint32_t CPUInfo[4]; string_class Buff(sizeof(CPUInfo) * 3 + 1, 0); size_t Offset = 0; diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index a529d974082a4..de86e38e5cf67 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -33,7 +33,8 @@ program_impl::program_impl( MBuildOptions(LinkOptions) { // Verify arguments if (ProgramList.empty()) { - throw runtime_error("Non-empty vector of programs expected"); + throw runtime_error("Non-empty vector of programs expected", + PI_INVALID_VALUE); } MContext = ProgramList[0]->MContext; MDevices = ProgramList[0]->MDevices; @@ -46,14 +47,16 @@ program_impl::program_impl( Prg->throw_if_state_is_not(program_state::compiled); if (Prg->MContext != MContext) { throw invalid_object_error( - "Not all programs are associated with the same context"); + "Not all programs are associated with the same context", + PI_INVALID_CONTEXT); } if (!is_host()) { vector_class PrgDevicesSorted = sort_devices_by_cl_device_id(Prg->MDevices); if (PrgDevicesSorted != DevicesSorted) { throw invalid_object_error( - "Not all programs are associated with the same devices"); + "Not all programs are associated with the same devices", + PI_INVALID_PROGRAM); } } } @@ -152,7 +155,8 @@ program_impl::~program_impl() { cl_program program_impl::get() const { throw_if_state_is(program_state::none); if (is_host()) { - throw invalid_object_error("This instance of program is a host instance"); + throw invalid_object_error("This instance of program is a host instance", + PI_INVALID_DEVICE); } const detail::plugin &Plugin = getPlugin(); Plugin.call(MProgram); @@ -245,7 +249,8 @@ kernel program_impl::get_kernel(string_class KernelName, throw_if_state_is(program_state::none); if (is_host()) { if (IsCreatedFromSource) - throw invalid_object_error("This instance of program is a host instance"); + throw invalid_object_error("This instance of program is a host instance", + PI_INVALID_DEVICE); return createSyclObjFromImpl( std::make_shared(MContext, PtrToSelf)); @@ -297,7 +302,7 @@ void program_impl::compile(const string_class &Options) { if (Err != PI_SUCCESS) { throw compile_program_error( "Program compilation error:\n" + - ProgramManager::getProgramBuildLog(MProgram, MContext)); + ProgramManager::getProgramBuildLog(MProgram, MContext), Err); } MCompileOptions = Options; } @@ -313,7 +318,7 @@ void program_impl::build(const string_class &Options) { if (Err != PI_SUCCESS) { throw compile_program_error( "Program build error:\n" + - ProgramManager::getProgramBuildLog(MProgram, MContext)); + ProgramManager::getProgramBuildLog(MProgram, MContext), Err); } MBuildOptions = Options; MCompileOptions = Options; @@ -359,7 +364,7 @@ RT::PiKernel program_impl::get_pi_kernel(const string_class &KernelName) const { MProgram, KernelName.c_str(), &Kernel); if (Err == PI_RESULT_INVALID_KERNEL_NAME) { throw invalid_object_error( - "This instance of program does not contain the kernel requested"); + "This instance of program does not contain the kernel requested", Err); } Plugin.checkPiResult(Err); } @@ -379,13 +384,13 @@ program_impl::sort_devices_by_cl_device_id(vector_class Devices) { void program_impl::throw_if_state_is(program_state State) const { if (MState == State) { - throw invalid_object_error("Invalid program state"); + throw invalid_object_error("Invalid program state", PI_INVALID_PROGRAM); } } void program_impl::throw_if_state_is_not(program_state State) const { if (MState != State) { - throw invalid_object_error("Invalid program state"); + throw invalid_object_error("Invalid program state", PI_INVALID_PROGRAM); } } @@ -400,7 +405,8 @@ void program_impl::create_pi_program_with_kernel_name( template <> cl_uint program_impl::get_info() const { if (is_host()) { - throw invalid_object_error("This instance of program is a host instance"); + throw invalid_object_error("This instance of program is a host instance", + PI_INVALID_DEVICE); } cl_uint Result; const detail::plugin &Plugin = getPlugin(); diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index 720bbfe92de8b..edfb979b4db64 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -276,10 +276,12 @@ RT::PiProgram ProgramManager::createPIProgram(const DeviceImage &Img, // perform minimal sanity checks on the device image and the descriptor if (Img.BinaryEnd < Img.BinaryStart) { - throw runtime_error("Malformed device program image descriptor"); + throw runtime_error("Malformed device program image descriptor", + PI_INVALID_VALUE); } if (Img.BinaryEnd == Img.BinaryStart) { - throw runtime_error("Invalid device program image: size is zero"); + throw runtime_error("Invalid device program image: size is zero", + PI_INVALID_VALUE); } size_t ImgSize = static_cast(Img.BinaryEnd - Img.BinaryStart); @@ -295,7 +297,8 @@ RT::PiProgram ProgramManager::createPIProgram(const DeviceImage &Img, if (!isDeviceBinaryTypeSupported(Context, Format)) throw feature_not_supported( - "Online compilation is not supported in this context"); + "Online compilation is not supported in this context", + PI_INVALID_OPERATION); // Load the image const ContextImplPtr Ctx = getSyclObjImpl(Context); @@ -473,7 +476,8 @@ static const char* getDeviceLibFilename(DeviceLibExt Extension) { case cl_intel_devicelib_complex_fp64: return "libsycl-fallback-complex-fp64.spv"; } - throw compile_program_error("Unhandled (new?) device library extension"); + throw compile_program_error("Unhandled (new?) device library extension", + PI_INVALID_OPERATION); } static const char* getDeviceLibExtensionStr(DeviceLibExt Extension) { @@ -489,7 +493,8 @@ static const char* getDeviceLibExtensionStr(DeviceLibExt Extension) { case cl_intel_devicelib_complex_fp64: return "cl_intel_devicelib_complex_fp64"; } - throw compile_program_error("Unhandled (new?) device library extension"); + throw compile_program_error("Unhandled (new?) device library extension", + PI_INVALID_OPERATION); } static RT::PiProgram loadDeviceLibFallback( @@ -510,7 +515,8 @@ static RT::PiProgram loadDeviceLibFallback( if (!loadDeviceLib(Context, LibFileName, LibProg)) { CachedLibPrograms.erase(LibProgIt); - throw compile_program_error(std::string("Failed to load ") + LibFileName); + throw compile_program_error(std::string("Failed to load ") + LibFileName, + PI_INVALID_VALUE); } const detail::plugin &Plugin = Context->getPlugin(); @@ -526,7 +532,7 @@ static RT::PiProgram loadDeviceLibFallback( if (Error != PI_SUCCESS) { CachedLibPrograms.erase(LibProgIt); throw compile_program_error( - ProgramManager::getProgramBuildLog(LibProg, Context)); + ProgramManager::getProgramBuildLog(LibProg, Context), Error); } return LibProg; @@ -550,7 +556,8 @@ ProgramManager::ProgramManager() { if (!File.is_open()) throw runtime_error(std::string("Can't open file specified via ") + - UseSpvEnv + ": " + SpvFile); + UseSpvEnv + ": " + SpvFile, + PI_INVALID_VALUE); File.seekg(0, std::ios::end); size_t Size = File.tellg(); std::unique_ptr Data(new unsigned char[Size]); @@ -559,7 +566,7 @@ ProgramManager::ProgramManager() { File.close(); if (!File.good()) throw runtime_error(std::string("read from ") + SpvFile + - std::string(" failed")); + std::string(" failed"), PI_INVALID_VALUE); std::unique_ptr ImgPtr(new DeviceImage(), ImageDeleter()); @@ -732,7 +739,8 @@ ProgramManager::build(ProgramPtr Program, const ContextImplPtr Context, Program.get(), Devices.size(), Devices.data(), Opts.c_str(), nullptr, nullptr); if (Error != PI_SUCCESS) - throw compile_program_error(getProgramBuildLog(Program.get(), Context)); + throw compile_program_error(getProgramBuildLog(Program.get(), Context), + Error); return Program; } @@ -754,7 +762,8 @@ ProgramManager::build(ProgramPtr Program, const ContextImplPtr Context, if (LinkedProg) { // A non-trivial error occurred during linkage: get a build log, release // an incomplete (but valid) LinkedProg, and throw. - throw compile_program_error(getProgramBuildLog(LinkedProg, Context)); + throw compile_program_error(getProgramBuildLog(LinkedProg, Context), + Error); } Plugin.checkPiResult(Error); } @@ -868,7 +877,8 @@ ProgramManager::getKernelSetId(OSModuleHandle M, if (ModuleKSIdIt != m_OSModuleKernelSets.end()) return ModuleKSIdIt->second; - throw runtime_error("No kernel named " + KernelName + " was found"); + throw runtime_error("No kernel named " + KernelName + " was found", + PI_RESULT_INVALID_KERNEL_NAME); } RT::PiDeviceBinaryType ProgramManager::getFormat(const DeviceImage &Img) const { @@ -918,7 +928,8 @@ void ProgramManager::dumpImage(const DeviceImage &Img, KernelSetId KSId) const { std::ofstream F(Fname, std::ios::binary); if (!F.is_open()) { - throw runtime_error(std::string("Can not write ") + Fname); + throw runtime_error(std::string("Can not write ") + Fname, + PI_INVALID_VALUE); } size_t ImgSize = static_cast(Img.BinaryEnd - Img.BinaryStart); F.write(reinterpret_cast(Img.BinaryStart), ImgSize); diff --git a/sycl/source/detail/sampler_impl.cpp b/sycl/source/detail/sampler_impl.cpp index 56c2d345b7c1d..96ef75cc0bf5f 100644 --- a/sycl/source/detail/sampler_impl.cpp +++ b/sycl/source/detail/sampler_impl.cpp @@ -65,7 +65,8 @@ RT::PiSampler sampler_impl::getOrCreateSampler(const context &Context) { getSyclObjImpl(Context)->getHandleRef(), sprops, &resultSampler); if (errcode_ret == PI_INVALID_OPERATION) - throw feature_not_supported("Images are not supported by this device."); + throw feature_not_supported("Images are not supported by this device.", + errcode_ret); Plugin.checkPiResult(errcode_ret); m_contextToSampler[Context] = resultSampler; diff --git a/sycl/source/detail/scheduler/commands.cpp b/sycl/source/detail/scheduler/commands.cpp index 6e1b8d246364b..86938420cf3d0 100644 --- a/sycl/source/detail/scheduler/commands.cpp +++ b/sycl/source/detail/scheduler/commands.cpp @@ -506,7 +506,7 @@ AllocaCommandBase *ExecCGCommand::getAllocaForReq(Requirement *Req) { if (Dep.MDepRequirement == Req) return Dep.MAllocaCmd; } - throw runtime_error("Alloca for command not found"); + throw runtime_error("Alloca for command not found", PI_INVALID_OPERATION); } void ExecCGCommand::flushStreams() { @@ -764,7 +764,8 @@ cl_int ExecCGCommand::enqueueImp() { case CG::CGTYPE::UPDATE_HOST: { assert(!"Update host should be handled by the Scheduler."); - throw runtime_error("Update host should be handled by the Scheduler."); + throw runtime_error("Update host should be handled by the Scheduler.", + PI_INVALID_OPERATION); } case CG::CGTYPE::COPY_ACC_TO_PTR: { CGCopy *Copy = (CGCopy *)MCommandGroup.get(); @@ -1007,7 +1008,7 @@ cl_int ExecCGCommand::enqueueImp() { } case CG::CGTYPE::NONE: default: - throw runtime_error("CG type not implemented."); + throw runtime_error("CG type not implemented.", PI_INVALID_OPERATION); } } diff --git a/sycl/source/detail/scheduler/graph_builder.cpp b/sycl/source/detail/scheduler/graph_builder.cpp index bbc5d13b79b19..e6fe7706235a3 100644 --- a/sycl/source/detail/scheduler/graph_builder.cpp +++ b/sycl/source/detail/scheduler/graph_builder.cpp @@ -230,7 +230,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record, AllocaCommandBase *AllocaCmdDst = getOrCreateAllocaForReq(Record, Req, Queue); if (!AllocaCmdDst) - throw runtime_error("Out of host memory"); + throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); std::set Deps = findDepsForReq(Record, Req, Queue->getContextImplPtr()); @@ -264,7 +264,7 @@ Command *Scheduler::GraphBuilder::insertMemoryMove(MemObjRecord *Record, AllocaCmdSrc = (Record->MAllocaCommands.end() != It) ? *It : nullptr; } if (!AllocaCmdSrc) - throw runtime_error("Cannot find buffer allocation"); + throw runtime_error("Cannot find buffer allocation", PI_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) @@ -322,7 +322,7 @@ Command *Scheduler::GraphBuilder::addCopyBack(Requirement *Req) { SrcAllocaCmd->getQueue(), std::move(HostQueue))); if (!MemCpyCmdUniquePtr) - throw runtime_error("Out of host memory"); + throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); MemCpyCommandHost *MemCpyCmd = MemCpyCmdUniquePtr.release(); for (Command *Dep : Deps) { @@ -592,7 +592,7 @@ Scheduler::GraphBuilder::addCG(std::unique_ptr CommandGroup, std::unique_ptr NewCmd( new ExecCGCommand(std::move(CommandGroup), Queue)); if (!NewCmd) - throw runtime_error("Out of host memory"); + throw runtime_error("Out of host memory", PI_OUT_OF_HOST_MEMORY); if (MPrintOptionsArray[BeforeAddCG]) printGraphAsDot("before_addCG"); diff --git a/sycl/source/detail/scheduler/graph_processor.cpp b/sycl/source/detail/scheduler/graph_processor.cpp index e9ccb51f2b57c..5ac84eda08cfd 100644 --- a/sycl/source/detail/scheduler/graph_processor.cpp +++ b/sycl/source/detail/scheduler/graph_processor.cpp @@ -43,7 +43,7 @@ void Scheduler::GraphProcessor::waitForEvent(EventImplPtr Event) { bool Enqueued = enqueueCommand(Cmd, Res, BLOCKING); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) // TODO: Reschedule commands. - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); RT::PiEvent &CLEvent = Cmd->getEvent()->getHandleRef(); if (CLEvent) { diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index b4f8c3af47174..e16afed2aaa25 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -25,14 +25,14 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); GraphProcessor::waitForEvent(Cmd->getEvent()); } for (Command *Cmd : Record->MWriteLeaves) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); GraphProcessor::waitForEvent(Cmd->getEvent()); } for (AllocaCommandBase *AllocaCmd : Record->MAllocaCommands) { @@ -40,7 +40,7 @@ void Scheduler::waitForRecordToFinish(MemObjRecord *Record) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(ReleaseCmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); GraphProcessor::waitForEvent(ReleaseCmd->getEvent()); } } @@ -65,7 +65,7 @@ EventImplPtr Scheduler::addCG(std::unique_ptr CommandGroup, EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); } if (IsKernel) @@ -86,7 +86,7 @@ EventImplPtr Scheduler::addCopyBack(Requirement *Req) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); } catch (...) { NewCmd->getQueue()->reportAsyncException(std::current_exception()); } @@ -145,7 +145,7 @@ EventImplPtr Scheduler::addHostAccessor(Requirement *Req) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(NewCmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); return NewCmd->getEvent(); } @@ -157,7 +157,7 @@ void Scheduler::releaseHostAccessor(Requirement *Req) { EnqueueResultT Res; bool Enqueued = GraphProcessor::enqueueCommand(Cmd, Res); if (!Enqueued && EnqueueResultT::FAILED == Res.MResult) - throw runtime_error("Enqueue process failed."); + throw runtime_error("Enqueue process failed.", PI_INVALID_OPERATION); } }; EnqueueLeaves(Record->MReadLeaves); diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 0069bd384daf9..a80b02bae41e3 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -28,17 +28,18 @@ SYCLMemObjT::SYCLMemObjT(cl_mem MemObject, const context &SyclContext, if (MInteropContext->is_host()) throw cl::sycl::invalid_parameter_error( "Creation of interoperability memory object using host context is " - "not allowed"); + "not allowed", PI_INVALID_OPERATION); RT::PiMem Mem = pi::cast(MInteropMemObject); RT::PiContext Context = nullptr; const plugin &Plugin = getPlugin(); Plugin.call(Mem, CL_MEM_CONTEXT, sizeof(Context), - &Context, nullptr); + &Context, nullptr); if (MInteropContext->getHandleRef() != Context) throw cl::sycl::invalid_parameter_error( - "Input context must be the same as the context of cl_mem"); + "Input context must be the same as the context of cl_mem", + PI_INVALID_CONTEXT); Plugin.call(Mem); } diff --git a/sycl/source/detail/usm/usm_impl.cpp b/sycl/source/detail/usm/usm_impl.cpp index ce4978e20aa0d..4f95832be410d 100644 --- a/sycl/source/detail/usm/usm_impl.cpp +++ b/sycl/source/detail/usm/usm_impl.cpp @@ -293,7 +293,7 @@ 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!"); + throw runtime_error("Ptr not a valid USM allocation!", PI_INVALID_VALUE); // Just return the host device in the host context if (Ctxt.is_host()) @@ -305,7 +305,7 @@ 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!"); + throw runtime_error("No devices in passed context!", PI_INVALID_VALUE); // Just return the first device in the context return Devs[0]; @@ -325,7 +325,8 @@ device get_pointer_device(const void *Ptr, const context &Ctxt) { return Dev; } - throw runtime_error("Cannot find device associated with USM allocation!"); + throw runtime_error("Cannot find device associated with USM allocation!", + PI_INVALID_OPERATION); } } // namespace sycl diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index ac6abf7a70c4a..a3fe2adffcda2 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -19,7 +19,8 @@ void force_type(info::device_type &t, const info::device_type &ft) { if (t == info::device_type::all) { t = ft; } else if (ft != info::device_type::all && t != ft) { - throw cl::sycl::invalid_parameter_error("No device of forced type."); + throw cl::sycl::invalid_parameter_error("No device of forced type.", + PI_INVALID_OPERATION); } } } // namespace detail diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index aea9cbfba6572..69545910f2a5a 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -27,7 +27,8 @@ device device_selector::select_device() const { if (res != nullptr) return *res; - throw cl::sycl::runtime_error("No device of requested type available."); + throw cl::sycl::runtime_error("No device of requested type available.", + PI_INVALID_OPERATION); } int default_selector::operator()(const device &dev) const { diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index a271509dd64ab..b053df045a617 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -73,9 +73,10 @@ event handler::finalize() { break; case detail::CG::NONE: throw runtime_error("Command group submitted without a kernel or a " - "explicit memory operation."); + "explicit memory operation.", PI_INVALID_OPERATION); default: - throw runtime_error("Unhandled type of command group"); + throw runtime_error("Unhandled type of command group", + PI_INVALID_OPERATION); } detail::EventImplPtr Event = detail::Scheduler::getInstance().addCG( @@ -168,7 +169,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."); + "Unsupported accessor target case.", PI_INVALID_OPERATION); break; } } diff --git a/sycl/source/ordered_queue.cpp b/sycl/source/ordered_queue.cpp index 80d3b130550e1..4331cfb30bf03 100644 --- a/sycl/source/ordered_queue.cpp +++ b/sycl/source/ordered_queue.cpp @@ -56,7 +56,8 @@ ordered_queue::ordered_queue(cl_command_queue clQueue, &reportedProps, nullptr); if (reportedProps & CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE) throw runtime_error( - "Failed to build a sycl ordered queue from a cl OOO queue."); + "Failed to build a sycl ordered queue from a cl OOO queue.", + PI_INVALID_OPERATION); impl = std::make_shared( m_CommandQueue, detail::getSyclObjImpl(syclContext), asyncHandler); diff --git a/sycl/test/sub_group/attributes.cpp b/sycl/test/sub_group/attributes.cpp index e032de24f30db..027327324329e 100644 --- a/sycl/test/sub_group/attributes.cpp +++ b/sycl/test/sub_group/attributes.cpp @@ -101,7 +101,8 @@ int main() { submit(Queue); break; default: - throw feature_not_supported("sub-group size is not supported"); + throw feature_not_supported("sub-group size is not supported", + PI_INVALID_OPERATION); } auto Kernel = TheKernel[0]; diff --git a/sycl/test/sub_group/common_ocl.cpp b/sycl/test/sub_group/common_ocl.cpp index 19f125d5036f0..f324f0b9044c3 100644 --- a/sycl/test/sub_group/common_ocl.cpp +++ b/sycl/test/sub_group/common_ocl.cpp @@ -38,7 +38,7 @@ void check(queue &Queue, const int G, const int L, const char *SpvFile) { std::ifstream File(SpvFile, std::ios::binary); if (!File.is_open()) { std::cerr << std::strerror(errno); - throw compile_program_error("Cannot open SPIRV file\n"); + throw compile_program_error("Cannot open SPIRV file\n", PI_INVALID_VALUE); } File.seekg(0, std::ios::end); vector_class Spv(File.tellg()); From 2c9a5b9e8284a7681b6ed5390f99ec3930a4a4f0 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Fri, 21 Feb 2020 10:53:33 +0300 Subject: [PATCH 2/9] [SYCL] Fix review comments Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/detail/pi.h | 4 +++- sycl/include/CL/sycl/detail/platform_impl.hpp | 4 ++-- sycl/include/CL/sycl/detail/program_impl.hpp | 2 +- sycl/include/CL/sycl/detail/queue_impl.hpp | 2 +- sycl/source/detail/event_impl.cpp | 10 +++++----- sycl/source/detail/memory_manager.cpp | 6 +++--- sycl/source/detail/program_impl.cpp | 2 +- 7 files changed, 16 insertions(+), 14 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index e0ec490348a75..56f62088ebec4 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -66,7 +66,9 @@ typedef enum { PI_MISALIGNED_SUB_BUFFER_OFFSET = CL_MISALIGNED_SUB_BUFFER_OFFSET, PI_OUT_OF_HOST_MEMORY = CL_OUT_OF_HOST_MEMORY, PI_INVALID_WORK_GROUP_SIZE = CL_INVALID_WORK_GROUP_SIZE, - PI_INVALID_PROGRAM = CL_INVALID_PROGRAM + PI_INVALID_PROGRAM = CL_INVALID_PROGRAM, + PI_COMPILER_NOT_AVAILABLE = CL_COMPILER_NOT_AVAILABLE, + PI_PROFILING_INFO_NOT_AVAILABLE = CL_PROFILING_INFO_NOT_AVAILABLE } _pi_result; typedef enum { diff --git a/sycl/include/CL/sycl/detail/platform_impl.hpp b/sycl/include/CL/sycl/detail/platform_impl.hpp index 51b2743e1c54a..ad712d4c64118 100644 --- a/sycl/include/CL/sycl/detail/platform_impl.hpp +++ b/sycl/include/CL/sycl/detail/platform_impl.hpp @@ -73,7 +73,7 @@ class platform_impl { cl_platform_id get() const { if (is_host()) throw invalid_object_error( - "This instance of platform is a host instance", PI_INVALID_DEVICE); + "This instance of platform is a host instance", PI_INVALID_PLATFORM); return pi::cast(MPlatform); } @@ -88,7 +88,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_DEVICE); + "This instance of platform is a host instance", PI_INVALID_PLATFORM); return MPlatform; } diff --git a/sycl/include/CL/sycl/detail/program_impl.hpp b/sycl/include/CL/sycl/detail/program_impl.hpp index 38490e7f7ec2c..50b7de8f0670f 100644 --- a/sycl/include/CL/sycl/detail/program_impl.hpp +++ b/sycl/include/CL/sycl/detail/program_impl.hpp @@ -297,7 +297,7 @@ class program_impl { if (!Device.get_info()) { throw feature_not_supported( "Online compilation is not supported by this device", - PI_INVALID_DEVICE); + PI_COMPILER_NOT_AVAILABLE); } } } diff --git a/sycl/include/CL/sycl/detail/queue_impl.hpp b/sycl/include/CL/sycl/detail/queue_impl.hpp index 49df14cccb1d1..446854fd3039d 100644 --- a/sycl/include/CL/sycl/detail/queue_impl.hpp +++ b/sycl/include/CL/sycl/detail/queue_impl.hpp @@ -118,7 +118,7 @@ class queue_impl { } throw invalid_object_error( "This instance of queue doesn't support OpenCL interoperability", - PI_INVALID_DEVICE); + PI_INVALID_OPERATION); } /// @return an associated SYCL context. diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index f1dc0de2c18b1..24f9b950fe5dd 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -32,7 +32,7 @@ cl_event event_impl::get() const { } throw invalid_object_error( "This instance of event doesn't support OpenCL interoperability.", - PI_INVALID_DEVICE); + PI_INVALID_OPERATION); } event_impl::~event_impl() { @@ -70,7 +70,7 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) if (MContext->is_host()) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " - "clEvent.", PI_INVALID_DEVICE); + "clEvent.", PI_INVALID_CONTEXT); } RT::PiContext TempContext; @@ -130,7 +130,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_INVALID_DEVICE); + PI_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getStartTime(); } @@ -143,7 +143,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_INVALID_DEVICE); + PI_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getStartTime(); } @@ -156,7 +156,7 @@ event_impl::get_profiling_info() const { } if (!MHostProfilingInfo) throw invalid_object_error("Profiling info is not available.", - PI_INVALID_DEVICE); + PI_PROFILING_INFO_NOT_AVAILABLE); return MHostProfilingInfo->getEndTime(); } diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index d7421c9d08667..9a760d07f5e5c 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -355,7 +355,7 @@ static void copyH2H(SYCLMemObjI *SYCLMemObj, char *SrcMem, SrcSize != SrcAccessRange || DstSize != DstAccessRange)) { assert(!"Not supported configuration of memcpy requested"); throw runtime_error("Not supported configuration of memcpy requested", - PI_INVALID_VALUE); + PI_INVALID_OPERATION); } DstOffset[0] *= DstElemSize; @@ -429,7 +429,7 @@ void MemoryManager::fill(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, } assert(!"Not supported configuration of fill requested"); throw runtime_error("Not supported configuration of fill requested", - PI_INVALID_VALUE); + PI_INVALID_OPERATION); } else { Plugin.call( Queue->getHandleRef(), pi::cast(Mem), Pattern, &Offset[0], @@ -446,7 +446,7 @@ void *MemoryManager::map(SYCLMemObjI *SYCLMemObj, void *Mem, QueueImplPtr Queue, if (Queue->is_host()) { assert(!"Not supported configuration of map requested"); throw runtime_error("Not supported configuration of map requested", - PI_INVALID_VALUE); + PI_INVALID_OPERATION); } cl_map_flags Flags = 0; diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index de86e38e5cf67..184e38925d719 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -406,7 +406,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_DEVICE); + PI_INVALID_OPERATION); } cl_uint Result; const detail::plugin &Plugin = getPlugin(); From 10b0e9ddb532e498368542584aee8dea7fec546a Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 26 Feb 2020 15:49:31 +0300 Subject: [PATCH 3/9] [SYCL] Fix review comments. Fix formatting Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/accessor.hpp | 5 +- sycl/include/CL/sycl/detail/cg.hpp | 4 +- .../CL/sycl/detail/image_accessor_util.hpp | 42 +++++++++++------ sycl/include/CL/sycl/detail/pi.h | 46 +++++++++---------- .../include/CL/sycl/detail/sycl_mem_obj_t.hpp | 3 +- sycl/include/CL/sycl/exception.hpp | 6 +-- sycl/include/CL/sycl/types.hpp | 6 ++- sycl/source/detail/context_impl.cpp | 2 +- sycl/source/detail/event_impl.cpp | 8 ++-- sycl/source/detail/image_impl.cpp | 27 +++++++---- sycl/source/detail/memory_manager.cpp | 3 +- sycl/source/detail/platform_impl.cpp | 12 +++-- sycl/source/detail/platform_impl.hpp | 8 ++-- sycl/source/detail/program_impl.cpp | 11 +++-- .../program_manager/program_manager.cpp | 5 +- sycl/source/detail/queue_impl.hpp | 2 +- sycl/source/detail/sycl_mem_obj_t.cpp | 3 +- sycl/source/handler.cpp | 3 +- 18 files changed, 116 insertions(+), 80 deletions(-) diff --git a/sycl/include/CL/sycl/accessor.hpp b/sycl/include/CL/sycl/accessor.hpp index d930070c7999d..baa869fc3eaf3 100644 --- a/sycl/include/CL/sycl/accessor.hpp +++ b/sycl/include/CL/sycl/accessor.hpp @@ -358,9 +358,8 @@ class image_accessor sycl::vec getRangeInternal() const { // TODO: Implement for host. - throw runtime_error( - "image::getRangeInternal() is not implemented for host", - PI_INVALID_OPERATION); + throw runtime_error("image::getRangeInternal() is not implemented for host", + PI_INVALID_OPERATION); return sycl::vec{1}; } diff --git a/sycl/include/CL/sycl/detail/cg.hpp b/sycl/include/CL/sycl/detail/cg.hpp index 0a5cf07cc4571..e4d0a0d30967c 100644 --- a/sycl/include/CL/sycl/detail/cg.hpp +++ b/sycl/include/CL/sycl/detail/cg.hpp @@ -280,7 +280,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_VALUE); + PI_INVALID_WORK_GROUP_SIZE); GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I]; } @@ -322,7 +322,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_VALUE); + PI_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 f7a5a6295d94c..f0a4cefbe43b0 100644 --- a/sycl/include/CL/sycl/detail/image_accessor_util.hpp +++ b/sycl/include/CL/sycl/detail/image_accessor_util.hpp @@ -295,7 +295,8 @@ void convertReadData(const vec PixelData, // unsigned_int32. 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); + "image_channel_type of the image.", + PI_INVALID_VALUE); } } @@ -316,7 +317,8 @@ void convertReadData(const vec PixelData, // signed_int32. 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); + "image_channel_type of the image.", + PI_INVALID_VALUE); } } @@ -397,7 +399,8 @@ void convertReadData(const vec PixelData, // and signed/unsigned_int32. 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); + "image_channel_type of the image.", + PI_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. @@ -427,7 +430,8 @@ void convertReadData(const vec PixelData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_half4.", PI_INVALID_OPERATION); + "to cl_half4.", + PI_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -439,14 +443,16 @@ void convertReadData(const vec PixelData, // and signed/unsigned_int32. throw cl::sycl::invalid_parameter_error( "Datatype to read- cl_half4 is incompatible with the " - "image_channel_type of the image.", PI_INVALID_VALUE); + "image_channel_type of the image.", + PI_INVALID_VALUE); case image_channel_type::fp16: RetData = PixelData.template convert(); break; case image_channel_type::fp32: throw cl::sycl::invalid_parameter_error( "Datatype to read - cl_half4 is incompatible with the " - "image_channel_type of the image.", PI_INVALID_VALUE); + "image_channel_type of the image.", + PI_INVALID_VALUE); default: break; } @@ -486,7 +492,8 @@ convertWriteData(const vec WriteData, // unsigned_int32. 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); + "image_channel_type of the image.", + PI_INVALID_VALUE); } } @@ -518,7 +525,8 @@ convertWriteData(const vec WriteData, // signed_int32. 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); + "image_channel_type of the image.", + PI_INVALID_VALUE); } } @@ -556,7 +564,8 @@ convertWriteData(const vec WriteData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_float4.", PI_INVALID_OPERATION); + "to cl_float4.", + PI_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. @@ -598,7 +607,8 @@ convertWriteData(const vec WriteData, // and signed/unsigned_int32. 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); + "image_channel_type of the image.", + PI_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. @@ -626,7 +636,8 @@ convertWriteData(const vec WriteData, // TODO: Missing information in OpenCL spec. throw cl::sycl::feature_not_supported( "Currently unsupported datatype conversion from image_channel_type " - "to cl_half4.", PI_INVALID_OPERATION); + "to cl_half4.", + PI_INVALID_OPERATION); case image_channel_type::signed_int8: case image_channel_type::signed_int16: case image_channel_type::signed_int32: @@ -638,13 +649,15 @@ convertWriteData(const vec WriteData, // and signed/unsigned_int32. 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); + "image_channel_type of the image.", + PI_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); + "image_channel_type of the image.", + PI_INVALID_VALUE); default: break; } @@ -1009,7 +1022,8 @@ DataT imageReadSamplerHostImpl(const CoordT &Coords, const sampler &Smpl, throw cl::sycl::feature_not_supported( "Sampler used with unsupported configuration of " "mirrored_repeat/repeat filtering mode with unnormalized " - "coordinates. ", PI_INVALID_OPERATION); + "coordinates. ", + PI_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 7800cb218279b..5d56c8cbe39c9 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -53,29 +53,29 @@ typedef pi_uint64 pi_bitfield; // TODO: populate PI enums. // typedef enum { - PI_SUCCESS = CL_SUCCESS, - PI_RESULT_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_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_SUCCESS = CL_SUCCESS, + PI_RESULT_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_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_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_ERROR_UNKNOWN = -999 + PI_ERROR_UNKNOWN = -999 } _pi_result; typedef enum { @@ -220,8 +220,8 @@ typedef enum { // TODO: populate typedef enum { - PI_CONTEXT_INFO_DEVICES = CL_CONTEXT_DEVICES, - PI_CONTEXT_INFO_NUM_DEVICES = CL_CONTEXT_NUM_DEVICES, + PI_CONTEXT_INFO_DEVICES = CL_CONTEXT_DEVICES, + PI_CONTEXT_INFO_NUM_DEVICES = CL_CONTEXT_NUM_DEVICES, PI_CONTEXT_INFO_REFERENCE_COUNT = CL_CONTEXT_REFERENCE_COUNT } _pi_context_info; 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 784a47752790b..ba6e6ba11c7fe 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -236,7 +236,8 @@ class SYCLMemObjT : public SYCLMemObjI { if (useHostPtr()) throw invalid_parameter_error( "Buffer constructor from a pair of iterator values does not support " - "use_host_ptr property.", PI_INVALID_OPERATION); + "use_host_ptr property.", + PI_INVALID_OPERATION); setAlign(RequiredAlign); MShadowCopy = allocateHostMem(); diff --git a/sycl/include/CL/sycl/exception.hpp b/sycl/include/CL/sycl/exception.hpp index 08811c2aba528..781d108ec0dfa 100644 --- a/sycl/include/CL/sycl/exception.hpp +++ b/sycl/include/CL/sycl/exception.hpp @@ -59,8 +59,7 @@ class runtime_error : public exception { runtime_error(const char *Msg, cl_int Err) : runtime_error(string_class(Msg), Err) {} - runtime_error(const string_class &Msg, cl_int Err) - : exception(Msg, Err) {} + runtime_error(const string_class &Msg, cl_int Err) : exception(Msg, Err) {} }; class kernel_error : public runtime_error { using runtime_error::runtime_error; @@ -84,8 +83,7 @@ class device_error : public exception { device_error(const char *Msg, cl_int Err) : device_error(string_class(Msg), Err) {} - device_error(const string_class &Msg, cl_int Err) - : exception(Msg, Err) {} + device_error(const string_class &Msg, cl_int Err) : exception(Msg, Err) {} }; class compile_program_error : public device_error { using device_error::device_error; diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index 0fb2950dca89b..47a2db3dfc8c1 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -243,11 +243,13 @@ detail::enable_if_t::value, R> convertImpl(T Value) { int OldRoundingDirection = std::fegetround(); int Err = std::fesetround(FE_TONEAREST); if (Err) - throw std::runtime_error("Unable to set rounding mode to FE_TONEAREST"); + throw runtime_error("Unable to set rounding mode to FE_TONEAREST", + PI_ERROR_UNKNOWN); R Result = std::rint(Value); Err = std::fesetround(OldRoundingDirection); if (Err) - throw std::runtime_error("Unable to restore rounding mode."); + throw std::runtime_error("Unable to restore rounding mode.", + PI_ERROR_UNKNOWN); return Result; } // Round toward zero. diff --git a/sycl/source/detail/context_impl.cpp b/sycl/source/detail/context_impl.cpp index d46a2bb970c8f..c6ee313722312 100644 --- a/sycl/source/detail/context_impl.cpp +++ b/sycl/source/detail/context_impl.cpp @@ -99,7 +99,7 @@ cl_context context_impl::get() const { } throw invalid_object_error( "This instance of context doesn't support OpenCL interoperability.", - PI_INVALID_DEVICE); + PI_INVALID_CONTEXT); } bool context_impl::is_host() const { return MHostContext || !MPluginInterop; } diff --git a/sycl/source/detail/event_impl.cpp b/sycl/source/detail/event_impl.cpp index 8a1a2af45e595..126cb8a1a8204 100644 --- a/sycl/source/detail/event_impl.cpp +++ b/sycl/source/detail/event_impl.cpp @@ -32,7 +32,7 @@ cl_event event_impl::get() const { } throw invalid_object_error( "This instance of event doesn't support OpenCL interoperability.", - PI_INVALID_OPERATION); + PI_INVALID_EVENT); } event_impl::~event_impl() { @@ -70,7 +70,8 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) if (MContext->is_host()) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " - "clEvent.", PI_INVALID_CONTEXT); + "clEvent.", + PI_INVALID_CONTEXT); } RT::PiContext TempContext; @@ -79,7 +80,8 @@ event_impl::event_impl(RT::PiEvent Event, const context &SyclContext) if (MContext->getHandleRef() != TempContext) { throw cl::sycl::invalid_parameter_error( "The syclContext must match the OpenCL context associated with the " - "clEvent.", PI_INVALID_CONTEXT); + "clEvent.", + PI_INVALID_CONTEXT); } getPlugin().call(MEvent); diff --git a/sycl/source/detail/image_impl.cpp b/sycl/source/detail/image_impl.cpp index c3f9525d653a0..595df166fe997 100644 --- a/sycl/source/detail/image_impl.cpp +++ b/sycl/source/detail/image_impl.cpp @@ -312,14 +312,16 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Desc.image_width)) throw invalid_parameter_error( "For a 1D/2D image/image array, the width must be a Value >= 1 and " - "<= CL_DEVICE_IMAGE2D_MAX_WIDTH.", PI_INVALID_VALUE); + "<= CL_DEVICE_IMAGE2D_MAX_WIDTH.", + PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange(Context, Desc.image_width)) throw invalid_parameter_error( "For a 3D image, the width must be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_WIDTH", PI_INVALID_VALUE); + "CL_DEVICE_IMAGE3D_MAX_WIDTH", + PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE2D, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -335,14 +337,16 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Context, Desc.image_height)) throw invalid_parameter_error( "For a 3D image, the heightmust be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_HEIGHT", PI_INVALID_VALUE); + "CL_DEVICE_IMAGE3D_MAX_HEIGHT", + PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE3D) && !checkImageValueRange(Context, Desc.image_depth)) throw invalid_parameter_error( "For a 3D image, the depth must be a Value >= 1 and <= " - "CL_DEVICE_IMAGE3D_MAX_DEPTH", PI_INVALID_VALUE); + "CL_DEVICE_IMAGE3D_MAX_DEPTH", + PI_INVALID_VALUE); if (checkAny(Desc.image_type, PI_MEM_TYPE_IMAGE1D_ARRAY, PI_MEM_TYPE_IMAGE2D_ARRAY) && @@ -350,7 +354,8 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, Context, Desc.image_array_size)) throw invalid_parameter_error( "For a 1D and 2D image array, the array_size must be a " - "Value >= 1 and <= CL_DEVICE_IMAGE_MAX_ARRAY_SIZE.", PI_INVALID_VALUE); + "Value >= 1 and <= CL_DEVICE_IMAGE_MAX_ARRAY_SIZE.", + PI_INVALID_VALUE); if ((nullptr == UserPtr) && (0 != Desc.image_row_pitch)) throw invalid_parameter_error( @@ -371,7 +376,8 @@ bool image_impl::checkImageDesc(const RT::PiMemImageDesc &Desc, 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); + "image creation from memory objects.", + PI_INVALID_VALUE); return true; } @@ -389,7 +395,8 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "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); + "CL_SNORM_INT16, CL_HALF_FLOAT, or CL_FLOAT.", + PI_INVALID_VALUE); if (checkAny(Format.image_channel_order, PI_IMAGE_CHANNEL_ORDER_RGB, PI_IMAGE_CHANNEL_ORDER_RGBx) && @@ -400,7 +407,8 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "CL_RGB or CL_RGBx These formats can only be used if channel data " "type = CL_UNORM_SHORT_565, CL_UNORM_SHORT_555 or " - "CL_UNORM_INT_101010.", PI_INVALID_VALUE); + "CL_UNORM_INT_101010.", + PI_INVALID_VALUE); if (checkAny(Format.image_channel_order, PI_IMAGE_CHANNEL_ORDER_ARGB, PI_IMAGE_CHANNEL_ORDER_BGRA, PI_IMAGE_CHANNEL_ORDER_ABGR) && @@ -411,7 +419,8 @@ bool image_impl::checkImageFormat( throw invalid_parameter_error( "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); + "or CL_UNSIGNED_INT8.", + PI_INVALID_VALUE); return true; } diff --git a/sycl/source/detail/memory_manager.cpp b/sycl/source/detail/memory_manager.cpp index 3085a2c2883e9..54df3781580d4 100644 --- a/sycl/source/detail/memory_manager.cpp +++ b/sycl/source/detail/memory_manager.cpp @@ -200,7 +200,8 @@ void *MemoryManager::allocateMemSubBuffer(ContextImplPtr TargetContext, if (Error == PI_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); + "multiple of the memory base address alignment", + PI_INVALID_VALUE); return NewMem; } diff --git a/sycl/source/detail/platform_impl.cpp b/sycl/source/detail/platform_impl.cpp index 2cf8dcffd4799..ac0274c0bd4c7 100644 --- a/sycl/source/detail/platform_impl.cpp +++ b/sycl/source/detail/platform_impl.cpp @@ -101,13 +101,15 @@ static std::vector getWhiteListDesc() { } if (':' != *str) - throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); + throw sycl::runtime_error("Malformed device white list", + PI_INVALID_VALUE); // Skip ':' str += 1; if ('{' != *str || '{' != *(str + 1)) - throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); + throw sycl::runtime_error("Malformed device white list", + PI_INVALID_VALUE); // Skip opening sequence "{{" str += 2; @@ -119,7 +121,8 @@ static std::vector getWhiteListDesc() { ++str; if ('\0' == *str) - throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); + throw sycl::runtime_error("Malformed device white list", + PI_INVALID_VALUE); *size = str - *valuePtr; @@ -133,7 +136,8 @@ static std::vector getWhiteListDesc() { if ('|' == *str) decDescs.emplace_back(); else if (',' != *str) - throw sycl::runtime_error("Malformed device white list", PI_INVALID_VALUE); + throw sycl::runtime_error("Malformed device white list", + PI_INVALID_VALUE); ++str; } diff --git a/sycl/source/detail/platform_impl.hpp b/sycl/source/detail/platform_impl.hpp index c8777cf6bc8fd..d47cf2ecb0abf 100644 --- a/sycl/source/detail/platform_impl.hpp +++ b/sycl/source/detail/platform_impl.hpp @@ -82,8 +82,8 @@ class platform_impl { /// @return an instance of OpenCL cl_platform_id. cl_platform_id get() const { if (is_host()) - throw invalid_object_error( - "This instance of platform is a host instance", PI_INVALID_PLATFORM); + throw invalid_object_error("This instance of platform is a host instance", + PI_INVALID_PLATFORM); return pi::cast(MPlatform); } @@ -97,8 +97,8 @@ class platform_impl { /// @return a raw plug-in platform handle. const RT::PiPlatform &getHandleRef() const { if (is_host()) - throw invalid_object_error( - "This instance of platform is a host instance", PI_INVALID_PLATFORM); + throw invalid_object_error("This instance of platform is a host instance", + PI_INVALID_PLATFORM); return MPlatform; } diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 3edc2700d81b5..a973eedddf9b0 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -302,7 +302,8 @@ void program_impl::compile(const string_class &Options) { if (Err != PI_SUCCESS) { throw compile_program_error( "Program compilation error:\n" + - ProgramManager::getProgramBuildLog(MProgram, MContext), Err); + ProgramManager::getProgramBuildLog(MProgram, MContext), + Err); } MCompileOptions = Options; } @@ -318,7 +319,8 @@ void program_impl::build(const string_class &Options) { if (Err != PI_SUCCESS) { throw compile_program_error( "Program build error:\n" + - ProgramManager::getProgramBuildLog(MProgram, MContext), Err); + ProgramManager::getProgramBuildLog(MProgram, MContext), + Err); } MBuildOptions = Options; MCompileOptions = Options; @@ -364,7 +366,8 @@ RT::PiKernel program_impl::get_pi_kernel(const string_class &KernelName) const { MProgram, KernelName.c_str(), &Kernel); if (Err == PI_RESULT_INVALID_KERNEL_NAME) { throw invalid_object_error( - "This instance of program does not contain the kernel requested", Err); + "This instance of program does not contain the kernel requested", + Err); } Plugin.checkPiResult(Err); } @@ -406,7 +409,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_OPERATION); + PI_INVALID_PROGRAM); } cl_uint Result; const detail::plugin &Plugin = getPlugin(); diff --git a/sycl/source/detail/program_manager/program_manager.cpp b/sycl/source/detail/program_manager/program_manager.cpp index e2433f5832cb5..6b369bd0f9bb7 100644 --- a/sycl/source/detail/program_manager/program_manager.cpp +++ b/sycl/source/detail/program_manager/program_manager.cpp @@ -586,7 +586,7 @@ ProgramManager::ProgramManager() { if (!File.is_open()) throw runtime_error(std::string("Can't open file specified via ") + - UseSpvEnv + ": " + SpvFile, + UseSpvEnv + ": " + SpvFile, PI_INVALID_VALUE); File.seekg(0, std::ios::end); size_t Size = File.tellg(); @@ -596,7 +596,8 @@ ProgramManager::ProgramManager() { File.close(); if (!File.good()) throw runtime_error(std::string("read from ") + SpvFile + - std::string(" failed"), PI_INVALID_VALUE); + std::string(" failed"), + PI_INVALID_VALUE); std::unique_ptr ImgPtr(new DeviceImage(), ImageDeleter()); diff --git a/sycl/source/detail/queue_impl.hpp b/sycl/source/detail/queue_impl.hpp index 0d6b96b6d884b..701c1f6941694 100644 --- a/sycl/source/detail/queue_impl.hpp +++ b/sycl/source/detail/queue_impl.hpp @@ -119,7 +119,7 @@ class queue_impl { } throw invalid_object_error( "This instance of queue doesn't support OpenCL interoperability", - PI_INVALID_OPERATION); + PI_INVALID_QUEUE); } /// @return an associated SYCL context. diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 47649dfd9bb67..61ec5ba30df61 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -29,7 +29,8 @@ SYCLMemObjT::SYCLMemObjT(cl_mem MemObject, const context &SyclContext, if (MInteropContext->is_host()) throw cl::sycl::invalid_parameter_error( "Creation of interoperability memory object using host context is " - "not allowed", PI_INVALID_OPERATION); + "not allowed", + PI_INVALID_OPERATION); RT::PiMem Mem = pi::cast(MInteropMemObject); RT::PiContext Context = nullptr; diff --git a/sycl/source/handler.cpp b/sycl/source/handler.cpp index 92ffd35c187b8..9d49f0c3e8efa 100644 --- a/sycl/source/handler.cpp +++ b/sycl/source/handler.cpp @@ -79,7 +79,8 @@ event handler::finalize() { break; case detail::CG::NONE: throw runtime_error("Command group submitted without a kernel or a " - "explicit memory operation.", PI_INVALID_OPERATION); + "explicit memory operation.", + PI_INVALID_OPERATION); default: throw runtime_error("Unhandled type of command group", PI_INVALID_OPERATION); From 62c1d7ed3b04aa4067c2f25459d0be949d659c90 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 26 Feb 2020 15:55:32 +0300 Subject: [PATCH 4/9] [SYCL] Fix formatting Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/access/access.hpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sycl/include/CL/sycl/access/access.hpp b/sycl/include/CL/sycl/access/access.hpp index ce6dea8bd3615..6e5054815a16a 100644 --- a/sycl/include/CL/sycl/access/access.hpp +++ b/sycl/include/CL/sycl/access/access.hpp @@ -76,8 +76,7 @@ constexpr bool modeWritesNewData(access::mode m) { #define __OPENCL_PRIVATE_AS__ #endif -template -struct DeviceValueType; +template struct DeviceValueType; template struct DeviceValueType { @@ -89,8 +88,7 @@ struct DeviceValueType { using type = __OPENCL_CONSTANT_AS__ dataT; }; -template -struct DeviceValueType { +template struct DeviceValueType { using type = __OPENCL_LOCAL_AS__ dataT; }; From 457984b9b343cfda6c504eac62a62f156cbb553c Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 26 Feb 2020 16:30:51 +0300 Subject: [PATCH 5/9] [SYCL] Fix typo Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/types.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index 47a2db3dfc8c1..4b9070ac02107 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -248,8 +248,8 @@ detail::enable_if_t::value, R> convertImpl(T Value) { R Result = std::rint(Value); Err = std::fesetround(OldRoundingDirection); if (Err) - throw std::runtime_error("Unable to restore rounding mode.", - PI_ERROR_UNKNOWN); + throw runtime_error("Unable to restore rounding mode.", + PI_ERROR_UNKNOWN); return Result; } // Round toward zero. From c247d309328b3a48fa1892097fa0a0e84e524961 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 26 Feb 2020 17:23:34 +0300 Subject: [PATCH 6/9] [SYCL] Fix style Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/types.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sycl/include/CL/sycl/types.hpp b/sycl/include/CL/sycl/types.hpp index 4b9070ac02107..472ce566d377a 100644 --- a/sycl/include/CL/sycl/types.hpp +++ b/sycl/include/CL/sycl/types.hpp @@ -248,8 +248,7 @@ detail::enable_if_t::value, R> convertImpl(T Value) { R Result = std::rint(Value); Err = std::fesetround(OldRoundingDirection); if (Err) - throw runtime_error("Unable to restore rounding mode.", - PI_ERROR_UNKNOWN); + throw runtime_error("Unable to restore rounding mode.", PI_ERROR_UNKNOWN); return Result; } // Round toward zero. From d413f0dbef13aedb2a87b0a557f7ef338d31f2a4 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Thu, 27 Feb 2020 10:47:24 +0300 Subject: [PATCH 7/9] [SYCL] Fix Signed-off-by: Sergey Kanaev --- sycl/source/detail/force_device.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/force_device.cpp b/sycl/source/detail/force_device.cpp index f261f24480052..a88b129d86f8d 100644 --- a/sycl/source/detail/force_device.cpp +++ b/sycl/source/detail/force_device.cpp @@ -39,7 +39,8 @@ info::device_type get_forced_type() { return info::device_type::host; } throw cl::sycl::runtime_error("SYCL_DEVICE_TYPE is not recognized. Must " - "be GPU, CPU, ACC or HOST."); + "be GPU, CPU, ACC or HOST.", + PI_INVALID_VALUE); } return info::device_type::all; } From a790baf9e4d941a7316d1d9794bbf806f3cf9388 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 4 Mar 2020 16:37:22 +0300 Subject: [PATCH 8/9] [SYCL] Fix review comments Signed-off-by: Sergey Kanaev --- sycl/include/CL/sycl/detail/pi.h | 1 + sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp | 2 +- sycl/include/CL/sycl/handler.hpp | 2 +- sycl/source/detail/kernel_impl.hpp | 2 +- sycl/source/detail/program_impl.cpp | 6 +++--- sycl/source/detail/sycl_mem_obj_t.cpp | 2 +- sycl/source/device_selector.cpp | 2 +- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sycl/include/CL/sycl/detail/pi.h b/sycl/include/CL/sycl/detail/pi.h index f83aea4d3d7d5..ff72923551723 100644 --- a/sycl/include/CL/sycl/detail/pi.h +++ b/sycl/include/CL/sycl/detail/pi.h @@ -75,6 +75,7 @@ typedef enum { 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_ERROR_UNKNOWN = -999 } _pi_result; 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 ba6e6ba11c7fe..4bd7641953099 100644 --- a/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp +++ b/sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp @@ -234,7 +234,7 @@ class SYCLMemObjT : public SYCLMemObjI { MHostPtrReadOnly = iterator_to_const_type_t::value; setAlign(RequiredAlign); if (useHostPtr()) - throw invalid_parameter_error( + throw runtime_error( "Buffer constructor from a pair of iterator values does not support " "use_host_ptr property.", PI_INVALID_OPERATION); diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index ff0a6c2d103f3..a753190079f49 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -301,7 +301,7 @@ class handler { } if (SyclKernel.is_host()) { throw invalid_object_error("Invalid kernel type, OpenCL expected", - PI_RESULT_INVALID_KERNEL_NAME); + PI_INVALID_KERNEL); } } diff --git a/sycl/source/detail/kernel_impl.hpp b/sycl/source/detail/kernel_impl.hpp index 2b8fcf41c0845..d026b052aa089 100644 --- a/sycl/source/detail/kernel_impl.hpp +++ b/sycl/source/detail/kernel_impl.hpp @@ -74,7 +74,7 @@ class kernel_impl { cl_kernel get() const { if (is_host()) throw invalid_object_error("This instance of kernel is a host instance", - PI_INVALID_DEVICE); + PI_INVALID_KERNEL); getPlugin().call(MKernel); return pi::cast(MKernel); } diff --git a/sycl/source/detail/program_impl.cpp b/sycl/source/detail/program_impl.cpp index 71aa87ad6c572..205c5da8c219c 100644 --- a/sycl/source/detail/program_impl.cpp +++ b/sycl/source/detail/program_impl.cpp @@ -48,7 +48,7 @@ program_impl::program_impl( if (Prg->MContext != MContext) { throw invalid_object_error( "Not all programs are associated with the same context", - PI_INVALID_CONTEXT); + PI_INVALID_PROGRAM); } if (!is_host()) { vector_class PrgDevicesSorted = @@ -156,7 +156,7 @@ cl_program program_impl::get() const { throw_if_state_is(program_state::none); if (is_host()) { throw invalid_object_error("This instance of program is a host instance", - PI_INVALID_DEVICE); + PI_INVALID_PROGRAM); } const detail::plugin &Plugin = getPlugin(); Plugin.call(MProgram); @@ -250,7 +250,7 @@ kernel program_impl::get_kernel(string_class KernelName, if (is_host()) { if (IsCreatedFromSource) throw invalid_object_error("This instance of program is a host instance", - PI_INVALID_DEVICE); + PI_INVALID_PROGRAM); return createSyclObjFromImpl( std::make_shared(MContext, PtrToSelf)); diff --git a/sycl/source/detail/sycl_mem_obj_t.cpp b/sycl/source/detail/sycl_mem_obj_t.cpp index 61ec5ba30df61..8f5b3e2c1ade2 100644 --- a/sycl/source/detail/sycl_mem_obj_t.cpp +++ b/sycl/source/detail/sycl_mem_obj_t.cpp @@ -30,7 +30,7 @@ SYCLMemObjT::SYCLMemObjT(cl_mem MemObject, const context &SyclContext, throw cl::sycl::invalid_parameter_error( "Creation of interoperability memory object using host context is " "not allowed", - PI_INVALID_OPERATION); + PI_INVALID_CONTEXT); RT::PiMem Mem = pi::cast(MInteropMemObject); RT::PiContext Context = nullptr; diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 539b29784c0a0..1b6c2d7bef7ad 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -28,7 +28,7 @@ device device_selector::select_device() const { return *res; throw cl::sycl::runtime_error("No device of requested type available.", - PI_INVALID_OPERATION); + PI_DEVICE_NOT_FOUND); } int default_selector::operator()(const device &dev) const { From 6383e6cb43278d86e4a0576838caa2c98cc8d3a4 Mon Sep 17 00:00:00 2001 From: Sergey Kanaev Date: Wed, 4 Mar 2020 16:40:16 +0300 Subject: [PATCH 9/9] [SYCL] Fix code-style issue Signed-off-by: Sergey Kanaev --- sycl/source/detail/scheduler/scheduler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sycl/source/detail/scheduler/scheduler.cpp b/sycl/source/detail/scheduler/scheduler.cpp index 7679e3f85a727..862507c1839cc 100644 --- a/sycl/source/detail/scheduler/scheduler.cpp +++ b/sycl/source/detail/scheduler/scheduler.cpp @@ -21,7 +21,7 @@ namespace sycl { namespace detail { EventImplPtr addHostAccessorToSchedulerInstance(Requirement *Req, - const bool destructor) { + const bool destructor) { return cl::sycl::detail::Scheduler::getInstance(). addHostAccessor(Req, destructor); }