Skip to content

Add build-hpc workflow #780

Add build-hpc workflow

Add build-hpc workflow #780

Workflow file for this run

name: build
# Controls when the action will run
on:
# Trigger the workflow on all pushes, except on tag creation
push:
branches:
- '**'
tags-ignore:
- '**'
# Trigger the workflow on all pull requests
pull_request: ~
# Allow workflow to be dispatched on demand
workflow_dispatch: ~
env:
ECTRANS_TOOLS: ${{ github.workspace }}/.github/tools
CTEST_PARALLEL_LEVEL: 1
CACHE_SUFFIX: v1 # Increase to force new cache to be created
jobs:
ci:
name: ci
strategy:
fail-fast: false # false: try to complete all jobs
matrix:
build_type: [Release,Debug]
name:
- linux gnu-10
- linux clang-12
- linux nvhpc-21.9
- linux intel-classic
- macos
include:
- name: linux gnu-10
os: ubuntu-20.04
compiler: gnu-10
compiler_cc: gcc-10
compiler_cxx: g++-10
compiler_fc: gfortran-10
ctest_options: -E memory
caching: true
- name: linux clang-12
os: ubuntu-20.04
compiler: clang-12
compiler_cc: clang-12
compiler_cxx: clang++-12
compiler_fc: gfortran-10
ctest_options: -E memory
caching: true
- name: linux clang-12
build_type: Release
os: ubuntu-20.04
compiler: clang-12
compiler_cc: clang-12
compiler_cxx: clang++-12
compiler_fc: gfortran-10
ctest_options: -E memory
caching: true
- name: linux nvhpc-21.9
os: ubuntu-20.04
compiler: nvhpc-21.9
compiler_cc: nvc
compiler_cxx: nvc++
compiler_fc: nvfortran
cmake_options: -DCMAKE_CXX_FLAGS=--diag_suppress177
ctest_options: -E memory
caching: false
- name : linux intel-classic
os: ubuntu-20.04
compiler: intel-classic
compiler_cc: icc
compiler_cxx: icpc
compiler_fc: ifort
caching: true
- name: macos
# Xcode compiler requires empty environment variables, so we pass null (~) here
os: macos-13
compiler: clang-14
compiler_cc: ~
compiler_cxx: ~
compiler_fc: gfortran-13
caching: true
runs-on: ${{ matrix.os }}
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Environment
run: |
echo "DEPS_DIR=${{ runner.temp }}/deps" >> $GITHUB_ENV
echo "CC=${{ matrix.compiler_cc }}" >> $GITHUB_ENV
echo "CXX=${{ matrix.compiler_cxx }}" >> $GITHUB_ENV
echo "FC=${{ matrix.compiler_fc }}" >> $GITHUB_ENV
if [[ "${{ matrix.os }}" =~ macos ]]; then
brew install ninja
else
sudo apt-get update
sudo apt-get install ninja-build
fi
printenv
- name: Cache Dependencies
# There seems to be a problem with cached NVHPC dependencies, leading to SIGILL perhaps due to slightly different architectures
if: matrix.caching
id: deps-cache
uses: pat-s/[email protected]
with:
path: ${{ env.DEPS_DIR }}
key: deps-${{ matrix.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ env.CACHE_SUFFIX }}
# Free up disk space for nvhpc
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
if: contains( matrix.compiler, 'nvhpc' )
continue-on-error: true
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Install NVHPC compiler
if: contains( matrix.compiler, 'nvhpc' )
shell: bash -eux {0}
run: |
${ECTRANS_TOOLS}/install-nvhpc.sh --prefix /opt/nvhpc
source /opt/nvhpc/env.sh
echo "${NVHPC_DIR}/compilers/bin" >> $GITHUB_PATH
[ -z ${MPI_HOME+x} ] || echo "MPI_HOME=${MPI_HOME}" >> $GITHUB_ENV
- name: Install Intel oneAPI compiler
if: contains( matrix.compiler, 'intel' )
run: |
${ECTRANS_TOOLS}/install-intel-oneapi.sh
source /opt/intel/oneapi/setvars.sh
printenv >> $GITHUB_ENV
echo "CACHE_SUFFIX=$CC-$($CC -dumpversion)" >> $GITHUB_ENV
- name: Install MPI
shell: bash -eux {0}
run: |
FCFLAGS=-fPIC CFLAGS=-fPIC FFLAGS=-fPIC ${ECTRANS_TOOLS}/install-mpi.sh --mpi openmpi --prefix ${DEPS_DIR}/openmpi
[ -f ${DEPS_DIR}/openmpi/env.sh ] && source ${DEPS_DIR}/openmpi/env.sh
[ -z ${MPI_HOME+x} ] || echo "MPI_HOME=${MPI_HOME}" >> $GITHUB_ENV
- name: Install FFTW
shell: bash -eux {0}
run: |
${ECTRANS_TOOLS}/install-fftw.sh --version 3.3.10 --with-single --prefix ${DEPS_DIR}/fftw
echo "FFTW_ROOT=${DEPS_DIR}/fftw" >> $GITHUB_ENV
- name: Set Build & Test Environment
run: |
# Add mpirun to path for testing
[ -z ${MPI_HOME+x} ] || echo "${MPI_HOME}/bin" >> $GITHUB_PATH
- name: Build & Test
id: build-test
uses: ecmwf-actions/build-package@v2
with:
self_coverage: true
force_build: true
cache_suffix: "${{ matrix.build_type }}-${{ env.CACHE_SUFFIX }}"
recreate_cache: ${{ matrix.caching == false }}
dependencies: |
ecmwf/ecbuild
ecmwf-ifs/fiat
dependency_branch: develop
dependency_cmake_options: |
ecmwf-ifs/fiat: "-G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DENABLE_TESTS=OFF -DENABLE_MPI=ON"
cmake_options: "-G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.cmake_options }} -DENABLE_MPI=ON -DENABLE_FFTW=ON"
ctest_options: "${{ matrix.ctest_options }}"
- name: Verify tools
run: |
export PATH=${{ steps.build-test.outputs.bin_path }}:$PATH
echo "+ ectrans --info"
ectrans --info
# - name: Codecov Upload
# if: steps.build-test.outputs.coverage_file
# uses: codecov/codecov-action@v2
# with:
# files: ${{ steps.build-test.outputs.coverage_file }}
ci-hpc:
name: ci-hpc
runs-on: [self-hosted, linux, hpc]
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: ecmwf-actions/reusable-workflows/ci-hpc-generic@v2
with:
site: ac-batch
troika_user: ${{ secrets.HPC_CI_SSH_USER }}
sbatch_options: |
#SBATCH --time=00:20:00
#SBATCH --nodes=1
#SBATCH --ntasks=2
#SBATCH --cpus-per-task=32
#SBATCH --gpus-per-task=1
#SBATCH --mem=200G
#SBATCH --qos=dg
template_data: |
modules:
- cmake
- ninja
- ecbuild
- prgenv/nvidia
- hpcx-openmpi
- fftw
cmake_options:
- -DENABLE_MPI=ON
- -DENABLE_ACC=ON
- -DENABLE_GPU=ON
template: |
{% for module in modules %}
module load {{module}}
{% endfor %}
git clone -b develop ${{ github.server_url}}/ecmwf-ifs/fiat
cmake -G Ninja -S fiat -B build-fiat -DENABLE_MPI=ON
cmake --build build-fiat
cmake --install build-fiat --prefix install-fiat
mkdir ectrans
cd ectrans
git init
git remote add origin ${{ github.server_url }}/ecmwf-ifs/ectrans
git fetch origin ${{ github.sha }}
git reset --hard FETCH_HEAD
cd ..
cmake -G Ninja -S ectrans -B build-ectrans \
-Dfiat_DIR=$PWD/install-fiat/lib64/cmake/fiat \
{{ cmake_options|join(' ') }}
cmake --build build-ectrans
ctest --test-dir build-ectrans