Skip to content

Commit 2d2c13a

Browse files
[SYCL] Drop sycl::exception::get_cl_code (#14400)
It was removed in SYCL 2020 and should be dropped during the current ABI breaking window. We still need to access PI error code, either for internal needs or for the backend interoperability, so the member field remains. Also, introduce `sycl::detail::get_pi_error(const exception &)` instead for internal needs (cache cleanup when out of resources only currently).
1 parent 3dda8b4 commit 2d2c13a

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

sycl/include/sycl/exception.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ inline namespace _V1 {
2929

3030
// Forward declaration
3131
class context;
32+
class exception;
3233

3334
enum class errc : unsigned int {
3435
success = 0,
@@ -66,6 +67,9 @@ class __SYCL_EXPORT SYCLCategory : public std::error_category {
6667
const char *name() const noexcept override { return "sycl"; }
6768
std::string message(int) const override { return "SYCL Error"; }
6869
};
70+
71+
// Forward declare to declare as a friend in sycl::excepton.
72+
__SYCL_EXPORT pi_int32 get_pi_error(const exception &e);
6973
} // namespace detail
7074

7175
// Derive from std::exception so uncaught exceptions are printed in c++ default
@@ -110,9 +114,6 @@ class __SYCL_EXPORT exception : public virtual std::exception {
110114

111115
context get_context() const;
112116

113-
__SYCL2020_DEPRECATED("use sycl::exception.code() instead.")
114-
cl_int get_cl_code() const;
115-
116117
private:
117118
// Exceptions must be noexcept copy constructible, so cannot use std::string
118119
// directly.
@@ -154,6 +155,8 @@ class __SYCL_EXPORT exception : public virtual std::exception {
154155
}
155156
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
156157
const char *WhatArg);
158+
159+
friend __SYCL_EXPORT pi_int32 detail::get_pi_error(const exception &);
157160
};
158161

159162
class __SYCL2020_DEPRECATED(

sycl/source/detail/kernel_program_cache.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class KernelProgramCache {
289289
return BuildResult;
290290
} catch (const exception &Ex) {
291291
BuildResult->Error.Msg = Ex.what();
292-
BuildResult->Error.Code = Ex.get_cl_code();
292+
BuildResult->Error.Code = detail::get_pi_error(Ex);
293293
if (BuildResult->Error.Code == PI_ERROR_OUT_OF_RESOURCES ||
294294
BuildResult->Error.Code == PI_ERROR_OUT_OF_HOST_MEMORY) {
295295
reset();

sycl/source/exception.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ context exception::get_context() const {
8383
return *MContext;
8484
}
8585

86-
cl_int exception::get_cl_code() const { return MPIErr; }
87-
8886
const std::error_category &sycl_category() noexcept {
8987
static const detail::SYCLCategory SYCLCategoryObj;
9088
return SYCLCategoryObj;
@@ -95,7 +93,9 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
9593
}
9694

9795
namespace detail {
98-
const char *stringifyErrorCode(pi_int32 error) {
96+
pi_int32 get_pi_error(const exception &e) { return e.MPIErr; }
97+
98+
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error) {
9999
switch (error) {
100100
#define _PI_ERRC(NAME, VAL) \
101101
case NAME: \

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3232,6 +3232,7 @@ _ZN4sycl3_V16detail12buffer_plainC2ERKSt8functionIFvPvEEmmRKNS0_13property_listE
32323232
_ZN4sycl3_V16detail12buffer_plainC2EmRKNS0_7contextESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS7_EEbRKNS0_5eventE
32333233
_ZN4sycl3_V16detail12buffer_plainC2EmmRKNS0_13property_listESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS7_EE
32343234
_ZN4sycl3_V16detail12compile_implERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS8_EERKNS0_13property_listE
3235+
_ZN4sycl3_V16detail12get_pi_errorERKNS0_9exceptionE
32353236
_ZN4sycl3_V16detail12isOutOfRangeENS0_3vecIiLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE
32363237
_ZN4sycl3_V16detail12make_contextEmRKSt8functionIFvNS0_14exception_listEEENS0_7backendEbRKSt6vectorINS0_6deviceESaISA_EE
32373238
_ZN4sycl3_V16detail13host_pipe_map3addEPKvPKc
@@ -4189,7 +4190,6 @@ _ZNK4sycl3_V18platform3getEv
41894190
_ZNK4sycl3_V18platform3hasENS0_6aspectE
41904191
_ZNK4sycl3_V18platform7is_hostEv
41914192
_ZNK4sycl3_V18platform9getNativeEv
4192-
_ZNK4sycl3_V19exception11get_cl_codeEv
41934193
_ZNK4sycl3_V19exception11get_contextEv
41944194
_ZNK4sycl3_V19exception11has_contextEv
41954195
_ZNK4sycl3_V19exception4codeEv

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4195,7 +4195,6 @@
41954195
?get_backend@queue@_V1@sycl@@QEBA?AW4backend@23@XZ
41964196
?get_channel_order@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AW4image_channel_order@56@XZ
41974197
?get_channel_type@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AW4image_channel_type@56@XZ
4198-
?get_cl_code@exception@_V1@sycl@@QEBAHXZ
41994198
?get_composite_devices@experimental@oneapi@ext@_V1@sycl@@YA?AV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@std@@XZ
42004199
?get_context@exception@_V1@sycl@@QEBA?AVcontext@23@XZ
42014200
?get_context@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AVcontext@56@XZ
@@ -4241,6 +4240,7 @@
42414240
?get_node_from_event@node@experimental@oneapi@ext@_V1@sycl@@SA?AV123456@Vevent@56@@Z
42424241
?get_nodes@modifiable_command_graph@detail@experimental@oneapi@ext@_V1@sycl@@QEBA?AV?$vector@Vnode@experimental@oneapi@ext@_V1@sycl@@V?$allocator@Vnode@experimental@oneapi@ext@_V1@sycl@@@std@@@std@@XZ
42434242
?get_num_channels@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBAIXZ
4243+
?get_pi_error@detail@_V1@sycl@@YAHAEBVexception@23@@Z
42444244
?get_pipe_name@pipe_base@experimental@intel@ext@_V1@sycl@@KA?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PEBX@Z
42454245
?get_pitch@image_plain@detail@_V1@sycl@@IEBA?AV?$range@$01@34@XZ
42464246
?get_platform@context@_V1@sycl@@QEBA?AVplatform@23@XZ

sycl/test/warnings/sycl_2020_deprecations.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,6 @@ int main() {
101101
sycl::feature_not_supported fns;
102102
// expected-warning@+1{{'exception' is deprecated: The version of an exception constructor which takes no arguments is deprecated.}}
103103
sycl::exception ex;
104-
// expected-warning@+1{{'get_cl_code' is deprecated: use sycl::exception.code() instead.}}
105-
ex.get_cl_code();
106-
(void)ex;
107104

108105
// expected-warning@+1{{'online_compiler<sycl::ext::intel::experimental::source_language::opencl_c>' is deprecated}}
109106
sycl::ext::intel::experimental::online_compiler<

0 commit comments

Comments
 (0)