Skip to content

Commit 3fcf848

Browse files
authored
[SYCL] Isolate OpenCL types and enums (#6261)
This PR populates PI enums and typedefs with values taken from the OpenCL equivalents; it also makes sure that all uses of the system OpenCL header `cl.h` are channelled through `include/CL/sycl/detail/cl.h`. Finally, `pi.h` and `pi.hpp` would only tap into the system `cl.h` for OpenCL backend (guarded by `PI_OPENCL_AVAILABLE` compiler definition), which allowed a removal of all OpenCL types and enums from other PI backends. Fixes: #1265
1 parent 2c7caab commit 3fcf848

File tree

93 files changed

+1614
-1609
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1614
-1609
lines changed

sycl/include/CL/sycl/accessor.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ class image_accessor
447447
void checkDeviceFeatureSupported(const device &Device) {
448448
if (!Device.get_info<param>())
449449
throw feature_not_supported("Images are not supported by this device.",
450-
PI_INVALID_OPERATION);
450+
PI_ERROR_INVALID_OPERATION);
451451
}
452452

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

@@ -1461,7 +1461,7 @@ class __SYCL_SPECIAL_CLASS accessor :
14611461
throw sycl::invalid_object_error(
14621462
"accessor with requested offset and range would exceed the bounds of "
14631463
"the buffer",
1464-
PI_INVALID_VALUE);
1464+
PI_ERROR_INVALID_VALUE);
14651465

14661466
if (!IsPlaceH)
14671467
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1502,7 +1502,7 @@ class __SYCL_SPECIAL_CLASS accessor :
15021502
throw sycl::invalid_object_error(
15031503
"accessor with requested offset and range would exceed the bounds of "
15041504
"the buffer",
1505-
PI_INVALID_VALUE);
1505+
PI_ERROR_INVALID_VALUE);
15061506

15071507
if (!IsPlaceH)
15081508
addHostAccessorAndWait(AccessorBaseHost::impl.get());
@@ -1574,7 +1574,7 @@ class __SYCL_SPECIAL_CLASS accessor :
15741574
throw sycl::invalid_object_error(
15751575
"accessor with requested offset and range would exceed the bounds of "
15761576
"the buffer",
1577-
PI_INVALID_VALUE);
1577+
PI_ERROR_INVALID_VALUE);
15781578

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

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

18211821
// check that no_init property is compatible with access mode
18221822
if (PropertyList.template has_property<property::no_init>() &&
18231823
AccessMode == access::mode::read) {
18241824
throw sycl::invalid_object_error(
18251825
"accessor would cannot be both read_only and no_init",
1826-
PI_INVALID_VALUE);
1826+
PI_ERROR_INVALID_VALUE);
18271827
}
18281828
}
18291829

sycl/include/CL/sycl/backend.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ auto get_native_buffer(const buffer<DataT, Dimensions, AllocatorT, void> &Obj)
110110
throw sycl::runtime_error(
111111
errc::feature_not_supported,
112112
"Buffer interop is not supported by level zero yet",
113-
PI_INVALID_OPERATION);
113+
PI_ERROR_INVALID_OPERATION);
114114
return Obj.template getNative<BackendName>();
115115
}
116116
} // namespace detail
@@ -121,7 +121,7 @@ auto get_native(const SyclObjectT &Obj)
121121
// TODO use SYCL 2020 exception when implemented
122122
if (Obj.get_backend() != BackendName) {
123123
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
124-
PI_INVALID_OPERATION);
124+
PI_ERROR_INVALID_OPERATION);
125125
}
126126
return Obj.template get_native<BackendName>();
127127
}
@@ -157,7 +157,7 @@ get_native<backend::opencl, event>(const event &Obj) {
157157
// TODO use SYCL 2020 exception when implemented
158158
if (Obj.get_backend() != backend::opencl) {
159159
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
160-
PI_INVALID_OPERATION);
160+
PI_ERROR_INVALID_OPERATION);
161161
}
162162
backend_return_t<backend::opencl, event> ReturnValue;
163163
for (auto const &element : Obj.getNativeVector()) {
@@ -180,7 +180,7 @@ inline backend_return_t<backend::opencl, event> get_native<
180180
// TODO use SYCL 2020 exception when implemented
181181
if (Obj.get_backend() != backend::opencl) {
182182
throw sycl::runtime_error(errc::backend_mismatch, "Backends mismatch",
183-
PI_INVALID_OPERATION);
183+
PI_ERROR_INVALID_OPERATION);
184184
}
185185
return reinterpret_cast<
186186
typename detail::interop<backend::opencl, event>::type>(Obj.getNative());

sycl/include/CL/sycl/buffer.hpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,14 +329,15 @@ class buffer {
329329

330330
if (b.is_sub_buffer())
331331
throw cl::sycl::invalid_object_error(
332-
"Cannot create sub buffer from sub buffer.", PI_INVALID_VALUE);
332+
"Cannot create sub buffer from sub buffer.", PI_ERROR_INVALID_VALUE);
333333
if (isOutOfBounds(baseIndex, subRange, b.Range))
334334
throw cl::sycl::invalid_object_error(
335335
"Requested sub-buffer size exceeds the size of the parent buffer",
336-
PI_INVALID_VALUE);
336+
PI_ERROR_INVALID_VALUE);
337337
if (!isContiguousRegion(baseIndex, subRange, b.Range))
338338
throw cl::sycl::invalid_object_error(
339-
"Requested sub-buffer region is not contiguous", PI_INVALID_VALUE);
339+
"Requested sub-buffer region is not contiguous",
340+
PI_ERROR_INVALID_VALUE);
340341
}
341342

342343
#ifdef __SYCL_INTERNAL_API
@@ -435,7 +436,7 @@ class buffer {
435436
if (isOutOfBounds(accessOffset, accessRange, this->Range))
436437
throw cl::sycl::invalid_object_error(
437438
"Requested accessor would exceed the bounds of the buffer",
438-
PI_INVALID_VALUE);
439+
PI_ERROR_INVALID_VALUE);
439440

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

456457
return accessor<T, dimensions, mode, access::target::host_buffer,
457458
access::placeholder::false_t,
@@ -498,7 +499,7 @@ class buffer {
498499
"Total size in bytes represented by the type and range of the "
499500
"reinterpreted SYCL buffer does not equal the total size in bytes "
500501
"represented by the type and range of this SYCL buffer",
501-
PI_INVALID_VALUE);
502+
PI_ERROR_INVALID_VALUE);
502503

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

529530
return buffer<ReinterpretT, ReinterpretDim, AllocatorT>(
530531
impl, range<1>{sz / sizeof(ReinterpretT)}, OffsetInBytes, IsSubBuffer);

sycl/include/CL/sycl/detail/array.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ template <int dimensions = 1> class array {
112112
#ifndef __SYCL_DEVICE_ONLY__
113113
if (dimension >= dimensions || dimension < 0) {
114114
throw cl::sycl::invalid_parameter_error("Index out of range",
115-
PI_INVALID_VALUE);
115+
PI_ERROR_INVALID_VALUE);
116116
}
117117
#endif
118118
(void)dimension;

sycl/include/CL/sycl/detail/backend_traits_level_zero.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ struct OptionalDevice {
140140

141141
operator device() const {
142142
if (!DeviceImpl)
143-
throw runtime_error("No device has been set.", PI_INVALID_DEVICE);
143+
throw runtime_error("No device has been set.", PI_ERROR_INVALID_DEVICE);
144144
return createSyclObjFromImpl<device>(DeviceImpl);
145145
}
146146

sycl/include/CL/sycl/detail/buffer_impl.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class __SYCL_EXPORT buffer_impl final : public SYCLMemObjT {
5050
if (Props.has_property<sycl::property::buffer::use_host_ptr>())
5151
throw sycl::invalid_object_error(
5252
"The use_host_ptr property requires host pointer to be provided",
53-
PI_INVALID_OPERATION);
53+
PI_ERROR_INVALID_OPERATION);
5454
}
5555

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

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

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

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

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

136136
BaseT::handleHostData(First, Last, RequiredAlign);
137137
}

sycl/include/CL/sycl/detail/cg_types.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ class HostKernel : public HostKernelBase {
364364
if (NDRDesc.LocalSize[I] == 0 ||
365365
NDRDesc.GlobalSize[I] % NDRDesc.LocalSize[I] != 0)
366366
throw sycl::nd_range_error("Invalid local size for global size",
367-
PI_INVALID_WORK_GROUP_SIZE);
367+
PI_ERROR_INVALID_WORK_GROUP_SIZE);
368368
GroupSize[I] = NDRDesc.GlobalSize[I] / NDRDesc.LocalSize[I];
369369
}
370370

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

sycl/include/CL/sycl/detail/image_accessor_util.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
298298
throw cl::sycl::invalid_parameter_error(
299299
"Datatype of read data - cl_uint4 is incompatible with the "
300300
"image_channel_type of the image.",
301-
PI_INVALID_VALUE);
301+
PI_ERROR_INVALID_VALUE);
302302
}
303303
}
304304

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

@@ -402,7 +402,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
402402
throw cl::sycl::invalid_parameter_error(
403403
"Datatype of read data - cl_float4 is incompatible with the "
404404
"image_channel_type of the image.",
405-
PI_INVALID_VALUE);
405+
PI_ERROR_INVALID_VALUE);
406406
case image_channel_type::fp16:
407407
// Host has conversion from float to half with accuracy as required in
408408
// section 8.3.2 OpenCL spec.
@@ -445,7 +445,7 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
445445
throw cl::sycl::feature_not_supported(
446446
"Currently unsupported datatype conversion from image_channel_type "
447447
"to cl_half4.",
448-
PI_INVALID_OPERATION);
448+
PI_ERROR_INVALID_OPERATION);
449449
case image_channel_type::signed_int8:
450450
case image_channel_type::signed_int16:
451451
case image_channel_type::signed_int32:
@@ -458,15 +458,15 @@ void convertReadData(const vec<ChannelType, 4> PixelData,
458458
throw cl::sycl::invalid_parameter_error(
459459
"Datatype to read- cl_half4 is incompatible with the "
460460
"image_channel_type of the image.",
461-
PI_INVALID_VALUE);
461+
PI_ERROR_INVALID_VALUE);
462462
case image_channel_type::fp16:
463463
RetData = PixelData.template convert<cl_half>();
464464
return;
465465
case image_channel_type::fp32:
466466
throw cl::sycl::invalid_parameter_error(
467467
"Datatype to read - cl_half4 is incompatible with the "
468468
"image_channel_type of the image.",
469-
PI_INVALID_VALUE);
469+
PI_ERROR_INVALID_VALUE);
470470
}
471471
RetData = RetDataFloat.template convert<cl_half>();
472472
}
@@ -506,7 +506,7 @@ convertWriteData(const vec<cl_uint, 4> WriteData,
506506
throw cl::sycl::invalid_parameter_error(
507507
"Datatype of data to write - cl_uint4 is incompatible with the "
508508
"image_channel_type of the image.",
509-
PI_INVALID_VALUE);
509+
PI_ERROR_INVALID_VALUE);
510510
}
511511
}
512512

@@ -539,7 +539,7 @@ convertWriteData(const vec<cl_int, 4> WriteData,
539539
throw cl::sycl::invalid_parameter_error(
540540
"Datatype of data to write - cl_int4 is incompatible with the "
541541
"image_channel_type of the image.",
542-
PI_INVALID_VALUE);
542+
PI_ERROR_INVALID_VALUE);
543543
}
544544
}
545545

@@ -578,7 +578,7 @@ convertWriteData(const vec<cl_float, 4> WriteData,
578578
throw cl::sycl::feature_not_supported(
579579
"Currently unsupported datatype conversion from image_channel_type "
580580
"to cl_float4.",
581-
PI_INVALID_OPERATION);
581+
PI_ERROR_INVALID_OPERATION);
582582
case image_channel_type::unorm_short_555:
583583
// TODO: Missing information in OpenCL spec.
584584
// Check if the below code is correct after the spec is updated.
@@ -621,7 +621,7 @@ convertWriteData(const vec<cl_float, 4> WriteData,
621621
throw cl::sycl::invalid_parameter_error(
622622
"Datatype of data to write - cl_float4 is incompatible with the "
623623
"image_channel_type of the image.",
624-
PI_INVALID_VALUE);
624+
PI_ERROR_INVALID_VALUE);
625625
case image_channel_type::fp16:
626626
// Host has conversion from float to half with accuracy as required in
627627
// section 8.3.2 OpenCL spec.
@@ -656,7 +656,7 @@ convertWriteData(const vec<cl_half, 4> WriteData,
656656
throw cl::sycl::feature_not_supported(
657657
"Currently unsupported datatype conversion from image_channel_type "
658658
"to cl_half4.",
659-
PI_INVALID_OPERATION);
659+
PI_ERROR_INVALID_OPERATION);
660660
case image_channel_type::signed_int8:
661661
case image_channel_type::signed_int16:
662662
case image_channel_type::signed_int32:
@@ -669,14 +669,14 @@ convertWriteData(const vec<cl_half, 4> WriteData,
669669
throw cl::sycl::invalid_parameter_error(
670670
"Datatype of data to write - cl_float4 is incompatible with the "
671671
"image_channel_type of the image.",
672-
PI_INVALID_VALUE);
672+
PI_ERROR_INVALID_VALUE);
673673
case image_channel_type::fp16:
674674
return WriteData.convert<ChannelType>();
675675
case image_channel_type::fp32:
676676
throw cl::sycl::invalid_parameter_error(
677677
"Datatype of data to write - cl_float4 is incompatible with the "
678678
"image_channel_type of the image.",
679-
PI_INVALID_VALUE);
679+
PI_ERROR_INVALID_VALUE);
680680
}
681681
}
682682

@@ -1043,7 +1043,7 @@ DataT imageReadSamplerHostImpl(const CoordT &Coords, const sampler &Smpl,
10431043
"Sampler used with unsupported configuration of "
10441044
"mirrored_repeat/repeat filtering mode with unnormalized "
10451045
"coordinates. ",
1046-
PI_INVALID_OPERATION);
1046+
PI_ERROR_INVALID_OPERATION);
10471047
case addressing_mode::clamp_to_edge:
10481048
case addressing_mode::clamp:
10491049
case addressing_mode::none:

0 commit comments

Comments
 (0)