From 26e2c4f617ba1c47caa8e5c1fe812a221f411df7 Mon Sep 17 00:00:00 2001 From: Morris Hafner Date: Fri, 30 Aug 2024 12:34:48 +0000 Subject: [PATCH] Add nvc++ support --- Eigen/src/Core/arch/NEON/Complex.h | 15 ++++++--------- Eigen/src/Core/util/Macros.h | 7 +++++++ cmake/EigenTesting.cmake | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Eigen/src/Core/arch/NEON/Complex.h b/Eigen/src/Core/arch/NEON/Complex.h index a0467113c..4190d1bd1 100644 --- a/Eigen/src/Core/arch/NEON/Complex.h +++ b/Eigen/src/Core/arch/NEON/Complex.h @@ -502,13 +502,10 @@ EIGEN_STRONG_INLINE Packet2cf pexp(const Packet2cf& a) { //---------- double ---------- #if EIGEN_ARCH_ARM64 && !EIGEN_APPLE_DOUBLE_NEON_BUG -// See bug 1325, clang fails to call vld1q_u64. -#if EIGEN_COMP_CLANG || EIGEN_COMP_CASTXML || EIGEN_COMP_CPE -static uint64x2_t p2ul_CONJ_XOR = {0x0, 0x8000000000000000}; -#else -const uint64_t p2ul_conj_XOR_DATA[] = {0x0, 0x8000000000000000}; -static uint64x2_t p2ul_CONJ_XOR = vld1q_u64(p2ul_conj_XOR_DATA); -#endif +inline uint64x2_t p2ul_CONJ_XOR() { + static const uint64_t p2ul_conj_XOR_DATA[] = {0x0, 0x8000000000000000}; + return vld1q_u64(p2ul_conj_XOR_DATA); +} struct Packet1cd { EIGEN_STRONG_INLINE Packet1cd() {} @@ -592,7 +589,7 @@ EIGEN_STRONG_INLINE Packet1cd pnegate(const Packet1cd& a) { template <> EIGEN_STRONG_INLINE Packet1cd pconj(const Packet1cd& a) { - return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v), p2ul_CONJ_XOR))); + return Packet1cd(vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(a.v), p2ul_CONJ_XOR()))); } #ifdef __ARM_FEATURE_COMPLEX @@ -622,7 +619,7 @@ EIGEN_STRONG_INLINE Packet1cd pmul(const Packet1cd& a, const Packet1c // Multiply the imag a with b v2 = vmulq_f64(v2, b.v); // Conjugate v2 - v2 = vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(v2), p2ul_CONJ_XOR)); + v2 = vreinterpretq_f64_u64(veorq_u64(vreinterpretq_u64_f64(v2), p2ul_CONJ_XOR())); // Swap real/imag elements in v2. v2 = preverse(v2); // Add and return the result diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 91c821bd5..226844f64 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -196,6 +196,13 @@ #define EIGEN_COMP_PGI 0 #endif +/// \internal EIGEN_COMP_NVHPC set to NVHPC version if the compiler is nvc++ +#if defined(__NVCOMPILER) +#define EIGEN_COMP_NVHPC (__NVCOMPILER_MAJOR__ * 100 + __NVCOMPILER_MINOR__) +#else +#define EIGEN_COMP_NVHPC 0 +#endif + /// \internal EIGEN_COMP_ARM set to 1 if the compiler is ARM Compiler #if defined(__CC_ARM) || defined(__ARMCC_VERSION) #define EIGEN_COMP_ARM 1 diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index 9f75c1b8a..a1488fc47 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -75,7 +75,8 @@ macro(ei_add_test_internal testname testname_with_suffix) # let the user pass flags. if(${ARGC} GREATER 2) - target_compile_options(${targetname} PRIVATE ${ARGV2}) + separate_arguments(compile_options NATIVE_COMMAND ${ARGV2}) + target_compile_options(${targetname} PRIVATE ${compile_options}) endif() if(EIGEN_TEST_CUSTOM_CXX_FLAGS)