Skip to content

Commit ce81199

Browse files
[SYCL][ABI-Break] Hide some exported symbols (#14615)
Both `get_pi_error` and `set_pi_error` are only called from the library and therefore there is no need for them to be exported. This patch is essentially a by-product of #14145 and it is done to simplify that change, i.e. PI plugins removal should not be ABI-breaking by itself, we just need to cleanup some of our exported symbols.
1 parent 9fdef43 commit ce81199

File tree

5 files changed

+19
-17
lines changed

5 files changed

+19
-17
lines changed

sycl/include/sycl/exception.hpp

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,8 @@ class __SYCL_EXPORT SYCLCategory : public std::error_category {
6767
};
6868

6969
// Forward declare to declare as a friend in sycl::excepton.
70-
__SYCL_EXPORT pi_int32 get_pi_error(const exception &e);
71-
// TODO: Should it be exported at all?
72-
__SYCL_EXPORT exception set_pi_error(exception &&e, pi_int32 pi_err);
70+
pi_int32 get_pi_error(const exception &e);
71+
exception set_pi_error(exception &&e, pi_int32 pi_err);
7372
} // namespace detail
7473

7574
// Derive from std::exception so uncaught exceptions are printed in c++ default
@@ -140,16 +139,29 @@ class __SYCL_EXPORT exception : public virtual std::exception {
140139
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
141140
const char *WhatArg);
142141

143-
friend __SYCL_EXPORT pi_int32 detail::get_pi_error(const exception &);
142+
friend pi_int32 detail::get_pi_error(const exception &);
144143
// To be used like this:
145144
// throw/return detail::set_pi_error(exception(...), some_pi_error);
146145
// *only* when such a error is coming from the PI/UR level. Otherwise it
147146
// *should be left unset/default-initialized and exception should be thrown
148147
// as-is using public ctors.
149-
friend __SYCL_EXPORT exception detail::set_pi_error(exception &&e,
150-
pi_int32 pi_err);
148+
friend exception detail::set_pi_error(exception &&e, pi_int32 pi_err);
151149
};
152150

151+
namespace detail {
152+
// Even though at the moment those functions are only used in library and not
153+
// in headers, they were put here in case we will need them to implement some
154+
// of OpenCL (and other backends) interop APIs to query native backend error
155+
// from an exception.
156+
// And we don't want them to be part of our library ABI, because of future
157+
// underlying changes (PI -> UR -> Offload).
158+
inline pi_int32 get_pi_error(const exception &e) { return e.MPIErr; }
159+
inline exception set_pi_error(exception &&e, pi_int32 pi_err) {
160+
e.MPIErr = pi_err;
161+
return std::move(e);
162+
}
163+
} // namespace detail
164+
153165
} // namespace _V1
154166
} // namespace sycl
155167

sycl/source/exception.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
6666
}
6767

6868
namespace detail {
69-
pi_int32 get_pi_error(const exception &e) { return e.MPIErr; }
70-
exception set_pi_error(exception &&e, pi_int32 pi_err) {
71-
e.MPIErr = pi_err;
72-
return std::move(e);
73-
}
74-
7569
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error) {
7670
switch (error) {
7771
#define _PI_ERRC(NAME, VAL) \

sycl/test-e2e/KernelAndProgram/build-log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// for CUDA and HIP the failure happens at compile time, not during runtime
22
// UNSUPPORTED: cuda || hip || ze_debug
3+
// TODO: rewrite this into a unit-test
34

45
// RUN: %{build} -DGPU -o %t_gpu.out
56
// RUN: %{build} -o %t.out
@@ -46,7 +47,6 @@ void test() {
4647
std::cerr << Msg << std::endl;
4748
assert(e.code() == sycl::errc::build &&
4849
"Caught exception was not a compilation error");
49-
assert(sycl::detail::get_pi_error(e) == PI_ERROR_BUILD_PROGRAM_FAILURE);
5050
} catch (...) {
5151
assert(false && "Caught exception was not a compilation error");
5252
}

sycl/test/abi/sycl_symbols_linux.dump

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3218,10 +3218,8 @@ _ZN4sycl3_V16detail12buffer_plainC2ERKSt8functionIFvPvEEmmRKNS0_13property_listE
32183218
_ZN4sycl3_V16detail12buffer_plainC2EmRKNS0_7contextESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS7_EEbRKNS0_5eventE
32193219
_ZN4sycl3_V16detail12buffer_plainC2EmmRKNS0_13property_listESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS7_EE
32203220
_ZN4sycl3_V16detail12compile_implERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS8_EERKNS0_13property_listE
3221-
_ZN4sycl3_V16detail12get_pi_errorERKNS0_9exceptionE
32223221
_ZN4sycl3_V16detail12isOutOfRangeENS0_3vecIiLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE
32233222
_ZN4sycl3_V16detail12make_contextEmRKSt8functionIFvNS0_14exception_listEEENS0_7backendEbRKSt6vectorINS0_6deviceESaISA_EE
3224-
_ZN4sycl3_V16detail12set_pi_errorEONS0_9exceptionEi
32253223
_ZN4sycl3_V16detail13host_pipe_map3addEPKvPKc
32263224
_ZN4sycl3_V16detail13lgamma_r_implENS1_9half_impl4halfEPi
32273225
_ZN4sycl3_V16detail13lgamma_r_implEdPi

sycl/test/abi/sycl_symbols_windows.dump

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4028,7 +4028,6 @@
40284028
?get_node_from_event@node@experimental@oneapi@ext@_V1@sycl@@SA?AV123456@Vevent@56@@Z
40294029
?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
40304030
?get_num_channels@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBAIXZ
4031-
?get_pi_error@detail@_V1@sycl@@YAHAEBVexception@23@@Z
40324031
?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
40334032
?get_pitch@image_plain@detail@_V1@sycl@@IEBA?AV?$range@$01@34@XZ
40344033
?get_platform@context@_V1@sycl@@QEBA?AVplatform@23@XZ
@@ -4229,7 +4228,6 @@
42294228
?set_flag@stream@_V1@sycl@@AEBAXI@Z
42304229
?set_flag@stream@_V1@sycl@@AEBAXII@Z
42314230
?set_manipulator@stream@_V1@sycl@@AEBAXW4stream_manipulator@23@@Z
4232-
?set_pi_error@detail@_V1@sycl@@YA?AVexception@23@$$QEAV423@H@Z
42334231
?set_specialization_constant_impl@kernel_bundle_plain@detail@_V1@sycl@@IEAAXPEBDPEAX_K@Z
42344232
?set_write_back@buffer_plain@detail@_V1@sycl@@IEAAX_N@Z
42354233
?set_write_back@image_plain@detail@_V1@sycl@@IEAAX_N@Z

0 commit comments

Comments
 (0)