Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NVIDIA Compiler Support #53

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/actions/test-cc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ runs:
- name: Check compiler version
shell: bash
run: |
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]]); then
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]] && [[ "${{ inputs.compiler }}" != "nvidia-hpc" ]]); then
# only last line of output captured by command substitution, write to temp file instead
${{ env.CC }} //QV > "$RUNNER_TEMP/${{ env.CC }}.ver" 2>&1
ccv=$(cat "$RUNNER_TEMP/${{ env.CC }}.ver" | head -n 1)
ccv=${ccv#*Version }
ccv=${ccv%% Build*}
else
elif ([ "$RUNNER_OS" == "Linux" ] && [[ "${{ inputs.compiler }}" == "nvidia-hpc" ]]); then
# Get the compiler version and extract the version number
ccv=$(${{ env.CC }} --version 2>&1 | awk '/nvc/ {print $2}' | cut -d'-' -f1)
elif ([[ "${{ inputs.compiler }}" != "nvidia-hpc" ]]); then
ccv=$(${{ env.CC }} --version | head -n 1)
ccv=$(echo "$ccv" | grep -woE '[0123456789.]+' | head -n 1)
fi
Expand Down
7 changes: 5 additions & 2 deletions .github/actions/test-cxx/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ runs:
- name: Check compiler version
shell: bash
run: |
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ matrix.toolchain.compiler }}" =~ "intel" ]]); then
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ matrix.toolchain.compiler }}" =~ "intel" ]] && [[ "${{ matrix.toolchain.compiler }}" != "nvidia-hpc" ]]); then
# only last line of output captured by command substitution, write to temp file instead
${{ env.CXX }} //QV > "$RUNNER_TEMP/${{ env.CXX }}.ver" 2>&1
cxxv=$(cat "$RUNNER_TEMP/${{ env.CXX }}.ver" | head -n 1)
cxxv=${cxxv#*Version }
cxxv=${cxxv%% Build*}
else
elif ([ "$RUNNER_OS" == "Linux" ] && [[ "${{ matrix.toolchain.compiler}}" == "nvidia-hpc" ]]); then
# Get the compiler version and extract the version number
cxxv=$(${{ env.CXX }} --version 2>&1 | awk '/nvc++/ {print $2}' | cut -d'-' -f1)
elif ([[ "${{ matrix.toolchain.compiler}}" != "nvidia-hpc" ]]); then
cxxv=$(${{ env.CXX }} --version | head -n 1)
cxxv=$(echo "$cxxv" | grep -woE '[0123456789.]+' | head -n 1)
fi
Expand Down
7 changes: 5 additions & 2 deletions .github/actions/test-fc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,16 @@ runs:
- name: Check compiler version
shell: bash
run: |
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]]); then
if ([ "$RUNNER_OS" == "Windows" ] && [[ "${{ inputs.compiler }}" =~ "intel" ]] && [[ "${{ inputs.compiler }}" != "nvidia-hpc" ]]); then
# only last line of output captured by command substitution, write to temp file instead
${{ env.FC }} //QV > "$RUNNER_TEMP/${{ env.FC }}.ver" 2>&1
fcv=$(cat "$RUNNER_TEMP/${{ env.FC }}.ver" | head -n 1)
fcv=${fcv#*Version }
fcv=${fcv%% Build*}
else
elif ([ "$RUNNER_OS" == "Linux" ] && [[ "${{ inputs.compiler }}" == "nvidia-hpc" ]]); then
# Get the compiler version and extract the version number
fcv=$(${{ env.FC }} --version 2>&1 | awk '/nvfortran/ {print $2}' | cut -d'-' -f1)
elif ([[ "${{ inputs.compiler }}" != "nvidia-hpc" ]]); then
fcv=$(${{ env.FC }} --version | head -n 1)
fcv=$(echo "$fcv" | grep -woE '[0123456789.]+' | head -n 1)
fi
Expand Down
63 changes: 56 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,28 @@ jobs:
- {compiler: gcc, version: 13}
- {compiler: intel, version: '2023.2'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: nvidia-hpc, version: '23.11'}
exclude:
# ifx not available for mac
- os: macos-13
toolchain: {compiler: intel}
- os: macos-12
toolchain: {compiler: intel}
- os: macos-11
toolchain: {compiler: intel}
# ifx not available for mac
- os: macos-13
toolchain: {compiler: intel}
- os: macos-12
toolchain: {compiler: intel}
- os: macos-11
toolchain: {compiler: intel}
# nvidia-hpc not available for mac
- os: macos-13
toolchain: {compiler: nvidia-hpc}
- os: macos-12
toolchain: {compiler: nvidia-hpc}
- os: macos-11
toolchain: {compiler: nvidia-hpc}
# nvidia-hpc not available for windows
- os: windows-2022
toolchain: {compiler: nvidia-hpc}
- os: windows-2019
toolchain: {compiler: nvidia-hpc}

steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -123,6 +137,29 @@ jobs:
- {compiler: intel-classic, version: '2021.2'}
- {compiler: intel-classic, version: '2021.1.2'}
- {compiler: intel-classic, version: '2021.1'}
- {compiler: nvidia-hpc, version: '23.11'}
wpbonelli marked this conversation as resolved.
Show resolved Hide resolved
- {compiler: nvidia-hpc, version: '23.9'}
- {compiler: nvidia-hpc, version: '23.7'}
- {compiler: nvidia-hpc, version: '23.5'}
- {compiler: nvidia-hpc, version: '23.3'}
- {compiler: nvidia-hpc, version: '23.1'}
- {compiler: nvidia-hpc, version: '22.11'}
- {compiler: nvidia-hpc, version: '22.9'}
- {compiler: nvidia-hpc, version: '22.7'}
- {compiler: nvidia-hpc, version: '22.5'}
- {compiler: nvidia-hpc, version: '22.3'}
- {compiler: nvidia-hpc, version: '22.2'}
- {compiler: nvidia-hpc, version: '22.1'}
- {compiler: nvidia-hpc, version: '21.11'}
- {compiler: nvidia-hpc, version: '21.9'}
- {compiler: nvidia-hpc, version: '21.7'}
- {compiler: nvidia-hpc, version: '21.5'}
- {compiler: nvidia-hpc, version: '21.3'}
- {compiler: nvidia-hpc, version: '21.2'}
- {compiler: nvidia-hpc, version: '21.1'}
- {compiler: nvidia-hpc, version: '20.11'}
- {compiler: nvidia-hpc, version: '20.9'}
- {compiler: nvidia-hpc, version: '20.7'}
exclude:
# ifx not available for mac
- os: macos-13
Expand All @@ -131,6 +168,18 @@ jobs:
toolchain: {compiler: intel}
- os: macos-11
toolchain: {compiler: intel}
# nvidia-hpc not available for mac
- os: macos-13
toolchain: {compiler: nvidia-hpc}
- os: macos-12
toolchain: {compiler: nvidia-hpc}
- os: macos-11
toolchain: {compiler: nvidia-hpc}
# nvidia-hpc not available for windows
- os: windows-2022
toolchain: {compiler: nvidia-hpc}
- os: windows-2019
toolchain: {compiler: nvidia-hpc}
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ jobs:
- {compiler: gcc, version: 13}
- {compiler: intel, version: '2023.2'}
- {compiler: intel-classic, version: '2021.10'}
- {compiler: nvidia-hpc, version: '23.11'}
include:
- os: ubuntu-latest
toolchain: {compiler: gcc, version: 12}
exclude:
- os: macos-latest
toolchain: {compiler: intel, version: '2023.2'}
- os: macos-latest
wpbonelli marked this conversation as resolved.
Show resolved Hide resolved
toolchain: {compiler: nvidia-hpc, version: '23.11'}
- os: windows-latest
toolchain: {compiler: nvidia-hpc, version: '23.11'}

steps:
- uses: fortran-lang/setup-fortran@v1
Expand All @@ -61,6 +66,7 @@ jobs:
- *gcc* (for `gfortran`)
- *intel* (for `ifx`)
- *intel-classic* (for `ifort`)
- *nvidia-hpc* (for `nvfortran`)
- *version*: Version of the compiler toolchain. See [runner compatibility](#runner-compatibility) charts below.


Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ runs:
version=${VERSION:-2023.2.0}
install_intel $platform false
;;
nvidia-hpc)
version=${VERSION:-23.11}
install_nvidiahpc $platform
;;
*)
exit 1
;;
Expand Down
97 changes: 97 additions & 0 deletions setup-fortran.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ require_fetch()
fi
}

# Function to install environment-modules via apt
# https://github.com/cea-hpc/modules
install_environment_modules_apt() {
echo "Installing environment-modules package..."
sudo apt-get install -y environment-modules
echo "Environment-modules installed."
echo "Sourcing modules.sh script to set up environment modules..."
source /etc/profile.d/modules.sh
echo "Environment modules set up completed."
}

install_gcc_brew()
{
# check if gcc preinstalled via brew
Expand Down Expand Up @@ -504,3 +515,89 @@ install_intel()
;;
esac
}

export_nvidiahpc_vars()
{
local version=$1

# to convert version format from X.Y to X-Y
local cversion=$(echo "$version" | tr '.' '-')

cat >> $GITHUB_ENV <<EOF
NVARCH=`uname -s`_`uname -m`;
NVCOMPILERS=/opt/nvidia/hpc_sdk;
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$cversion/compilers/man;
PATH=$NVCOMPILERS/$NVARCH/$cversion/compilers/bin:$PATH;
PATH=$NVCOMPILERS/$NVARCH/$cversion/comm_libs/mpi/bin:$PATH
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/$cversion/comm_libs/mpi/man
EOF
for path in ${PATH//:/ }; do
echo $path >> $GITHUB_PATH
done
}

install_nvidiahpc_apt()
{
local version=$1

# install environment-modules
install_environment_modules_apt

# to convert version format from X.Y to X-Y
local cversion=$(echo "$version" | tr '.' '-')

# install NVIDIA HPC SDK
echo "Installing NVIDIA HPC SDK $version..."
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-$cversion
echo "NVIDIA HPC SDK $version installed."

# load NVIDIA HPC SDK module
echo "Loading NVIDIA HPC SDK $version module..."
NVCOMPILERS=/opt/nvidia/hpc_sdk; export NVCOMPILERS
export MODULEPATH=$NVCOMPILERS/modulefiles:$MODULEPATH
module load nvhpc
echo "NVIDIA HPC SDK $version module loaded."

# set environment variables
echo "Setting environment variables..."
export_nvidiahpc_vars $version

# set environment variables
export FC="nvfortran"
export CC="nvc"
export CXX="nvc++"
echo "Environment variables set."
}

install_nvidiahpc()
{
local platform=$1
case $platform in
linux*)
install_nvidiahpc_apt $version
wpbonelli marked this conversation as resolved.
Show resolved Hide resolved
;;
darwin*)
echo "NVIDIA HPC SDK is not supported on macOS."
exit 1
;;
mingw*)
echo "NVIDIA HPC SDK is not supported on Windows."
exit 1
;;
msys*)
echo "NVIDIA HPC SDK is not supported on MSYS."
exit 1
;;
cygwin*)
echo "NVIDIA HPC SDK is not supported on Cygwin."
exit 1
;;
*)
echo "Unsupported platform: $platform"
exit 1
;;
esac
}
Loading