Skip to content

[SYCL] Remove *SUPPRESS* macros and move some others to source/ #13905

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 27, 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
68 changes: 0 additions & 68 deletions sycl/include/sycl/detail/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,75 +165,7 @@ class __SYCL_EXPORT tls_code_loc_t {
/* ":" __SYCL_STRINGIFY(__LINE__) ": " */ \
"Native API returns: "

#ifndef __SYCL_SUPPRESS_PI_ERROR_REPORT
#include <sycl/detail/iostream_proxy.hpp>
// TODO: rename all names with direct use of OCL/OPENCL to be backend agnostic.
#define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
std::cerr << __SYCL_PI_ERROR_REPORT << sycl::detail::codeToString(code) \
<< std::endl; \
} \
}
#endif

#ifndef SYCL_SUPPRESS_EXCEPTIONS
#include <sycl/exception.hpp>
// SYCL 1.2.1 exceptions
#define __SYCL_REPORT_PI_ERR_TO_EXC(expr, exc, str) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
std::string err_str = \
str ? "\n" + std::string(str) + "\n" : std::string{}; \
throw exc(__SYCL_PI_ERROR_REPORT + sycl::detail::codeToString(code) + \
err_str, \
code); \
} \
}
#define __SYCL_REPORT_PI_ERR_TO_EXC_THROW(code, exc, str) \
__SYCL_REPORT_PI_ERR_TO_EXC(code, exc, str)
#define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_PI_ERR_TO_EXC(code, sycl::runtime_error, nullptr)
#else
#define __SYCL_REPORT_PI_ERR_TO_EXC_BASE(code) \
__SYCL_REPORT_PI_ERR_TO_STREAM(code)
#endif
// SYCL 2020 exceptions
#define __SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(expr, errc) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
throw sycl::exception(sycl::make_error_code(errc), \
__SYCL_PI_ERROR_REPORT + \
sycl::detail::codeToString(code)); \
} \
}
#define __SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(code, errc) \
__SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(code, errc)

#ifdef __SYCL_SUPPRESS_PI_ERROR_REPORT
// SYCL 1.2.1 exceptions
#define __SYCL_CHECK_OCL_CODE(X) (void)(X)
#define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
{ \
(void)(X); \
(void)(STR); \
}
#define __SYCL_CHECK_OCL_CODE_NO_EXC(X) (void)(X)
// SYCL 2020 exceptions
#define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) (void)(X)
#else
// SYCL 1.2.1 exceptions
#define __SYCL_CHECK_OCL_CODE(X) __SYCL_REPORT_PI_ERR_TO_EXC_BASE(X)
#define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
__SYCL_REPORT_PI_ERR_TO_EXC_THROW(X, EXC, STR)
#define __SYCL_CHECK_OCL_CODE_NO_EXC(X) __SYCL_REPORT_PI_ERR_TO_STREAM(X)
// SYCL 2020 exceptions
#define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) \
__SYCL_REPORT_ERR_TO_EXC_THROW_VIA_ERRC(X, ERRC)
#endif

// Helper for enabling empty-base optimizations on MSVC.
// TODO: Remove this when MSVC has this optimization enabled by default.
Expand Down
2 changes: 2 additions & 0 deletions sycl/source/detail/device_binary_image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include <sycl/detail/os_util.hpp>
#include <sycl/detail/pi.hpp>

#include <sycl/detail/iostream_proxy.hpp>

#include <atomic>
#include <cstring>
#include <memory>
Expand Down
40 changes: 40 additions & 0 deletions sycl/source/detail/plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,46 @@
#include "xpti/xpti_trace_framework.h"
#endif

#include <sycl/detail/iostream_proxy.hpp>

#define __SYCL_REPORT_PI_ERR_TO_STREAM(expr) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
std::cerr << __SYCL_PI_ERROR_REPORT << sycl::detail::codeToString(code) \
<< std::endl; \
} \
}

#define __SYCL_REPORT_PI_ERR_TO_EXC(expr, exc, str) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
std::string err_str = \
str ? "\n" + std::string(str) + "\n" : std::string{}; \
throw exc(__SYCL_PI_ERROR_REPORT + sycl::detail::codeToString(code) + \
err_str, \
code); \
} \
}

#define __SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(expr, errc) \
{ \
auto code = expr; \
if (code != PI_SUCCESS) { \
throw sycl::exception(sycl::make_error_code(errc), \
__SYCL_PI_ERROR_REPORT + \
sycl::detail::codeToString(code)); \
} \
}

#define __SYCL_CHECK_OCL_CODE_THROW(X, EXC, STR) \
__SYCL_REPORT_PI_ERR_TO_EXC(X, EXC, STR)
#define __SYCL_CHECK_OCL_CODE_NO_EXC(X) __SYCL_REPORT_PI_ERR_TO_STREAM(X)

#define __SYCL_CHECK_CODE_THROW_VIA_ERRC(X, ERRC) \
__SYCL_REPORT_ERR_TO_EXC_VIA_ERRC(X, ERRC)

namespace sycl {
inline namespace _V1 {
namespace detail {
Expand Down
2 changes: 1 addition & 1 deletion sycl/test/include_deps/sycl_buffer.hpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
// CHECK-NEXT: CL/cl_platform.h
// CHECK-NEXT: CL/cl_ext.h
// CHECK-NEXT: detail/common.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: range.hpp
// CHECK-NEXT: info/info_desc.hpp
// CHECK-NEXT: detail/type_traits.hpp
Expand Down Expand Up @@ -75,6 +74,7 @@
// CHECK-NEXT: aliases.hpp
// CHECK-NEXT: half_type.hpp
// CHECK-NEXT: bit_cast.hpp
// CHECK-NEXT: detail/iostream_proxy.hpp
// CHECK-NEXT: detail/vector_traits.hpp
// CHECK-NEXT: ext/oneapi/matrix/matrix-unified-utils.hpp
// CHECK-NEXT: info/platform_traits.def
Expand Down
Loading