Skip to content

Commit

Permalink
Adding CI scripts (#45)
Browse files Browse the repository at this point in the history
* Adding scripts for github actions CI
* Disabling CI tests for oneapi and rocm
  • Loading branch information
G-Ragghianti authored Aug 29, 2024
1 parent a6236b0 commit be7be23
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/build-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash -e

STAGE=$1
BACKEND=$2

source $(dirname $0)/init.sh

source /apps/spacks/current/github_env/share/spack/setup-env.sh
spack env activate heffte

spack load cmake
spack load openmpi

ARGS="-DCMAKE_INSTALL_PREFIX=install"
if [ "$BACKEND" = "MKL" ]; then
ARGS+=" -DHeffte_ENABLE_MKL=ON"
spack load intel-oneapi-mkl
[ -z "$MKLROOT" ] && echo "Error loading MKL!" && exit 1
elif [ "$BACKEND" = "FFTW" ]; then
ARGS+=" -DHeffte_ENABLE_FFTW=ON"
spack load fftw
fftw-wisdom
elif [ "$BACKEND" == "ONEAPI" ]; then
spack load intel-oneapi-mkl
spack load intel-oneapi-compilers
ARGS+=" -DHeffte_ENABLE_ONEAPI=ON"
ARGS+=" -D CMAKE_CXX_COMPILER=icpx -D Heffte_ONEMKL_ROOT=$MKLROOT"
[ -z "$MKLROOT" ] && echo "Error loading OneAPI-MKL!" && exit 1
elif [ "$BACKEND" = "CUDA" ]; then
ARGS+=" -DHeffte_ENABLE_CUDA=ON"
spack load cuda
which nvcc
elif [ "$BACKEND" = "ROCM" ]; then
ARGS+=" -DHeffte_ENABLE_ROCM=ON"
export PATH=/opt/rocm/bin:$PATH
which hipcc
else
# Use the stock backend with AVX instruction set
ARGS+=" -DHeffte_ENABLE_AVX=ON"
fi

[ "$STAGE" = "build" ] && rm -rf build install || true
mkdir -p build
cd build

if [ "$STAGE" = "build" ]; then
cmake $ARGS ..
make -j4
make install
ls -lR install/lib*/libheffte.so
elif [ "$BACKEND" = "ONEAPI" ]; then
echo "Skipping tests due to lack of hardware support."
exit
elif [ "$BACKEND" = "ROCM" ]; then
echo "ROCM backend tests require HIP-aware MPI. Skipping tests."
exit
elif [ "$STAGE" = "test" ]; then
ctest -V
elif [ "$STAGE" = "smoketest" ]; then
make test_install
fi

38 changes: 38 additions & 0 deletions .github/workflows/build-spack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash -e

STAGE=$1
BACKEND=$2

source $(dirname $0)/init.sh

export HOME=`pwd`
git clone https://github.com/spack/spack || true
source spack/share/spack/setup-env.sh
spack config --scope=site add upstreams:i1:install_tree:/apps/spacks/current/opt/spack

VARIANTS=""
if [ "$BACKEND" = "FFTW" ]; then
VARIANTS="+fftw"
elif [ "$BACKEND" = "MKL" ]; then
VARIANTS="+mkl"
# Need to replace deprecated intel-mkl package with oneapi version
sed -i s/intel-mkl/intel-oneapi-mkl/ spack/var/spack/repos/builtin/packages/heffte/package.py
elif [ "$BACKEND" = "CUDA" ]; then
VARIANTS="+cuda cuda_arch=70 ^[email protected]"
elif [ "$BACKEND" = "ROCM" ]; then
VARIANTS="+rocm amdgpu_target=gfx90a ^[email protected]"
fi

SPEC="heffte@develop $VARIANTS ^openmpi"
echo SPEC=$SPEC

if [ "$STAGE" = "build" ]; then
spack compiler find
spack spec $SPEC
spack dev-build $SPEC
elif [ "$STAGE" = "test" ]; then
spack uninstall -a -y heffte || true
spack dev-build -i --test=root $SPEC
else # STAGE = smoketest
spack test run heffte
fi
6 changes: 6 additions & 0 deletions .github/workflows/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#source /etc/profile
set +x
set -e
trap 'echo "# $BASH_COMMAND"' DEBUG
#shopt -s expand_aliases

51 changes: 51 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
heffte:
strategy:
matrix:
maker: [cmake, spack]
backend: [BUILTIN, FFTW, MKL]
device: [cpu_intel]
include:
- maker: cmake
backend: ONEAPI
device: gpu_intel
- maker: cmake
backend: CUDA
device: gpu_nvidia
- maker: spack
backend: CUDA
device: gpu_nvidia
- maker: cmake
backend: ROCM
device: gpu_amd
fail-fast: false
runs-on: ${{matrix.device}}
timeout-minutes: 60
steps:
- uses: actions/checkout@v4
- name: Build
run: .github/workflows/build-${{matrix.maker}}.sh build ${{matrix.backend}}
- name: Test
run: .github/workflows/build-${{matrix.maker}}.sh test ${{matrix.backend}}
- name: SmokeTest
run: .github/workflows/build-${{matrix.maker}}.sh smoketest ${{matrix.backend}}
- uses: actions/upload-artifact@v4
if: always()
with:
name: heffte ${{matrix.maker}} ${{matrix.backend}} ${{matrix.device}}
path: |
*.txt
spack-build-*/CMakeFiles/*.log
build/CMakeFiles/*.log
.spack/test/*/*.txt

0 comments on commit be7be23

Please sign in to comment.