Skip to content

Commit 1dd7a97

Browse files
[SYCL] Stop using legacy feature_not_supported exception (#11960)
Cleaned up both SYCL RT and tests to remove use of legacy SYCL 1.2.1 `feature_not_supported` exception and replaced its uses with `sycl::exception` with `feature_not_supported` error code
1 parent 98b5505 commit 1dd7a97

File tree

10 files changed

+100
-66
lines changed

10 files changed

+100
-66
lines changed

sycl/include/sycl/accessor.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,9 @@ class image_accessor
982982

983983
device Device = getDeviceFromHandler(CommandGroupHandlerRef);
984984
if (!Device.has(aspect::ext_intel_legacy_image))
985-
throw feature_not_supported(
986-
"SYCL 1.2.1 images are not supported by this device.",
987-
PI_ERROR_INVALID_OPERATION);
985+
throw sycl::exception(
986+
sycl::errc::feature_not_supported,
987+
"SYCL 1.2.1 images are not supported by this device.");
988988
}
989989
#endif
990990

sycl/include/sycl/ext/oneapi/group_local_memory.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <sycl/detail/defines_elementary.hpp> // for __SYCL_ALWAYS_INLINE
1212
#include <sycl/detail/pi.h> // for PI_ERROR_INVALID_OPERA...
1313
#include <sycl/detail/type_traits.hpp> // for is_group
14-
#include <sycl/exception.hpp> // for feature_not_supported
14+
#include <sycl/exception.hpp> // for exception
1515
#include <sycl/ext/intel/usm_pointers.hpp> // for multi_ptr
1616

1717
#include <type_traits> // for enable_if_t
@@ -42,9 +42,9 @@ std::enable_if_t<
4242
}
4343
return reinterpret_cast<__attribute__((opencl_local)) T *>(AllocatedMem);
4444
#else
45-
throw feature_not_supported(
46-
"sycl_ext_oneapi_local_memory extension is not supported on host device",
47-
PI_ERROR_INVALID_OPERATION);
45+
throw sycl::exception(
46+
sycl::errc::feature_not_supported,
47+
"sycl_ext_oneapi_local_memory extension is not supported on host");
4848
#endif
4949
}
5050

@@ -64,9 +64,9 @@ std::enable_if_t<
6464
// Silence unused variable warning
6565
(void)g;
6666
[&args...] {}();
67-
throw feature_not_supported(
68-
"sycl_ext_oneapi_local_memory extension is not supported on host device",
69-
PI_ERROR_INVALID_OPERATION);
67+
throw sycl::exception(
68+
sycl::errc::feature_not_supported,
69+
"sycl_ext_oneapi_local_memory extension is not supported on host");
7070
#endif
7171
}
7272
} // namespace ext::oneapi

sycl/source/detail/event_impl.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,13 @@ void event_impl::setSubmissionTime() {
464464
if (QueueImplPtr Queue = MQueue.lock()) {
465465
try {
466466
MSubmitTime = Queue->getDeviceImplPtr()->getCurrentDeviceTime();
467-
} catch (feature_not_supported &e) {
468-
throw sycl::exception(
469-
make_error_code(errc::profiling),
470-
std::string("Unable to get command group submission time: ") +
471-
e.what());
467+
} catch (sycl::exception &e) {
468+
if (e.code() == sycl::errc::feature_not_supported)
469+
throw sycl::exception(
470+
make_error_code(errc::profiling),
471+
std::string("Unable to get command group submission time: ") +
472+
e.what());
473+
std::rethrow_exception(std::current_exception());
472474
}
473475
}
474476
} else {

sycl/source/detail/program_impl.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ program_impl::program_impl(ContextImplPtr Context,
3636
const property_list &PropList)
3737
: MContext(Context), MDevices(DeviceList), MPropList(PropList) {
3838
if (Context->getDevices().size() > 1) {
39-
throw feature_not_supported(
39+
throw sycl::exception(
40+
sycl::errc::feature_not_supported,
4041
"multiple devices within a context are not supported with "
41-
"sycl::program and sycl::kernel",
42-
PI_ERROR_INVALID_OPERATION);
42+
"sycl::program and sycl::kernel");
4343
}
4444
}
4545

@@ -65,10 +65,10 @@ program_impl::program_impl(
6565

6666
MContext = ProgramList[0]->MContext;
6767
if (MContext->getDevices().size() > 1) {
68-
throw feature_not_supported(
68+
throw sycl::exception(
69+
sycl::errc::feature_not_supported,
6970
"multiple devices within a context are not supported with "
70-
"sycl::program and sycl::kernel",
71-
PI_ERROR_INVALID_OPERATION);
71+
"sycl::program and sycl::kernel");
7272
}
7373
MDevices = ProgramList[0]->MDevices;
7474
std::vector<device> DevicesSorted;

sycl/source/detail/program_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -315,9 +315,9 @@ class program_impl {
315315
void check_device_feature_support(const std::vector<device> &Devices) {
316316
for (const auto &Device : Devices) {
317317
if (!Device.get_info<Param>()) {
318-
throw feature_not_supported(
319-
"Online compilation is not supported by this device",
320-
PI_ERROR_COMPILER_NOT_AVAILABLE);
318+
throw sycl::exception(
319+
sycl::errc::feature_not_supported,
320+
"Online compilation is not supported by this device");
321321
}
322322
}
323323
}

sycl/source/detail/program_manager/program_manager.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,9 @@ ProgramManager::createPIProgram(const RTDeviceBinaryImage &Img,
300300
// assert(Format != PI_DEVICE_BINARY_TYPE_NONE && "Image format not set");
301301

302302
if (!isDeviceBinaryTypeSupported(Context, Format))
303-
throw feature_not_supported(
304-
"SPIR-V online compilation is not supported in this context",
305-
PI_ERROR_INVALID_OPERATION);
303+
throw sycl::exception(
304+
sycl::errc::feature_not_supported,
305+
"SPIR-V online compilation is not supported in this context");
306306

307307
// Get program metadata from properties
308308
auto ProgMetadata = Img.getProgramMetadata();
@@ -1065,8 +1065,8 @@ void CheckJITCompilationForImage(const RTDeviceBinaryImage *const &Image,
10651065
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_GEN) == 0) ||
10661066
(strcmp(RawImg.DeviceTargetSpec,
10671067
__SYCL_PI_DEVICE_BINARY_TARGET_SPIRV64_FPGA) == 0)) {
1068-
throw feature_not_supported("Recompiling AOT image is not supported",
1069-
PI_ERROR_INVALID_OPERATION);
1068+
throw sycl::exception(sycl::errc::feature_not_supported,
1069+
"Recompiling AOT image is not supported");
10701070
}
10711071
}
10721072

sycl/source/detail/sampler_impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ sampler_impl::getOrCreateSampler(const context &Context) {
7474
getSyclObjImpl(Context)->getHandleRef(), sprops, &resultSampler);
7575

7676
if (errcode_ret == PI_ERROR_INVALID_OPERATION)
77-
throw feature_not_supported("Images are not supported by this device.",
78-
errcode_ret);
77+
throw sycl::exception(sycl::errc::feature_not_supported,
78+
"Images are not supported by this device.");
7979

8080
Plugin->checkPiResult(errcode_ret);
8181
std::lock_guard<std::mutex> Lock(MMutex);

sycl/source/esimd_emulator_device_interface.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ __SYCL_EXPORT ESIMDDeviceInterface *getESIMDDeviceInterface() {
3535
std::cerr << "ESIMD EMU plugin error or not loaded - try setting "
3636
"SYCL_DEVICE_FILTER=esimd_emulator:gpu environment variable"
3737
<< std::endl;
38-
throw sycl::feature_not_supported();
38+
throw sycl::exception(sycl::errc::feature_not_supported);
3939
}
4040

4141
ESIMDEmuPluginOpaqueData *OpaqueData =
@@ -53,7 +53,7 @@ __SYCL_EXPORT ESIMDDeviceInterface *getESIMDDeviceInterface() {
5353
<< "Returned version : " << OpaqueData->version << std::endl
5454
<< "Required version : "
5555
<< ESIMD_EMULATOR_PLUGIN_OPAQUE_DATA_VERSION << std::endl;
56-
throw feature_not_supported();
56+
throw sycl::exception(sycl::errc::feature_not_supported);
5757
}
5858
// Opaque data version is OK, can cast the 'data' field.
5959
ESIMDDeviceInterface *Interface =
@@ -68,7 +68,7 @@ __SYCL_EXPORT ESIMDDeviceInterface *getESIMDDeviceInterface() {
6868
<< "Found version : " << Interface->version << std::endl
6969
<< "Required version :" << ESIMD_DEVICE_INTERFACE_VERSION
7070
<< std::endl;
71-
throw feature_not_supported();
71+
throw sycl::exception(sycl::errc::feature_not_supported);
7272
}
7373
return Interface;
7474
}

sycl/test-e2e/Basic/subdevice.cpp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,10 @@ int main() {
4747
assert(sycl::get_native<sycl::backend::opencl>(
4848
SubDevicesEq[0].get_info<info::device::parent_device>()) ==
4949
sycl::get_native<sycl::backend::opencl>(dev));
50-
} catch (feature_not_supported) {
51-
// okay skip it
50+
} catch (const sycl::exception &e) {
51+
if (e.code() != sycl::errc::feature_not_supported)
52+
std::rethrow_exception(std::current_exception());
53+
// otherwise okay skip it
5254
}
5355

5456
try {
@@ -64,8 +66,10 @@ int main() {
6466
assert(SubDevicesByCount[0]
6567
.get_info<info::device::partition_type_property>() ==
6668
info::partition_property::partition_by_counts);
67-
} catch (feature_not_supported) {
68-
// okay skip it
69+
} catch (const sycl::exception &e) {
70+
if (e.code() != sycl::errc::feature_not_supported)
71+
std::rethrow_exception(std::current_exception());
72+
// otherwise okay skip it
6973
}
7074

7175
try {
@@ -76,8 +80,10 @@ int main() {
7680
<< "Created " << SubDevicesDomainNuma.size()
7781
<< " subdevices using partition by numa affinity domain scheme."
7882
<< std::endl;
79-
} catch (feature_not_supported) {
80-
// okay skip it
83+
} catch (const sycl::exception &e) {
84+
if (e.code() != sycl::errc::feature_not_supported)
85+
std::rethrow_exception(std::current_exception());
86+
// otherwise okay skip it
8187
}
8288

8389
try {
@@ -87,8 +93,10 @@ int main() {
8793
std::cout << "Created " << SubDevicesDomainL4.size()
8894
<< " subdevices using partition by L4 cache domain scheme."
8995
<< std::endl;
90-
} catch (feature_not_supported) {
91-
// okay skip it
96+
} catch (const sycl::exception &e) {
97+
if (e.code() != sycl::errc::feature_not_supported)
98+
std::rethrow_exception(std::current_exception());
99+
// otherwise okay skip it
92100
}
93101

94102
try {
@@ -98,8 +106,10 @@ int main() {
98106
std::cout << "Created " << SubDevicesDomainL3.size()
99107
<< " subdevices using partition by L3 cache domain scheme."
100108
<< std::endl;
101-
} catch (feature_not_supported) {
102-
// okay skip it
109+
} catch (const sycl::exception &e) {
110+
if (e.code() != sycl::errc::feature_not_supported)
111+
std::rethrow_exception(std::current_exception());
112+
// otherwise okay skip it
103113
}
104114

105115
try {
@@ -109,8 +119,10 @@ int main() {
109119
std::cout << "Created " << SubDevicesDomainL2.size()
110120
<< " subdevices using partition by L2 cache domain scheme."
111121
<< std::endl;
112-
} catch (feature_not_supported) {
113-
// okay skip it
122+
} catch (const sycl::exception &e) {
123+
if (e.code() != sycl::errc::feature_not_supported)
124+
std::rethrow_exception(std::current_exception());
125+
// otherwise okay skip it
114126
}
115127

116128
try {
@@ -120,8 +132,10 @@ int main() {
120132
std::cout << "Created " << SubDevicesDomainL1.size()
121133
<< " subdevices using partition by L1 cache domain scheme."
122134
<< std::endl;
123-
} catch (feature_not_supported) {
124-
// okay skip it
135+
} catch (const sycl::exception &e) {
136+
if (e.code() != sycl::errc::feature_not_supported)
137+
std::rethrow_exception(std::current_exception());
138+
// otherwise okay skip it
125139
}
126140

127141
try {
@@ -132,8 +146,10 @@ int main() {
132146
<< " subdevices using partition by next partitionable "
133147
"domain scheme."
134148
<< std::endl;
135-
} catch (feature_not_supported) {
136-
// okay skip it
149+
} catch (const sycl::exception &e) {
150+
if (e.code() != sycl::errc::feature_not_supported)
151+
std::rethrow_exception(std::current_exception());
152+
// otherwise okay skip it
137153
}
138154

139155
// test exception

sycl/test-e2e/Basic/subsubdevice.cpp

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ int main() {
4848
assert(sycl::get_native<sycl::backend::opencl>(
4949
SubDevicesEq[0].get_info<info::device::parent_device>()) ==
5050
sycl::get_native<sycl::backend::opencl>(dev));
51-
} catch (feature_not_supported) {
52-
// okay skip it
51+
} catch (const sycl::exception &e) {
52+
if (e.code() != sycl::errc::feature_not_supported)
53+
std::rethrow_exception(std::current_exception());
54+
// otherwise okay skip it
5355
}
5456

5557
try {
@@ -65,8 +67,10 @@ int main() {
6567
assert(SubDevicesByCount[0]
6668
.get_info<info::device::partition_type_property>() ==
6769
info::partition_property::partition_by_counts);
68-
} catch (feature_not_supported) {
69-
// okay skip it
70+
} catch (const sycl::exception &e) {
71+
if (e.code() != sycl::errc::feature_not_supported)
72+
std::rethrow_exception(std::current_exception());
73+
// otherwise okay skip it
7074
}
7175

7276
try {
@@ -88,8 +92,10 @@ int main() {
8892
<< " sub-subdevices from subdevice 0 using partition by numa "
8993
"affinity domain scheme."
9094
<< std::endl;
91-
} catch (feature_not_supported) {
92-
// okay skip it
95+
} catch (const sycl::exception &e) {
96+
if (e.code() != sycl::errc::feature_not_supported)
97+
std::rethrow_exception(std::current_exception());
98+
// otherwise okay skip it
9399
}
94100

95101
try {
@@ -99,8 +105,10 @@ int main() {
99105
std::cout << "Created " << SubDevicesDomainL4.size()
100106
<< " subdevices using partition by L4 cache domain scheme."
101107
<< std::endl;
102-
} catch (feature_not_supported) {
103-
// okay skip it
108+
} catch (const sycl::exception &e) {
109+
if (e.code() != sycl::errc::feature_not_supported)
110+
std::rethrow_exception(std::current_exception());
111+
// otherwise okay skip it
104112
}
105113

106114
try {
@@ -110,8 +118,10 @@ int main() {
110118
std::cout << "Created " << SubDevicesDomainL3.size()
111119
<< " subdevices using partition by L3 cache domain scheme."
112120
<< std::endl;
113-
} catch (feature_not_supported) {
114-
// okay skip it
121+
} catch (const sycl::exception &e) {
122+
if (e.code() != sycl::errc::feature_not_supported)
123+
std::rethrow_exception(std::current_exception());
124+
// otherwise okay skip it
115125
}
116126

117127
try {
@@ -121,8 +131,10 @@ int main() {
121131
std::cout << "Created " << SubDevicesDomainL2.size()
122132
<< " subdevices using partition by L2 cache domain scheme."
123133
<< std::endl;
124-
} catch (feature_not_supported) {
125-
// okay skip it
134+
} catch (const sycl::exception &e) {
135+
if (e.code() != sycl::errc::feature_not_supported)
136+
std::rethrow_exception(std::current_exception());
137+
// otherwise okay skip it
126138
}
127139

128140
try {
@@ -132,8 +144,10 @@ int main() {
132144
std::cout << "Created " << SubDevicesDomainL1.size()
133145
<< " subdevices using partition by L1 cache domain scheme."
134146
<< std::endl;
135-
} catch (feature_not_supported) {
136-
// okay skip it
147+
} catch (const sycl::exception &e) {
148+
if (e.code() != sycl::errc::feature_not_supported)
149+
std::rethrow_exception(std::current_exception());
150+
// otherwise okay skip it
137151
}
138152

139153
try {
@@ -154,8 +168,10 @@ int main() {
154168
<< " sub-subdevices from subdevice 0 using partition by next "
155169
"partitionable domain scheme."
156170
<< std::endl;
157-
} catch (feature_not_supported) {
158-
// okay skip it
171+
} catch (const sycl::exception &e) {
172+
if (e.code() != sycl::errc::feature_not_supported)
173+
std::rethrow_exception(std::current_exception());
174+
// otherwise okay skip it
159175
}
160176
}
161177
} catch (exception e) {

0 commit comments

Comments
 (0)