From b00a1eac7519cf0b0053818116bd25e3144f4280 Mon Sep 17 00:00:00 2001 From: Federico <55920584+federico-busato@users.noreply.github.com> Date: Wed, 26 Jan 2022 15:53:04 -0800 Subject: [PATCH] Fixes NVIDIA HPC compiler and Intel ICC compatibility (#2732) * Fixes NVIDIA HPC compiler and Intel ICC compatibility * Fixes NVIDIA HPC compiler and Intel ICC compatibility * Rename FMT_NVHPC_VERSION to FMT_NVCOMPILER_VERSION Co-authored-by: Federico Busato --- include/fmt/core.h | 9 ++++++++- include/fmt/format.h | 8 +++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 44fb16b3..e27578ed 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -49,6 +49,13 @@ # define FMT_ICC_VERSION 0 #endif +#ifdef __NVCOMPILER +# define FMT_NVCOMPILER_VERSION \ + (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__) +#else +# define FMT_NVCOMPILER_VERSION 0 +#endif + #ifdef __NVCC__ # define FMT_NVCC __NVCC__ #else @@ -287,7 +294,7 @@ // Enable minimal optimizations for more compact code in debug mode. FMT_GCC_PRAGMA("GCC push_options") -#ifndef __OPTIMIZE__ +#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 b4caec26..cf2f4c34 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_NVCOMPILER_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_NVCOMPILER_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 }