From fc2baa35b5c7b696a542388c25b2b3a6dfbf19e3 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sun, 29 Nov 2026 10:48:42 +0100 Subject: [PATCH] Leave out the AVX2 dispatch with NVIDIA HPC nvc++ defines __GNUC__, but its headers declare the AVX2 intrinsics only when the translation unit is compiled for AVX2, so ci_nvhpc failed with undefined _mm256_* identifiers. Signed-off-by: Niels Lohmann --- include/nlohmann/detail/input/simd_scan.hpp | 4 +++- single_include/nlohmann/json.hpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/nlohmann/detail/input/simd_scan.hpp b/include/nlohmann/detail/input/simd_scan.hpp index ffff69f3e..ca62c4a19 100644 --- a/include/nlohmann/detail/input/simd_scan.hpp +++ b/include/nlohmann/detail/input/simd_scan.hpp @@ -86,7 +86,9 @@ // to the lexer's string loop, and every translation unit has the same // definitions. Not with MSVC (not measured), and not with GCC for Windows, // which does not align the stack for spilled AVX registers (GCC bug 54412). -#if JSON_SCAN_SSE2 && !defined(NLOHMANN_JSON_NO_TARGET_ATTRIBUTE) && !(defined(_WIN32) && !defined(__clang__)) && ((defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__cpp_modules))) +// Not with NVIDIA HPC (nvc++ defines __GNUC__ but declares the AVX2 intrinsics +// only when the translation unit is compiled for AVX2). +#if JSON_SCAN_SSE2 && !defined(NLOHMANN_JSON_NO_TARGET_ATTRIBUTE) && !defined(__NVCOMPILER) && !(defined(_WIN32) && !defined(__clang__)) && ((defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__cpp_modules))) #ifndef NLOHMANN_JSON_CPUID_INCLUDED #define NLOHMANN_JSON_CPUID_INCLUDED #include diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 4167c8772..24a0ebaf4 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -12642,7 +12642,9 @@ NLOHMANN_JSON_NAMESPACE_END // to the lexer's string loop, and every translation unit has the same // definitions. Not with MSVC (not measured), and not with GCC for Windows, // which does not align the stack for spilled AVX registers (GCC bug 54412). -#if JSON_SCAN_SSE2 && !defined(NLOHMANN_JSON_NO_TARGET_ATTRIBUTE) && !(defined(_WIN32) && !defined(__clang__)) && ((defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__cpp_modules))) +// Not with NVIDIA HPC (nvc++ defines __GNUC__ but declares the AVX2 intrinsics +// only when the translation unit is compiled for AVX2). +#if JSON_SCAN_SSE2 && !defined(NLOHMANN_JSON_NO_TARGET_ATTRIBUTE) && !defined(__NVCOMPILER) && !(defined(_WIN32) && !defined(__clang__)) && ((defined(__clang__) && __clang_major__ >= 4) || (defined(__GNUC__) && !defined(__clang__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)) && !defined(__cpp_modules))) #ifndef NLOHMANN_JSON_CPUID_INCLUDED #define NLOHMANN_JSON_CPUID_INCLUDED #include