From 6a4e011717ce5874fb7fcbce6720c54db781a13e Mon Sep 17 00:00:00 2001 From: Oliver Lee Date: Mon, 6 May 2024 17:58:57 -0700 Subject: [PATCH] handle precondition error printing for multiple archs --- include/experimental/__p0009_bits/macros.hpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/include/experimental/__p0009_bits/macros.hpp b/include/experimental/__p0009_bits/macros.hpp index 2a5781e8..37a9c2e7 100644 --- a/include/experimental/__p0009_bits/macros.hpp +++ b/include/experimental/__p0009_bits/macros.hpp @@ -106,9 +106,17 @@ namespace MDSPAN_IMPL_STANDARD_NAMESPACE { namespace detail { +#ifdef __CUDA_ARCH__ + #define eprintf printf +#elif __SYCL_ARCH__ + #define eprintf sycl::ext::oneapi::experimental::printf +#else + const auto eprintf = [](auto... args) { (void)std::fprintf(::stderr, args...); }; +#endif + inline void default_precondition_violation_handler(const char* cond, const char* file, unsigned line) { - (void)std::fprintf(::stderr, "%s:%u: precondition failure: `%s`\n", file, line, cond); + eprintf("%s:%u: precondition failure: `%s`\n", file, line, cond); std::abort(); } @@ -132,7 +140,7 @@ namespace MDSPAN_IMPL_STANDARD_NAMESPACE { namespace detail { template -constexpr void precondition(const char* cond, const char* file, unsigned line) +MDSPAN_FUNCTION constexpr void precondition(const char* cond, const char* file, unsigned line) { if (not check) { return; }