Skip to content

Commit c2eb928

Browse files
[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.
1 parent 88b7d45 commit c2eb928

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

sycl/include/sycl/detail/common.hpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ class __SYCL_EXPORT tls_code_loc_t {
148148
bool MLocalScope = true;
149149
};
150150

151-
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error);
152-
153-
inline std::string codeToString(pi_int32 code) {
154-
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
155-
")");
156-
}
157-
158151
} // namespace detail
159152
} // namespace _V1
160153
} // namespace sycl

sycl/include/sycl/exception.hpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

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

6059
namespace detail {
60+
__SYCL_EXPORT const char *stringifyErrorCode(pi_int32 error);
61+
62+
inline std::string codeToString(pi_int32 code) {
63+
return std::string(std::to_string(code) + " (" + stringifyErrorCode(code) +
64+
")");
65+
}
66+
6167
class __SYCL_EXPORT SYCLCategory : public std::error_category {
6268
public:
6369
const char *name() const noexcept override { return "sycl"; }

sycl/source/detail/common.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,6 @@ tls_code_loc_t::~tls_code_loc_t() {
5353

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

56-
const char *stringifyErrorCode(pi_int32 error) {
57-
switch (error) {
58-
#define _PI_ERRC(NAME, VAL) \
59-
case NAME: \
60-
return #NAME;
61-
#define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) \
62-
case NAME: \
63-
return MSG;
64-
#include <sycl/detail/pi_error.def>
65-
#undef _PI_ERRC
66-
#undef _PI_ERRC_WITH_MSG
67-
68-
default:
69-
return "Unknown error code";
70-
}
71-
}
7256
} // namespace detail
7357
} // namespace _V1
7458
} // namespace sycl

sycl/source/exception.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,24 @@ std::error_code make_error_code(sycl::errc Err) noexcept {
9494
return {static_cast<int>(Err), sycl_category()};
9595
}
9696

97+
namespace detail {
98+
const char *stringifyErrorCode(pi_int32 error) {
99+
switch (error) {
100+
#define _PI_ERRC(NAME, VAL) \
101+
case NAME: \
102+
return #NAME;
103+
#define _PI_ERRC_WITH_MSG(NAME, VAL, MSG) \
104+
case NAME: \
105+
return MSG;
106+
#include <sycl/detail/pi_error.def>
107+
#undef _PI_ERRC
108+
#undef _PI_ERRC_WITH_MSG
109+
110+
default:
111+
return "Unknown error code";
112+
}
113+
}
114+
} // namespace detail
115+
97116
} // namespace _V1
98117
} // namespace sycl

sycl/source/spirv_ops.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <CL/__spirv/spirv_ops.hpp>
1010
#include <detail/platform_util.hpp>
11+
#include <sycl/detail/iostream_proxy.hpp>
1112
#include <sycl/exception.hpp>
1213

1314
#include <atomic>

0 commit comments

Comments
 (0)