Skip to content

[SYCL] Isolate OpenCL types and enums #6261

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions sycl/include/CL/sycl/accessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class image_accessor
void checkDeviceFeatureSupported(const device &Device) {
if (!Device.get_info<param>())
throw feature_not_supported("Images are not supported by this device.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
}

#ifdef __SYCL_DEVICE_ONLY__
Expand All @@ -469,7 +469,7 @@ class image_accessor
sycl::vec<int, Dimensions> getRangeInternal() const {
// TODO: Implement for host.
throw runtime_error("image::getRangeInternal() is not implemented for host",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
return sycl::vec<int, Dimensions>{1};
}

Expand Down Expand Up @@ -1461,7 +1461,7 @@ class __SYCL_SPECIAL_CLASS accessor :
throw sycl::invalid_object_error(
"accessor with requested offset and range would exceed the bounds of "
"the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

if (!IsPlaceH)
addHostAccessorAndWait(AccessorBaseHost::impl.get());
Expand Down Expand Up @@ -1502,7 +1502,7 @@ class __SYCL_SPECIAL_CLASS accessor :
throw sycl::invalid_object_error(
"accessor with requested offset and range would exceed the bounds of "
"the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

if (!IsPlaceH)
addHostAccessorAndWait(AccessorBaseHost::impl.get());
Expand Down Expand Up @@ -1574,7 +1574,7 @@ class __SYCL_SPECIAL_CLASS accessor :
throw sycl::invalid_object_error(
"accessor with requested offset and range would exceed the bounds of "
"the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
Expand Down Expand Up @@ -1614,7 +1614,7 @@ class __SYCL_SPECIAL_CLASS accessor :
throw sycl::invalid_object_error(
"accessor with requested offset and range would exceed the bounds of "
"the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

detail::associateWithHandler(CommandGroupHandler, this, AccessTarget);
detail::constructorNotification(detail::getSyclObjImpl(BufferRef).get(),
Expand Down Expand Up @@ -1816,14 +1816,14 @@ class __SYCL_SPECIAL_CLASS accessor :
throw sycl::invalid_object_error(
"SYCL buffer size is zero. To create a device accessor, SYCL "
"buffer size must be greater than zero.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

// check that no_init property is compatible with access mode
if (PropertyList.template has_property<property::no_init>() &&
AccessMode == access::mode::read) {
throw sycl::invalid_object_error(
"accessor would cannot be both read_only and no_init",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand Down
8 changes: 4 additions & 4 deletions sycl/include/CL/sycl/backend.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
throw sycl::runtime_error(
errc::feature_not_supported,
"Buffer interop is not supported by level zero yet",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
return Obj.template getNative<BackendName>();
}
} // namespace detail
Expand All @@ -121,7 +121,7 @@ auto get_native(const SyclObjectT &Obj)
// TODO use SYCL 2020 exception when implemented
if (Obj.get_backend() != BackendName) {
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
}
return Obj.template get_native<BackendName>();
}
Expand Down Expand Up @@ -157,7 +157,7 @@ get_native<backend::opencl, event>(const event &Obj) {
// TODO use SYCL 2020 exception when implemented
if (Obj.get_backend() != backend::opencl) {
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
}
backend_return_t<backend::opencl, event> ReturnValue;
for (auto const &element : Obj.getNativeVector()) {
Expand All @@ -180,7 +180,7 @@ inline backend_return_t<backend::opencl, event> get_native<
// TODO use SYCL 2020 exception when implemented
if (Obj.get_backend() != backend::opencl) {
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
}
return reinterpret_cast<
typename detail::interop<backend::opencl, event>::type>(Obj.getNative());
Expand Down
15 changes: 8 additions & 7 deletions sycl/include/CL/sycl/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,15 @@ class buffer {

if (b.is_sub_buffer())
throw cl::sycl::invalid_object_error(
"Cannot create sub buffer from sub buffer.", PI_INVALID_VALUE);
"Cannot create sub buffer from sub buffer.", PI_ERROR_INVALID_VALUE);
if (isOutOfBounds(baseIndex, subRange, b.Range))
throw cl::sycl::invalid_object_error(
"Requested sub-buffer size exceeds the size of the parent buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
if (!isContiguousRegion(baseIndex, subRange, b.Range))
throw cl::sycl::invalid_object_error(
"Requested sub-buffer region is not contiguous", PI_INVALID_VALUE);
"Requested sub-buffer region is not contiguous",
PI_ERROR_INVALID_VALUE);
}

#ifdef __SYCL_INTERNAL_API
Expand Down Expand Up @@ -435,7 +436,7 @@ class buffer {
if (isOutOfBounds(accessOffset, accessRange, this->Range))
throw cl::sycl::invalid_object_error(
"Requested accessor would exceed the bounds of the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

return accessor<T, dimensions, mode, target, access::placeholder::false_t,
ext::oneapi::accessor_property_list<>>(
Expand All @@ -451,7 +452,7 @@ class buffer {
if (isOutOfBounds(accessOffset, accessRange, this->Range))
throw cl::sycl::invalid_object_error(
"Requested accessor would exceed the bounds of the buffer",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

return accessor<T, dimensions, mode, access::target::host_buffer,
access::placeholder::false_t,
Expand Down Expand Up @@ -498,7 +499,7 @@ class buffer {
"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",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

return buffer<ReinterpretT, ReinterpretDim, AllocatorT>(
impl, reinterpretRange, OffsetInBytes, IsSubBuffer);
Expand All @@ -524,7 +525,7 @@ class buffer {
throw cl::sycl::invalid_object_error(
"Total byte size of buffer is not evenly divisible by the size of "
"the reinterpreted type",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);

return buffer<ReinterpretT, ReinterpretDim, AllocatorT>(
impl, range<1>{sz / sizeof(ReinterpretT)}, OffsetInBytes, IsSubBuffer);
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/array.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ template <int dimensions = 1> class array {
#ifndef __SYCL_DEVICE_ONLY__
if (dimension >= dimensions || dimension < 0) {
throw cl::sycl::invalid_parameter_error("Index out of range",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
#endif
(void)dimension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ struct OptionalDevice {

operator device() const {
if (!DeviceImpl)
throw runtime_error("No device has been set.", PI_INVALID_DEVICE);
throw runtime_error("No device has been set.", PI_ERROR_INVALID_DEVICE);
return createSyclObjFromImpl<device>(DeviceImpl);
}

Expand Down
12 changes: 6 additions & 6 deletions sycl/include/CL/sycl/detail/buffer_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
if (Props.has_property<sycl::property::buffer::use_host_ptr>())
throw sycl::invalid_object_error(
"The use_host_ptr property requires host pointer to be provided",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
}

buffer_impl(void *HostData, size_t SizeInBytes, size_t RequiredAlign,
Expand All @@ -62,7 +62,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::invalid_object_error(
"The use_pinned_host_memory cannot be used with host pointer",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);

BaseT::handleHostData(HostData, RequiredAlign);
}
Expand All @@ -76,7 +76,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::invalid_object_error(
"The use_pinned_host_memory cannot be used with host pointer",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);

BaseT::handleHostData(HostData, RequiredAlign);
}
Expand All @@ -91,7 +91,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
sycl::ext::oneapi::property::buffer::use_pinned_host_memory>())
throw sycl::invalid_object_error(
"The use_pinned_host_memory cannot be used with host pointer",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);

BaseT::handleHostData(HostData, RequiredAlign);
}
Expand All @@ -111,7 +111,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
throw sycl::invalid_object_error(
"Buffer constructor from a pair of iterator values cannot have the "
"use_host_ptr property.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);

BaseT::handleHostData(First, Last, RequiredAlign);
}
Expand All @@ -131,7 +131,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
throw sycl::invalid_object_error(
"Buffer constructor from a pair of iterator values cannot have the "
"use_host_ptr property.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);

BaseT::handleHostData(First, Last, RequiredAlign);
}
Expand Down
4 changes: 2 additions & 2 deletions sycl/include/CL/sycl/detail/cg_types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ class HostKernel : public HostKernelBase {
if (NDRDesc.LocalSize[I] == 0 ||
NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0)
throw sycl::nd_range_error("Invalid local size for global size",
PI_INVALID_WORK_GROUP_SIZE);
PI_ERROR_INVALID_WORK_GROUP_SIZE);
GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I];
}

Expand Down Expand Up @@ -406,7 +406,7 @@ class HostKernel : public HostKernelBase {
if (NDRDesc.LocalSize[I] == 0 ||
NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0)
throw sycl::nd_range_error("Invalid local size for global size",
PI_INVALID_WORK_GROUP_SIZE);
PI_ERROR_INVALID_WORK_GROUP_SIZE);
NGroups[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I];
}

Expand Down
28 changes: 14 additions & 14 deletions sycl/include/CL/sycl/detail/image_accessor_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
throw cl::sycl::invalid_parameter_error(
"Datatype of read data - cl_uint4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand All @@ -320,7 +320,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
throw cl::sycl::invalid_parameter_error(
"Datatype of read data - cl_int4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand Down Expand Up @@ -402,7 +402,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
throw cl::sycl::invalid_parameter_error(
"Datatype of read data - cl_float4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
case image_channel_type::fp16:
// Host has conversion from float to half with accuracy as required in
// section 8.3.2 OpenCL spec.
Expand Down Expand Up @@ -445,7 +445,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
throw cl::sycl::feature_not_supported(
"Currently unsupported datatype conversion from image_channel_type "
"to cl_half4.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
case image_channel_type::signed_int8:
case image_channel_type::signed_int16:
case image_channel_type::signed_int32:
Expand All @@ -458,15 +458,15 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
throw cl::sycl::invalid_parameter_error(
"Datatype to read- cl_half4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
case image_channel_type::fp16:
RetData = PixelData.template convert<cl_half>();
return;
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);
PI_ERROR_INVALID_VALUE);
}
RetData = RetDataFloat.template convert<cl_half>();
}
Expand Down Expand Up @@ -506,7 +506,7 @@ convertWriteData(const vec<cl_uint, 4> WriteData,
throw cl::sycl::invalid_parameter_error(
"Datatype of data to write - cl_uint4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand Down Expand Up @@ -539,7 +539,7 @@ convertWriteData(const vec<cl_int, 4> WriteData,
throw cl::sycl::invalid_parameter_error(
"Datatype of data to write - cl_int4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand Down Expand Up @@ -578,7 +578,7 @@ convertWriteData(const vec<cl_float, 4> WriteData,
throw cl::sycl::feature_not_supported(
"Currently unsupported datatype conversion from image_channel_type "
"to cl_float4.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
case image_channel_type::unorm_short_555:
// TODO: Missing information in OpenCL spec.
// Check if the below code is correct after the spec is updated.
Expand Down Expand Up @@ -621,7 +621,7 @@ convertWriteData(const vec<cl_float, 4> WriteData,
throw cl::sycl::invalid_parameter_error(
"Datatype of data to write - cl_float4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
case image_channel_type::fp16:
// Host has conversion from float to half with accuracy as required in
// section 8.3.2 OpenCL spec.
Expand Down Expand Up @@ -656,7 +656,7 @@ convertWriteData(const vec<cl_half, 4> WriteData,
throw cl::sycl::feature_not_supported(
"Currently unsupported datatype conversion from image_channel_type "
"to cl_half4.",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
case image_channel_type::signed_int8:
case image_channel_type::signed_int16:
case image_channel_type::signed_int32:
Expand All @@ -669,14 +669,14 @@ convertWriteData(const vec<cl_half, 4> WriteData,
throw cl::sycl::invalid_parameter_error(
"Datatype of data to write - cl_float4 is incompatible with the "
"image_channel_type of the image.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
case image_channel_type::fp16:
return WriteData.convert<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.",
PI_INVALID_VALUE);
PI_ERROR_INVALID_VALUE);
}
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ DataT imageReadSamplerHostImpl(const CoordT &Coords, const sampler &Smpl,
"Sampler used with unsupported configuration of "
"mirrored_repeat/repeat filtering mode with unnormalized "
"coordinates. ",
PI_INVALID_OPERATION);
PI_ERROR_INVALID_OPERATION);
case addressing_mode::clamp_to_edge:
case addressing_mode::clamp:
case addressing_mode::none:
Expand Down
Loading