From fa567f6bcd2409aa60dd790908169c1a2fb6d135 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Tue, 24 Feb 2026 16:54:08 -0800 Subject: [PATCH] Add CUDA CI jobs with NVHPC (nvc++) as host and device compiler libeigen/eigen!2204 Co-authored-by: Rasmus Munk Larsen --- ci/build.linux.gitlab-ci.yml | 17 +++++++++++++++-- ci/test.linux.gitlab-ci.yml | 24 +++++++++++++++++------- cmake/EigenTesting.cmake | 15 +++++++++++++++ test/CMakeLists.txt | 11 +++++++++++ 4 files changed, 58 insertions(+), 9 deletions(-) diff --git a/ci/build.linux.gitlab-ci.yml b/ci/build.linux.gitlab-ci.yml index e7f068ba5..f965c02f9 100644 --- a/ci/build.linux.gitlab-ci.yml +++ b/ci/build.linux.gitlab-ci.yml @@ -144,9 +144,9 @@ build:linux:cross:x86-64:clang-19:default:asan-ubsan: # 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: +build:linux:x86-64:nvhpc-26.1:default: extends: .build:linux:cross:x86-64 - image: nvcr.io/nvidia/nvhpc:25.1-devel-cuda12.6-ubuntu22.04 + image: nvcr.io/nvidia/nvhpc:26.1-devel-cuda13.1-ubuntu24.04 variables: EIGEN_CI_C_COMPILER: nvc EIGEN_CI_CXX_COMPILER: nvc++ @@ -164,11 +164,13 @@ build:linux:x86-64:nvhpc-25.1:default: EIGEN_CI_CUDA_COMPUTE_ARCH: "50;75" EIGEN_CI_BUILD_TARGET: buildtests_gpu EIGEN_CI_TEST_CUDA_CLANG: "off" + EIGEN_CI_TEST_CUDA_NVC: "off" EIGEN_CI_ADDITIONAL_ARGS: -DEIGEN_TEST_CUDA=on -DEIGEN_CUDA_CXX_FLAGS=${EIGEN_CI_CUDA_CXX_FLAGS} -DEIGEN_CUDA_COMPUTE_ARCH=${EIGEN_CI_CUDA_COMPUTE_ARCH} -DEIGEN_TEST_CUDA_CLANG=${EIGEN_CI_TEST_CUDA_CLANG} + -DEIGEN_TEST_CUDA_NVC=${EIGEN_CI_TEST_CUDA_NVC} tags: # Build on regular linux to limit GPU cost. - saas-linux-2xlarge-amd64 @@ -189,6 +191,17 @@ build:linux:cuda-12.2:clang-12: EIGEN_CI_CXX_COMPILER: clang++-12 EIGEN_CI_TEST_CUDA_CLANG: "on" +# NVHPC (nvc++), CUDA-13.1 — nvc++ as both host and device compiler +build:linux:cuda-13.1:nvhpc-26.1: + extends: .build:linux:cuda + image: nvcr.io/nvidia/nvhpc:26.1-devel-cuda13.1-ubuntu24.04 + variables: + EIGEN_CI_C_COMPILER: nvc + EIGEN_CI_CXX_COMPILER: nvc++ + EIGEN_CI_INSTALL: "" + EIGEN_CI_CROSS_INSTALL: "" + EIGEN_CI_TEST_CUDA_NVC: "on" + ######### HIP ################################################################## # Note: these are currently build-only, until we get an AMD-supported runner. diff --git a/ci/test.linux.gitlab-ci.yml b/ci/test.linux.gitlab-ci.yml index 7df351c3f..7d1fb8dfe 100644 --- a/ci/test.linux.gitlab-ci.yml +++ b/ci/test.linux.gitlab-ci.yml @@ -245,20 +245,20 @@ test:linux:x86-64:clang-19:default:asan-ubsan:unsupported: ##### NVHPC #################################################################### -.test:linux:x86-64:nvhpc-25.1:default: +.test:linux:x86-64:nvhpc-26.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 ] + image: nvcr.io/nvidia/nvhpc:26.1-devel-cuda13.1-ubuntu24.04 + needs: [ build:linux:x86-64:nvhpc-26.1:default ] variables: EIGEN_CI_INSTALL: "" -test:linux:x86-64:nvhpc-25.1:default:official: - extends: .test:linux:x86-64:nvhpc-25.1:default +test:linux:x86-64:nvhpc-26.1:default:official: + extends: .test:linux:x86-64:nvhpc-26.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 +test:linux:x86-64:nvhpc-26.1:default:unsupported: + extends: .test:linux:x86-64:nvhpc-26.1:default variables: EIGEN_CI_CTEST_LABEL: Unsupported @@ -289,6 +289,16 @@ test:linux:cuda-12.2:clang-12: EIGEN_CI_CXX_COMPILER: clang++-12 EIGEN_CI_CC_COMPILER: clang-12 +# NVHPC (nvc++), CUDA-13.1 +test:linux:cuda-13.1:nvhpc-26.1: + extends: .test:linux:cuda + image: nvcr.io/nvidia/nvhpc:26.1-devel-cuda13.1-ubuntu24.04 + needs: [ build:linux:cuda-13.1:nvhpc-26.1 ] + variables: + EIGEN_CI_CXX_COMPILER: nvc++ + EIGEN_CI_CC_COMPILER: nvc + EIGEN_CI_INSTALL: "" + ##### arm ###################################################################### .test:linux:arm: diff --git a/cmake/EigenTesting.cmake b/cmake/EigenTesting.cmake index 0e1020302..e5aefa3c5 100644 --- a/cmake/EigenTesting.cmake +++ b/cmake/EigenTesting.cmake @@ -46,6 +46,21 @@ macro(ei_add_test_internal testname testname_with_suffix) set(CUDA_CLANG_LINK_LIBRARIES ${CUDA_CLANG_LINK_LIBRARIES} "rt") endif() target_link_libraries(${targetname} ${CUDA_CLANG_LINK_LIBRARIES}) + elseif(EIGEN_TEST_CUDA_NVC) + set_source_files_properties(${filename} PROPERTIES LANGUAGE CXX) + + if(CUDA_64_BIT_DEVICE_CODE AND (EXISTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64")) + link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") + else() + link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib") + endif() + + add_executable(${targetname} ${filename}) + set(CUDA_NVC_LINK_LIBRARIES "cudart_static" "cuda" "dl" "pthread") + if (CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND CUDA_NVC_LINK_LIBRARIES "rt") + endif() + target_link_libraries(${targetname} ${CUDA_NVC_LINK_LIBRARIES}) else() cuda_add_executable(${targetname} ${filename}) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ef23acdc6..d167710bf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -407,11 +407,16 @@ endif() # CUDA unit tests option(EIGEN_TEST_CUDA "Enable CUDA support in unit tests" OFF) option(EIGEN_TEST_CUDA_CLANG "Use clang instead of nvcc to compile the CUDA tests" OFF) +option(EIGEN_TEST_CUDA_NVC "Use nvc++ (NVHPC) instead of nvcc to compile the CUDA tests" OFF) if(EIGEN_TEST_CUDA_CLANG AND NOT CMAKE_CXX_COMPILER MATCHES "clang") message(WARNING "EIGEN_TEST_CUDA_CLANG is set, but CMAKE_CXX_COMPILER does not appear to be clang.") endif() +if(EIGEN_TEST_CUDA_NVC AND NOT CMAKE_CXX_COMPILER_ID MATCHES "NVHPC") + message(WARNING "EIGEN_TEST_CUDA_NVC is set, but CMAKE_CXX_COMPILER does not appear to be nvc++.") +endif() + find_package(CUDA 9.0) if(CUDA_FOUND AND EIGEN_TEST_CUDA) # Make sure to compile without the -pedantic, -Wundef, -Wnon-virtual-dtor @@ -428,6 +433,12 @@ if(CUDA_FOUND AND EIGEN_TEST_CUDA) string(APPEND CMAKE_CXX_FLAGS " --cuda-gpu-arch=sm_${GPU}") endforeach() string(APPEND CMAKE_CXX_FLAGS " ${EIGEN_CUDA_CXX_FLAGS}") + elseif(EIGEN_TEST_CUDA_NVC) + string(APPEND CMAKE_CXX_FLAGS " -cuda") + foreach(GPU IN LISTS EIGEN_CUDA_COMPUTE_ARCH) + string(APPEND CMAKE_CXX_FLAGS " -gpu=cc${GPU}") + endforeach() + string(APPEND CMAKE_CXX_FLAGS " ${EIGEN_CUDA_CXX_FLAGS}") else() set(CUDA_PROPAGATE_HOST_FLAGS OFF) set(NVCC_ARCH_FLAGS)