From c2eb928aac5d0ffbe3c0d3a32848f6bf7975ed2b Mon Sep 17 00:00:00 2001 From: aelovikov-intel Date: Fri, 24 May 2024 10:50:47 -0700 Subject: [PATCH] [SYCL] Move `codeToString` `common.hpp` -> `exception.hpp` (#13904) That is its only use inside includes with others under `source/`. Breaks cyclical include dependency between those headers. --- sycl/include/sycl/detail/common.hpp | 7 ------- sycl/include/sycl/exception.hpp | 8 +++++++- sycl/source/detail/common.cpp | 16 ---------------- sycl/source/exception.cpp | 19 +++++++++++++++++++ sycl/source/spirv_ops.cpp | 1 + 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/sycl/include/sycl/detail/common.hpp b/sycl/include/sycl/detail/common.hpp index a8c94e32d81c..13919a39f823 100644 --- a/sycl/include/sycl/detail/common.hpp +++ b/sycl/include/sycl/detail/common.hpp @@ -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 diff --git a/sycl/include/sycl/exception.hpp b/sycl/include/sycl/exception.hpp index 7cd41224b315..472d5b335f14 100644 --- a/sycl/include/sycl/exception.hpp +++ b/sycl/include/sycl/exception.hpp @@ -12,7 +12,6 @@ #include // for backend #include // for cl_int -#include // for codeToString #include // for __SYCL2020_DEPRECATED #include // for __SYCL_EXPORT #include // for pi_int32 @@ -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"; } diff --git a/sycl/source/detail/common.cpp b/sycl/source/detail/common.cpp index 9e6aee1e8569..7bc85e026dc7 100644 --- a/sycl/source/detail/common.cpp +++ b/sycl/source/detail/common.cpp @@ -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 -#undef _PI_ERRC -#undef _PI_ERRC_WITH_MSG - - default: - return "Unknown error code"; - } -} } // namespace detail } // namespace _V1 } // namespace sycl diff --git a/sycl/source/exception.cpp b/sycl/source/exception.cpp index 836769389f98..e558d0ef2999 100644 --- a/sycl/source/exception.cpp +++ b/sycl/source/exception.cpp @@ -94,5 +94,24 @@ std::error_code make_error_code(sycl::errc Err) noexcept { return {static_cast(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 +#undef _PI_ERRC +#undef _PI_ERRC_WITH_MSG + + default: + return "Unknown error code"; + } +} +} // namespace detail + } // namespace _V1 } // namespace sycl diff --git a/sycl/source/spirv_ops.cpp b/sycl/source/spirv_ops.cpp index a635dea89d95..8a80e53ec974 100644 --- a/sycl/source/spirv_ops.cpp +++ b/sycl/source/spirv_ops.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include