Skip to content

Commit

Permalink
Add NVHPC CI workflow for cpu (#6)
Browse files Browse the repository at this point in the history
* Add first try at NVHPC cpu CI workflow

* Add new cmake files for NVHPC compiler options

* Remove unused code and add VERBOSE build to nvhpc ci workflow

* Add debug step to nvhpc ci

* Remove debug option for nvhpc, appears to be a compiler bug
  • Loading branch information
christopherwharrop-noaa authored Aug 10, 2024
1 parent 3f5c428 commit 19c2e2e
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 17 deletions.
37 changes: 22 additions & 15 deletions .github/workflows/linux_nvhpc.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Linux NVHPC
# triggered events (push, pull_request) for the develop branch
# triggered events (push, pull_request) for the master branch
on:
push:
branches: [ develop ]
branches: [ master ]
pull_request:
branches: [ develop ]
branches: [ master ]
workflow_dispatch:

defaults:
Expand All @@ -19,10 +19,6 @@ jobs:
# Run on ubuntu-latest
runs-on: ubuntu-latest

env:
NVIDIA_HPC_SDK_URL1: https://developer.download.nvidia.com/hpc-sdk/21.9/nvhpc-21-9_21.9_amd64.deb
NVIDIA_HPC_SDK_URL2: https://developer.download.nvidia.com/hpc-sdk/21.9/nvhpc-2021_21.9_amd64.deb

steps:

# Install Lmod
Expand All @@ -37,8 +33,10 @@ jobs:
# Install NVIDIA HPC SDK
- name: Install NVIDIA HPC SDK
run: |
wget "$NVIDIA_HPC_SDK_URL1" "$NVIDIA_HPC_SDK_URL2"
sudo apt-get install ./nvhpc-21-9_21.9_amd64.deb ./nvhpc-2021_21.9_amd64.deb
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
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
sudo apt-get update -y
sudo apt-get install -y nvhpc-24-7
# Check location of installed NVHPC compilers
- name: Check compiler install
Expand All @@ -63,9 +61,9 @@ jobs:
rm -rf build
mkdir build
cd build
export OMP_NUM_THREADS=4
cmake -DCMAKE_BUILD_TYPE=debug ..
make
#export OMP_NUM_THREADS=4
cmake -DCMAKE_BUILD_TYPE=debug -DENABLE_GPU=off ..
make VERBOSE=1
ctest --output-on-failure
# Test release mode
Expand All @@ -78,7 +76,16 @@ jobs:
rm -rf build
mkdir build
cd build
export OMP_NUM_THREADS=4
cmake -DCMAKE_BUILD_TYPE=release ..
make
#export OMP_NUM_THREADS=4
cmake -DCMAKE_BUILD_TYPE=release -DENABLE_GPU=off ..
make VERBOSE=1
ctest --output-on-failure
# Debug session for failures
-
name: Debug session
if: ${{ failure() }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60
with:
limit-access-to-actor: true
16 changes: 16 additions & 0 deletions ref/cmake/compiler_flags_NVHPC_C.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
####################################################################
# COMMON FLAGS
####################################################################
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")

####################################################################
# RELEASE FLAGS
####################################################################

set( CMAKE_C_FLAGS_RELEASE "-O3 -mp" )

####################################################################
# DEBUG FLAGS
####################################################################

set( CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0" )
23 changes: 23 additions & 0 deletions ref/cmake/compiler_flags_NVHPC_Fortran.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
####################################################################
# COMMON FLAGS
####################################################################
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -g -traceback -Mnofma")

####################################################################
# RELEASE FLAGS
####################################################################

# Must turn off SIMD vectorization to get same results as for debug
set( CMAKE_Fortran_FLAGS_RELEASE "-fast -mp -Mnovect" )

####################################################################
# DEBUG FLAGS
####################################################################

set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -Mbounds -Mchkptr -Mchkstk" )

####################################################################
# FLAGS FOR GPU
####################################################################

set( Fortran_GPU_FLAGS "" )
4 changes: 4 additions & 0 deletions ref/cmake/gf_compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ elseif (CMAKE_Fortran_COMPILER_ID MATCHES "^Intel")
include("compiler_flags_Intel_Fortran")
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "PGI")
include("compiler_flags_PGI_Fortran")
elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC")
include("compiler_flags_NVHPC_Fortran")
endif()

# Set flags depending on which compiler iis used
Expand All @@ -19,4 +21,6 @@ elseif (CMAKE_C_COMPILER_ID MATCHES "^Intel")
include("compiler_flags_Intel_C")
elseif (CMAKE_C_COMPILER_ID STREQUAL "PGI")
include("compiler_flags_PGI_C")
elseif (CMAKE_C_COMPILER_ID STREQUAL "NVHPC")
include("compiler_flags_NVHPC_C")
endif()
8 changes: 6 additions & 2 deletions ref/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ add_test(NAME cpu_kernel
COMMAND bash -c "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS} ../src/gf_kernel_cpu > test_output/gf_kernel_cpu.log")
add_test(NAME compare_cpu_kernel
COMMAND ${COMPARE_SH} test_output/gf_kernel_cpu.log test_output/output.test)
if ( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
set_property(TEST cpu_kernel PROPERTY ENVIRONMENT "FORTRANOPT=no_minus_zero")
endif()

# Tests when GPU is enabled
if ( ENABLE_GPU )
Expand All @@ -30,7 +33,8 @@ if ( ENABLE_GPU )
COMMAND bash -c "${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 1 ${MPIEXEC_PREFLAGS} ../src/gf_kernel_gpu > test_output/gf_kernel_gpu.log")
add_test(NAME compare_gpu_kernel
COMMAND ${COMPARE_SH} test_output/gf_kernel_gpu.log test_output/output.test)
if ( CMAKE_Fortran_COMPILER_ID STREQUAL "NVHPC" )
set_property(TEST gpu_kernel PROPERTY ENVIRONMENT "FORTRANOPT=no_minus_zero")
endif()

endif()


0 comments on commit 19c2e2e

Please sign in to comment.