From 241af1c0bab2a52197165483e7d72ccccc641ec2 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Mon, 23 Feb 2026 18:51:15 -0800 Subject: [PATCH] Add NVHPC (nvc++) compiler support and CI build/test jobs libeigen/eigen!2186 Closes #3032 Co-authored-by: Rasmus Munk Larsen --- Eigen/src/Core/util/Macros.h | 8 ++++---- bench/btl/generic_bench/utils/utilities.h | 4 +++- ci/build.linux.gitlab-ci.yml | 15 +++++++++++++++ ci/test.linux.gitlab-ci.yml | 20 ++++++++++++++++++++ cmake/EigenTesting.cmake | 2 +- 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index dff613252..7288cee77 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -278,10 +278,10 @@ /// \internal EIGEN_COMP_GNUC_STRICT set to 1 if the compiler is really GCC and not a compatible compiler (e.g., ICC, /// clang, mingw, etc.) -#if EIGEN_COMP_GNUC && \ - !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_CLANGICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || \ - EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN || EIGEN_COMP_FCC || EIGEN_COMP_CLANGFCC || \ - EIGEN_COMP_CPE || EIGEN_COMP_CLANGCPE || EIGEN_COMP_LCC) +#if EIGEN_COMP_GNUC && \ + !(EIGEN_COMP_CLANG || EIGEN_COMP_ICC || EIGEN_COMP_CLANGICC || EIGEN_COMP_MINGW || EIGEN_COMP_PGI || \ + EIGEN_COMP_NVHPC || EIGEN_COMP_IBM || EIGEN_COMP_ARM || EIGEN_COMP_EMSCRIPTEN || EIGEN_COMP_FCC || \ + EIGEN_COMP_CLANGFCC || EIGEN_COMP_CPE || EIGEN_COMP_CLANGCPE || EIGEN_COMP_LCC) #define EIGEN_COMP_GNUC_STRICT 1 #else #define EIGEN_COMP_GNUC_STRICT 0 diff --git a/bench/btl/generic_bench/utils/utilities.h b/bench/btl/generic_bench/utils/utilities.h index 352d61a00..96d03c011 100644 --- a/bench/btl/generic_bench/utils/utilities.h +++ b/bench/btl/generic_bench/utils/utilities.h @@ -34,7 +34,9 @@ /* --- To print date and time of compilation of current source on stdout --- */ -#if defined(__GNUC__) +#if defined(__NVCOMPILER) +#define COMPILER "nvc++"; +#elif defined(__GNUC__) #define COMPILER "g++"; #elif defined(__sun) #define COMPILER "CC"; diff --git a/ci/build.linux.gitlab-ci.yml b/ci/build.linux.gitlab-ci.yml index 04573f2cc..af22f8a95 100644 --- a/ci/build.linux.gitlab-ci.yml +++ b/ci/build.linux.gitlab-ci.yml @@ -140,6 +140,20 @@ build:linux:docs: # -DEIGEN_TEST_CUSTOM_CXX_FLAGS=-fsanitize=memory # -DEIGEN_TEST_CUSTOM_LINKER_FLAGS=-fsanitize=memory +######## NVHPC ################################################################# + +# NVHPC (nvc++) uses NVIDIA's HPC SDK container image with the compilers +# pre-installed. We override EIGEN_CI_INSTALL to avoid trying to apt-get +# install the compiler. +build:linux:x86-64:nvhpc-25.1:default: + extends: .build:linux:cross:x86-64 + image: nvcr.io/nvidia/nvhpc:25.1-devel-cuda12.6-ubuntu22.04 + variables: + EIGEN_CI_C_COMPILER: nvc + EIGEN_CI_CXX_COMPILER: nvc++ + EIGEN_CI_INSTALL: "" + EIGEN_CI_CROSS_INSTALL: "" + ######## CUDA ################################################################## .build:linux:cuda: @@ -312,3 +326,4 @@ build:linux:cross:x86-64:clang-12:default:smoketest: - if: $CI_PIPELINE_SOURCE == "merge_request_event" tags: - saas-linux-medium-amd64 + diff --git a/ci/test.linux.gitlab-ci.yml b/ci/test.linux.gitlab-ci.yml index 6712337cc..e042d48d2 100644 --- a/ci/test.linux.gitlab-ci.yml +++ b/ci/test.linux.gitlab-ci.yml @@ -220,6 +220,25 @@ test:linux:x86-64:clang-19:generic:avx512dq:unsupported: variables: EIGEN_CI_CTEST_LABEL: Unsupported +##### NVHPC #################################################################### + +.test:linux:x86-64:nvhpc-25.1:default: + extends: .test:linux:x86-64 + image: nvcr.io/nvidia/nvhpc:25.1-devel-cuda12.6-ubuntu22.04 + needs: [ build:linux:x86-64:nvhpc-25.1:default ] + variables: + EIGEN_CI_INSTALL: "" + +test:linux:x86-64:nvhpc-25.1:default:official: + extends: .test:linux:x86-64:nvhpc-25.1:default + variables: + EIGEN_CI_CTEST_LABEL: Official + +test:linux:x86-64:nvhpc-25.1:default:unsupported: + extends: .test:linux:x86-64:nvhpc-25.1:default + variables: + EIGEN_CI_CTEST_LABEL: Unsupported + ##### CUDA ##################################################################### .test:linux:cuda: extends: .test:linux @@ -420,3 +439,4 @@ test:linux:x86-64:clang-12:default:smoketest: - if: $CI_PIPELINE_SOURCE == "merge_request_event" tags: - saas-linux-medium-amd64 + diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index 2a44f05c3..0e1020302 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -458,7 +458,7 @@ macro(ei_get_compilerver VAR) endif() if(MSVC) set(${VAR} "${CMAKE_CXX_COMPILER_VERSION}") - elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI") + elseif(${CMAKE_CXX_COMPILER_ID} MATCHES "PGI" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "NVHPC") set(${VAR} "${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}") else() # on all other system we rely on ${CMAKE_CXX_COMPILER}