Skip to content

Commit 8702cb4

Browse files
committed
CI: make sure to use Clang as CUDA compiler on Clang+CUDA builds
- set CMAKE_CUDA_COMPILER=clang++ in CI script - changed CUDA arch specification with SPIRIT_CUDA_ARCH to number only (dropped prefix "sm_") in order to be able to set CMAKE_CUDA_ARCHITECTURES needed for Clang properly (which only expects a number)
1 parent 0a219e8 commit 8702cb4

3 files changed

Lines changed: 32 additions & 23 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -158,16 +158,16 @@ jobs:
158158
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-16 16
159159
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-16 16
160160
161-
- name: 📚 Install NVIDIA HPC SDK
161+
- name: 📚 Install CUDA Toolkit
162162
if: matrix.parallelisation == 'cuda'
163163
shell: bash
164164
run: |
165-
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
166-
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
167-
sudo apt update -y
168-
sudo apt install -y nvhpc-23-3
169-
echo "/opt/nvidia/hpc_sdk/Linux_x86_64/23.3/compilers/bin" >> $GITHUB_PATH
170-
echo "/opt/nvidia/hpc_sdk/Linux_x86_64/23.3/math_libs/lib64" >> $GITHUB_PATH
165+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb
166+
sudo dpkg -i cuda-keyring_1.0-1_all.deb
167+
sudo apt-get update
168+
sudo apt-get -y install cuda
169+
echo "/usr/local/cuda-12.1/bin" >> $GITHUB_PATH
170+
echo "/usr/local/cuda-12.1/lib64" >> $GITHUB_PATH
171171
172172
- name: 📚 Install LLVM (MacOS)
173173
if: matrix.os == 'macos-13'
@@ -199,7 +199,7 @@ jobs:
199199
if: matrix.parallelisation == 'cuda'
200200
shell: bash
201201
working-directory: ${{runner.workspace}}/build
202-
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_FLAGS -DSPIRIT_USE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=/opt/nvidia/hpc_sdk/Linux_x86_64/23.3/cuda/
202+
run: cmake $GITHUB_WORKSPACE -DCMAKE_CUDA_COMPILER=clang++ -DSPIRIT_CUDA_ARCH=70 -DCMAKE_BUILD_TYPE=$BUILD_TYPE $CMAKE_FLAGS -DSPIRIT_USE_CUDA=ON -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-12.1/
203203

204204
- name: ⚙ Configure with OpenMP
205205
if: matrix.parallelisation == 'openmp'
@@ -239,14 +239,15 @@ jobs:
239239
steps:
240240
- uses: actions/checkout@v3
241241

242-
- name: Force downgrade to gcc-10 on Ubuntu 22.04 to avoid a bug in gcc-11.3 header
242+
- name: Force upgrade to gcc-12 on Ubuntu 22.04 (resolve issue with __noinline__ macro)
243243
if: matrix.config.os == 'ubuntu-22.04'
244244
shell: bash
245245
run: |
246+
sudo add-apt-repository ppa:jonathonf/gcc
246247
sudo apt-get --purge remove "g++*"
247-
sudo apt install g++-10
248-
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 10
249-
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-10 10
248+
sudo apt install g++-12
249+
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10
250+
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10
250251
251252
- name: 📚 Install NVIDIA HPC SDK and some libs
252253
shell: bash
@@ -478,7 +479,7 @@ jobs:
478479
- os: ubuntu-22.04
479480
env:
480481
BUILD_TYPE: Release
481-
CMAKE_FLAGS: -DSPIRIT_UI_USE_IMGUI=OFF -DSPIRIT_UI_CXX_USE_QT=OFF -DSPIRIT_USE_CUDA=ON -DSPIRIT_CUDA_ARCH=sm_70
482+
CMAKE_FLAGS: -DSPIRIT_UI_USE_IMGUI=OFF -DSPIRIT_UI_CXX_USE_QT=OFF -DSPIRIT_USE_CUDA=ON -DSPIRIT_CUDA_ARCH=70
482483

483484
steps:
484485
- uses: actions/checkout@v3
@@ -763,4 +764,4 @@ jobs:
763764
tag_name: ${{ github.ref }}
764765
release_name: Release ${{ github.ref }}
765766
body: ${{ steps.changelog.outputs.changelog }}
766-
draft: true
767+
draft: true

‎CMakeLists.txt‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ set( SPIRIT_USE_THREADS OFF CACHE BOOL "Use std threads to speed up certa
2626
set( SPIRIT_USE_FFTW ON CACHE BOOL "If available, use the FFTW library instead of kissFFT." )
2727
### Set the scalar type used in the Spirit library
2828
set( SPIRIT_SCALAR_TYPE "double" CACHE STRING "The scalar type to be used in the Spirit library." )
29-
### Set the compute capability for CUDA compilation
30-
set( SPIRIT_CUDA_ARCH "sm_60" CACHE STRING "The CUDA compute architecture to use in case of a CUDA build." )
29+
### Set the compute capability for CUDA compilation (note: specify without prefix "sm_")
30+
set( SPIRIT_CUDA_ARCH "60" CACHE STRING "The CUDA compute architecture to use in case of a CUDA build." )
3131
####################################################################
3232
### CMake Verbosity
3333
option( SPIRIT_PRINT_SOURCES "Print Headers and Sources from Cmake." OFF )
@@ -303,4 +303,4 @@ install( FILES ${CMAKE_CURRENT_LIST_DIR}/ui-cpp/ui-imgui/thirdparty/stb/LICENSE
303303

304304
######### Write VERSION.txt ########################################
305305
file( WRITE "${CMAKE_SOURCE_DIR}/VERSION.txt" "${SPIRIT_META_NAME_VERSION}" )
306-
####################################################################
306+
####################################################################

‎core/CMakeLists.txt‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ option( SPIRIT_USE_FFTW "If available, use the FFTW library instead of k
2828
### Set the scalar type used in the Spirit library
2929
option( SPIRIT_SCALAR_TYPE "Use std threads to speed up certain parts of the code." "double" )
3030
### Set the compute capability for CUDA compilation
31-
option( SPIRIT_CUDA_ARCH "Use std threads to speed up certain parts of the code." "sm_60" )
31+
option( SPIRIT_CUDA_ARCH "Use std threads to speed up certain parts of the code." "60" )
3232
####################################################################
3333

3434

@@ -146,20 +146,28 @@ if( SPIRIT_USE_CUDA )
146146
set( SPIRIT_CUDA_LIBS "${CUDA_LIBRARIES};${CUDA_CUFFT_LIBRARIES};${CUDA_curand_LIBRARY}" )
147147
set( FFT_LIB ${CUDA_CUFFT_LIBRARIES} )
148148

149-
if( "${CMAKE_CXX_COMPILER_ID}" MATCHES "NVHPC" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "NVCC" )
150-
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo -arch=${SPIRIT_CUDA_ARCH} --expt-relaxed-constexpr --expt-extended-lambda" )
149+
if( "${CMAKE_CUDA_COMPILER_ID}" MATCHES "NVIDIA" )
150+
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -lineinfo -arch=sm_${SPIRIT_CUDA_ARCH} --expt-relaxed-constexpr --expt-extended-lambda" )
151151
### Deactivate CUDA warning inside Eigen such as "warning: __host__ annotation is ignored on a function("Quaternion") that is explicitly defaulted on its first declaration"
152152
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe=\"--diag_suppress=esa_on_defaulted_function_ignored\"")
153153
### Display warning number when writing a warning
154154
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe \"--display_error_number\"" )
155155

156156
set( META_COMPILER "${META_COMPILER} and nvcc" )
157157
set( META_COMPILER_VERSION "${META_COMPILER_VERSION} and ${CUDA_VERSION}" )
158-
set( META_COMPILER_FULL "${META_COMPILER_FULL} and nvcc (${CUDA_VERSION}) for cuda arch \\\"${SPIRIT_CUDA_ARCH}\\\"" )
158+
set( META_COMPILER_FULL "${META_COMPILER_FULL} and nvcc (${CUDA_VERSION}) for cuda arch \\\"sm_${SPIRIT_CUDA_ARCH}\\\"" )
159+
160+
elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "NVHPC")
161+
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -cuda" )
162+
163+
set( META_COMPILER "${META_COMPILER}" )
164+
set( META_COMPILER_VERSION "${META_COMPILER_VERSION} and ${CUDA_VERSION}" )
165+
set( META_COMPILER_FULL "${META_COMPILER_FULL} and nvcc (${CUDA_VERSION}) for cuda arch \\\"sm_${SPIRIT_CUDA_ARCH}\\\"" )
166+
159167
else()
168+
set( CMAKE_CUDA_ARCHITECTURES ${SPIRIT_CUDA_ARCH} )
160169
# set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D__STRICT_ANSI__" )
161170
# set( SPIRIT_COMPILE_DEFINITIONS "${SPIRIT_COMPILE_DEFINITIONS} -D__STRICT_ANSI__" )
162-
163171
set( META_COMPILER "${META_COMPILER}" )
164172
set( META_COMPILER_VERSION "${META_COMPILER_VERSION} and CUDA ${CUDA_VERSION}" )
165173
set( META_COMPILER_FULL "${META_COMPILER_FULL} and (CUDA ${CUDA_VERSION}) for cuda arch \\\"${SPIRIT_CUDA_ARCH}\\\"" )
@@ -741,4 +749,4 @@ if( SPIRIT_PRINT_SOURCES )
741749
endif()
742750
MESSAGE( STATUS ">> --------------------- Spirit done ---------------------------------- <<" )
743751
message( STATUS ">> CMake CXX Flags: ${CMAKE_CXX_FLAGS}" )
744-
MESSAGE( STATUS ">> -------------------------------------------------------------------- <<" )
752+
MESSAGE( STATUS ">> -------------------------------------------------------------------- <<" )

0 commit comments

Comments
 (0)