Skip to content

[SYCL] Move codeToString common.hpp -> exception.hpp #13904

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
May 24, 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
7 changes: 0 additions & 7 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,6 @@ class __SYCL_EXPORT tls_code_loc_t {
bool MLocalScope = true;
};

__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error);

inline std::string codeToString(pi_int32 code) {
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
")");
}

} // namespace detail
} // namespace _V1
} // namespace sycl
Expand Down
8 changes: 7 additions & 1 deletion sycl/include/sycl/exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include <sycl/backend_types.hpp> // for backend
#include <sycl/detail/cl.h> // for cl_int
#include <sycl/detail/common.hpp> // for codeToString
#include <sycl/detail/defines_elementary.hpp> // for __SYCL2020_DEPRECATED
#include <sycl/detail/export.hpp> // for __SYCL_EXPORT
#include <sycl/detail/pi.h> // for pi_int32
Expand Down Expand Up @@ -58,6 +57,13 @@ __SYCL_EXPORT std::error_code make_error_code(sycl::errc E) noexcept;
__SYCL_EXPORT const std::error_category &sycl_category() noexcept;

namespace detail {
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error);

inline std::string codeToString(pi_int32 code) {
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
")");
}

class __SYCL_EXPORT SYCLCategory : public std::error_category {
public:
const char *name() const noexcept override { return "sycl"; }
Expand Down
16 changes: 0 additions & 16 deletions sycl/source/detail/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,6 @@ tls_code_loc_t::~tls_code_loc_t() {

const detail::code_location &tls_code_loc_t::query() { return GCodeLocTLS; }

const char *stringifyErrorCode(pi_int32 error) {
switch (error) {
#define _PI_ERRC(NAME, VAL) \
case NAME: \
return #NAME;
#define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) \
case NAME: \
return MSG;
#include <sycl/detail/pi_error.def>
#undef _PI_ERRC
#undef _PI_ERRC_WITH_MSG

default:
return "Unknown error code";
}
}
} // namespace detail
} // namespace _V1
} // namespace sycl
19 changes: 19 additions & 0 deletions sycl/source/exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,24 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
return {static_cast<int>(Err), sycl_category()};
}

namespace detail {
const char *stringifyErrorCode(pi_int32 error) {
switch (error) {
#define _PI_ERRC(NAME, VAL) \
case NAME: \
return #NAME;
#define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) \
case NAME: \
return MSG;
#include <sycl/detail/pi_error.def>
#undef _PI_ERRC
#undef _PI_ERRC_WITH_MSG

default:
return "Unknown error code";
}
}
} // namespace detail

} // namespace _V1
} // namespace sycl
1 change: 1 addition & 0 deletions sycl/source/spirv_ops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include <CL/__spirv/spirv_ops.hpp>
#include <detail/platform_util.hpp>
#include <sycl/detail/iostream_proxy.hpp>
#include <sycl/exception.hpp>

#include <atomic>
Expand Down
Loading