Add CUDA CI jobs with NVHPC (nvc++) as host and device compiler

libeigen/eigen!2204

Co-authored-by: Rasmus Munk Larsen <rmlarsen@gmail.com>
This commit is contained in:
Rasmus Munk Larsen
2026-02-24 16:54:08 -08:00
parent 2cd9bb7380
commit fa567f6bcd
4 changed files with 58 additions and 9 deletions

View File

@@ -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.

View File

@@ -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:

View File

@@ -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()

View File

@@ -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)