Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,8 @@ class image_accessor
template <info::device param>
void checkDeviceFeatureSupported(const device &Device) {
if (!Device.get_info<param>())
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__
Expand All @@ -357,7 +358,8 @@ class image_accessor
sycl::vec<int, Dimensions> 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<int, Dimensions>{1};
}

Expand Down
10 changes: 6 additions & 4 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <int N = dimensions, typename = EnableIfOneDimension<N>>
Expand Down Expand Up @@ -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<ReinterpretT, ReinterpretDim, AllocatorT>(
impl, reinterpretRange, OffsetInBytes, IsSubBuffer);
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ template <int dimensions = 1> 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
}
Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/detail/cg.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down Expand Up @@ -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];
}

Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/detail/device_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
34 changes: 18 additions & 16 deletions sycl/include/CL/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ vec<T, 4> 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;
Expand Down Expand Up @@ -265,7 +266,8 @@ void writePixel(const vec<T, 4> 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);
}
}

Expand Down Expand Up @@ -293,7 +295,7 @@ void convertReadData(const vec<ChannelType, 4> 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);
}
}

Expand All @@ -314,7 +316,7 @@ void convertReadData(const vec<ChannelType, 4> 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);
}
}

Expand Down Expand Up @@ -395,7 +397,7 @@ void convertReadData(const vec<ChannelType, 4> 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.
Expand Down Expand Up @@ -425,7 +427,7 @@ void convertReadData(const vec<ChannelType, 4> 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:
Expand All @@ -437,14 +439,14 @@ void convertReadData(const vec<ChannelType, 4> 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<cl_half>();
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;
}
Expand Down Expand Up @@ -484,7 +486,7 @@ convertWriteData(const vec<cl_uint, 4> 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);
}
}

Expand Down Expand Up @@ -516,7 +518,7 @@ convertWriteData(const vec<cl_int, 4> 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);
}
}

Expand Down Expand Up @@ -554,7 +556,7 @@ convertWriteData(const vec<cl_float, 4> 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.
Expand Down Expand Up @@ -596,7 +598,7 @@ convertWriteData(const vec<cl_float, 4> 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.
Expand Down Expand Up @@ -624,7 +626,7 @@ convertWriteData(const vec<cl_half, 4> 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:
Expand All @@ -636,13 +638,13 @@ convertWriteData(const vec<cl_half, 4> 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<ChannelType>();
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;
}
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/kernel_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PiApiKind::piKernelRetain>(MKernel);
return pi::cast<cl_kernel>(MKernel);
}
Expand Down
4 changes: 3 additions & 1 deletion sycl/include/CL/sycl/detail/pi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/platform_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<cl_platform_id>(MPlatform);
}
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/program_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ class program_impl {
for (const auto &Device : Devices) {
if (!Device.get_info<param>()) {
throw feature_not_supported(
"Online compilation is not supported by this device");
"Online compilation is not supported by this device",
PI_INVALID_DEVICE);
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/detail/queue_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -116,7 +117,8 @@ class queue_impl {
return pi::cast<cl_command_queue>(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.
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/sycl_mem_obj_t.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
15 changes: 8 additions & 7 deletions sycl/include/CL/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// 4.9.2 Exception Class Interface

#include <CL/sycl/detail/common.hpp>
#include <CL/sycl/detail/pi.h>
#include <CL/sycl/stl.hpp>

#include <exception>
Expand All @@ -37,15 +38,15 @@ class exception: public std::exception {

private:
string_class MMsg;
cl_int MCLErr = CL_SUCCESS;
cl_int MCLErr;
shared_ptr_class<context> MContext;

protected:
exception(const char *Msg, const cl_int CLErr = CL_SUCCESS,
exception(const char *Msg, const cl_int CLErr,
shared_ptr_class<context> 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> Context = nullptr)
: MMsg(Msg + " " + detail::codeToString(CLErr)), MCLErr(CLErr),
MContext(Context) {}
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions sycl/include/CL/sycl/handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/intel/function_pointer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading