Skip to content

Commit

Permalink
[SYCL] Move codeToString common.hpp -> exception.hpp (intel#13904)
Browse files Browse the repository at this point in the history
That is its only use inside includes with others under `source/`. Breaks
cyclical include dependency between those headers.
  • Loading branch information
aelovikov-intel committed May 24, 2024
1 parent 88b7d45 commit c2eb928
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 24 deletions.
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

0 comments on commit c2eb928

Please sign in to comment.