Skip to content

[SYCL] Drop sycl::exception::get_cl_code #14400

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 1 commit into from
Jul 3, 2024
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
9 changes: 6 additions & 3 deletions sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ inline namespace _V1 {

// Forward declaration
class context;
class exception;

enum class errc : unsigned int {
success = 0,
Expand Down Expand Up @@ -66,6 +67,9 @@ class __SYCL_EXPORT SYCLCategory : public std::error_category {
const char *name() const noexcept override { return "sycl"; }
std::string message(int) const override { return "SYCL Error"; }
};

// Forward declare to declare as a friend in sycl::excepton.
__SYCL_EXPORT pi_int32 get_pi_error(const exception &e);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it should be an exported symbol or inline header-only utility. Or, in other words (I think), if layout of sycl::exception is a part of ABI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have https://github.com/intel/llvm/blob/sycl/sycl/test/abi/layout_exception.cpp, but then it's unclear to me why get_cl_code wasn't an inline function...

} // namespace detail

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

context get_context() const;

__SYCL2020_DEPRECATED("use sycl::exception.code() instead.")
cl_int get_cl_code() const;

private:
// Exceptions must be noexcept copy constructible, so cannot use std::string
// directly.
Expand Down Expand Up @@ -154,6 +155,8 @@ class __SYCL_EXPORT exception : public virtual std::exception {
}
exception(std::error_code Ec, std::shared_ptr<context> SharedPtrCtx,
const char *WhatArg);

friend __SYCL_EXPORT pi_int32 detail::get_pi_error(const exception &);
};

class __SYCL2020_DEPRECATED(
Expand Down
2 changes: 1 addition & 1 deletion sycl/source/detail/kernel_program_cache.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class KernelProgramCache {
return BuildResult;
} catch (const exception &Ex) {
BuildResult->Error.Msg = Ex.what();
BuildResult->Error.Code = Ex.get_cl_code();
BuildResult->Error.Code = detail::get_pi_error(Ex);
if (BuildResult->Error.Code == PI_ERROR_OUT_OF_RESOURCES ||
BuildResult->Error.Code == PI_ERROR_OUT_OF_HOST_MEMORY) {
reset();
Expand Down
6 changes: 3 additions & 3 deletions sycl/source/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ context exception::get_context() const {
return *MContext;
}

cl_int exception::get_cl_code() const { return MPIErr; }

const std::error_category &sycl_category() noexcept {
static const detail::SYCLCategory SYCLCategoryObj;
return SYCLCategoryObj;
Expand All @@ -95,7 +93,9 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
}

namespace detail {
const char *stringifyErrorCode(pi_int32 error) {
pi_int32 get_pi_error(const exception &e) { return e.MPIErr; }

__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error) {
switch (error) {
#define _PI_ERRC(NAME, VAL) \
case NAME: \
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/abi/sycl_symbols_linux.dump
Original file line number Diff line number Diff line change
Expand Up @@ -3232,6 +3232,7 @@ _ZN4sycl3_V16detail12buffer_plainC2ERKSt8functionIFvPvEEmmRKNS0_13property_listE
_ZN4sycl3_V16detail12buffer_plainC2EmNS0_7contextESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS5_EEbNS0_5eventE
_ZN4sycl3_V16detail12buffer_plainC2EmmRKNS0_13property_listESt10unique_ptrINS1_19SYCLMemObjAllocatorESt14default_deleteIS7_EE
_ZN4sycl3_V16detail12compile_implERKNS0_13kernel_bundleILNS0_12bundle_stateE0EEERKSt6vectorINS0_6deviceESaIS8_EERKNS0_13property_listE
_ZN4sycl3_V16detail12get_pi_errorERKNS0_9exceptionE
_ZN4sycl3_V16detail12isOutOfRangeENS0_3vecIiLi4EEENS0_15addressing_modeENS0_5rangeILi3EEE
_ZN4sycl3_V16detail12make_contextEmRKSt8functionIFvNS0_14exception_listEEENS0_7backendEbRKSt6vectorINS0_6deviceESaISA_EE
_ZN4sycl3_V16detail13host_pipe_map3addEPKvPKc
Expand Down Expand Up @@ -4190,7 +4191,6 @@ _ZNK4sycl3_V18platform3getEv
_ZNK4sycl3_V18platform3hasENS0_6aspectE
_ZNK4sycl3_V18platform7is_hostEv
_ZNK4sycl3_V18platform9getNativeEv
_ZNK4sycl3_V19exception11get_cl_codeEv
_ZNK4sycl3_V19exception11get_contextEv
_ZNK4sycl3_V19exception11has_contextEv
_ZNK4sycl3_V19exception4codeEv
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/abi/sycl_symbols_windows.dump
Original file line number Diff line number Diff line change
Expand Up @@ -4196,7 +4196,6 @@
?get_backend@queue@_V1@sycl@@QEBA?AW4backend@23@XZ
?get_channel_order@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AW4image_channel_order@56@XZ
?get_channel_type@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AW4image_channel_type@56@XZ
?get_cl_code@exception@_V1@sycl@@QEBAHXZ
?get_composite_devices@experimental@oneapi@ext@_V1@sycl@@YA?AV?$vector@Vdevice@_V1@sycl@@V?$allocator@Vdevice@_V1@sycl@@@std@@@std@@XZ
?get_context@exception@_V1@sycl@@QEBA?AVcontext@23@XZ
?get_context@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBA?AVcontext@56@XZ
Expand Down Expand Up @@ -4242,6 +4241,7 @@
?get_node_from_event@node@experimental@oneapi@ext@_V1@sycl@@SA?AV123456@Vevent@56@@Z
?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
?get_num_channels@image_mem@experimental@oneapi@ext@_V1@sycl@@QEBAIXZ
?get_pi_error@detail@_V1@sycl@@YAHAEBVexception@23@@Z
?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
?get_pitch@image_plain@detail@_V1@sycl@@IEBA?AV?$range@$01@34@XZ
?get_platform@context@_V1@sycl@@QEBA?AVplatform@23@XZ
Expand Down
3 changes: 0 additions & 3 deletions sycl/test/warnings/sycl_2020_deprecations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ int main() {
sycl::feature_not_supported fns;
// expected-warning@+1{{'exception' is deprecated: The version of an exception constructor which takes no arguments is deprecated.}}
sycl::exception ex;
// expected-warning@+1{{'get_cl_code' is deprecated: use sycl::exception.code() instead.}}
ex.get_cl_code();
(void)ex;

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