From 394f72949340c6a505a07cab8259bbce1117ffd3 Mon Sep 17 00:00:00 2001 From: Federico Busato Date: Tue, 25 Jan 2022 11:59:50 -0800 Subject: [PATCH 1/3] Fixes NVIDIA HPC compiler and Intel ICC compatibility --- include/fmt/core.h | 8 +++++++- include/fmt/format.h | 8 +++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 44fb16b33f72..ee054cde0716 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -49,6 +49,12 @@ # define FMT_ICC_VERSION 0 #endif +#ifdef __NVCOMPILER +# define FMT_NVHPC_VERSION (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__) +#else +# define FMT_NVHPC_VERSION 0 +#endif + #ifdef __NVCC__ # define FMT_NVCC __NVCC__ #else @@ -287,7 +293,7 @@ // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") -#ifndef __OPTIMIZE__ +#ifndef __OPTIMIZE__ && !FMT_NVHPC_VERSION FMT_GCC_PRAGMA("GCC optimize(\"Og\")") #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index b4caec26a666..1267aba355da 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -159,10 +159,12 @@ FMT_END_NAMESPACE // __builtin_ctz is broken in Intel Compiler Classic on Windows: // https://github.com/fmtlib/fmt/issues/2510. #ifndef __ICL -# if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || FMT_ICC_VERSION +# if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || \ + FMT_ICC_VERSION || FMT_NVHPC_VERSION # define FMT_BUILTIN_CTZ(n) __builtin_ctz(n) # endif -# if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || FMT_ICC_VERSION +# if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || \ + FMT_ICC_VERSION || FMT_NVHPC_VERSION # define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) # endif #endif @@ -354,7 +356,7 @@ template <> constexpr auto num_bits() -> int { FMT_INLINE void assume(bool condition) { (void)condition; -#if FMT_HAS_BUILTIN(__builtin_assume) +#if FMT_HAS_BUILTIN(__builtin_assume) && !FMT_ICC_VERSION __builtin_assume(condition); #endif } From ffba4c74f0e4e67b51e3e3984191a5f33ff40538 Mon Sep 17 00:00:00 2001 From: Federico Busato Date: Tue, 25 Jan 2022 12:04:54 -0800 Subject: [PATCH 2/3] Fixes NVIDIA HPC compiler and Intel ICC compatibility --- include/fmt/core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index ee054cde0716..c0032b028940 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -293,7 +293,7 @@ // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") -#ifndef __OPTIMIZE__ && !FMT_NVHPC_VERSION +#if !defined(__OPTIMIZE__) && !FMT_NVHPC_VERSION FMT_GCC_PRAGMA("GCC optimize(\"Og\")") #endif From 384dc2a4c5705f1f28c2545657103ac13b8a63d6 Mon Sep 17 00:00:00 2001 From: Federico Busato Date: Wed, 26 Jan 2022 15:37:33 -0800 Subject: [PATCH 3/3] Rename FMT_NVHPC_VERSION to FMT_NVCOMPILER_VERSION --- include/fmt/core.h | 7 ++++--- include/fmt/format.h | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index c0032b028940..e27578ed1495 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -50,9 +50,10 @@ #endif #ifdef __NVCOMPILER -# define FMT_NVHPC_VERSION (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__) +# define FMT_NVCOMPILER_VERSION \ + (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__) #else -# define FMT_NVHPC_VERSION 0 +# define FMT_NVCOMPILER_VERSION 0 #endif #ifdef __NVCC__ @@ -293,7 +294,7 @@ // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") -#if !defined(__OPTIMIZE__) && !FMT_NVHPC_VERSION +#if !defined(__OPTIMIZE__) && !FMT_NVCOMPILER_VERSION FMT_GCC_PRAGMA("GCC optimize(\"Og\")") #endif diff --git a/include/fmt/format.h b/include/fmt/format.h index 1267aba355da..cf2f4c346a32 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -160,11 +160,11 @@ FMT_END_NAMESPACE // https://github.com/fmtlib/fmt/issues/2510. #ifndef __ICL # if FMT_HAS_BUILTIN(__builtin_ctz) || FMT_GCC_VERSION || \ - FMT_ICC_VERSION || FMT_NVHPC_VERSION + FMT_ICC_VERSION || FMT_NVCOMPILER_VERSION # define FMT_BUILTIN_CTZ(n) __builtin_ctz(n) # endif # if FMT_HAS_BUILTIN(__builtin_ctzll) || FMT_GCC_VERSION || \ - FMT_ICC_VERSION || FMT_NVHPC_VERSION + FMT_ICC_VERSION || FMT_NVCOMPILER_VERSION # define FMT_BUILTIN_CTZLL(n) __builtin_ctzll(n) # endif #endif