From aa3e6e69b436309b42bfc9cf679cdaaae1e793b8 Mon Sep 17 00:00:00 2001 From: James Beach Date: Sat, 2 May 2020 17:12:29 +0100 Subject: [PATCH 1/3] excludes std::abort from compilation when compiling CUDA with Clang as device code --- include/fmt/format-inl.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 71ee20f55026..3196387632a3 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -15,6 +15,7 @@ #include #include // for std::memmove #include +#include #include "format.h" #if !defined(FMT_STATIC_THOUSANDS_SEPARATOR) @@ -47,7 +48,11 @@ namespace internal { FMT_FUNC void assert_fail(const char* file, int line, const char* message) { print(stderr, "{}:{}: assertion failed: {}", file, line, message); +#if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__) + std::terminate(); +#else std::abort(); +#endif } #ifndef _MSC_VER From 8225d42dd88dbfbe1451d267011ec39a09f9dc6f Mon Sep 17 00:00:00 2001 From: James Beach Date: Sun, 3 May 2020 09:05:26 +0100 Subject: [PATCH 2/3] Choose std::terminate unconditionally --- include/fmt/format-inl.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 3196387632a3..6572792d82f3 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -48,10 +48,9 @@ namespace internal { FMT_FUNC void assert_fail(const char* file, int line, const char* message) { print(stderr, "{}:{}: assertion failed: {}", file, line, message); -#if defined(__clang__) && defined(__CUDA__) && defined(__CUDA_ARCH__) + // Chosen instead of std::abort to satisfy Clang in CUDA mode during device + // code pass. std::terminate(); -#else - std::abort(); #endif } From 5934c2deddf3d6b598242f58c581c2813efc6446 Mon Sep 17 00:00:00 2001 From: James Beach Date: Sun, 3 May 2020 17:00:40 +0100 Subject: [PATCH 3/3] Remove extraneous #endif --- include/fmt/format-inl.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/fmt/format-inl.h b/include/fmt/format-inl.h index 6572792d82f3..343f2f767332 100644 --- a/include/fmt/format-inl.h +++ b/include/fmt/format-inl.h @@ -51,7 +51,6 @@ FMT_FUNC void assert_fail(const char* file, int line, const char* message) { // Chosen instead of std::abort to satisfy Clang in CUDA mode during device // code pass. std::terminate(); -#endif } #ifndef _MSC_VER