Skip to content

Commit

Permalink
ECLand: Add initial GNU-based CI setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mlange05 committed Feb 4, 2025
1 parent 7581922 commit 453d77b
Show file tree
Hide file tree
Showing 2 changed files with 296 additions and 0 deletions.
168 changes: 168 additions & 0 deletions .github/tools/install-mpi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
#!/bin/bash


set +x
set -e -o pipefail

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export PATH=$SCRIPTDIR:$PATH

# Some defaults for the arguments
PREFIX=$(pwd)/${MPI}
mpi_override=false
MPI=openmpi

while [ $# != 0 ]; do
case "$1" in
"--prefix")
PREFIX="$2"; shift
;;
"--override")
mpi_override=true;
;;
"--version")
mpi_version="$2"; shift
;;
"--mpi")
MPI="$2"; shift
;;
*)
echo "Unrecognized argument '$1'"
exit 1
;;
esac
shift
done

os=$(uname)
OMPIVER=4.1.1
MPICHVER=3.4.2

if [ ! -z ${mpi_version+x} ]; then
if [[ "${MPI}" =~ [Oo][Pp][Ee][Nn]\-?[Mm][Pp][Ii] ]]; then
OMPIVER=${mpi_version}
fi
if [[ "${MPI}" =~ [Mm][Pp][Ii][Cc][Hh] ]]; then
MPICHVER=${mpi_version}
fi
fi


mkdir -p ${PREFIX}
touch ${PREFIX}/env.sh

MPI_INSTALLED=false

case "$os" in
Darwin)
case "$MPI" in
mpich)
brew ls --versions mpich || brew install mpich
;;
openmpi)
brew ls --versions openmpi || brew install openmpi
echo "localhost slots=72" >> $(brew --prefix)/etc/openmpi-default-hostfile
echo "localhost slots=72" >> $(brew --prefix)/etc/prte-default-hostfile

# workaround for open-mpi/omp#7516
echo "setting the mca gds to hash..."
echo "gds = hash" >> $(brew --prefix)/etc/pmix-mca-params.conf

# workaround for open-mpi/ompi#5798
echo "setting the mca btl_vader_backing_directory to /tmp..."
echo "btl_vader_backing_directory = /tmp" >> $(brew --prefix)/etc/openmpi-mca-params.conf
;;
*)
echo "Unknown MPI implementation: $MPI"
exit 1
;;
esac
;;

Linux)
if [ -n "${MPI_HOME}" ]; then
echo "MPI is already installed at MPI_HOME=${MPI_HOME}."
echo "Not taking any action."
exit 0
fi
if [ -n "${I_MPI_ROOT}" ]; then
echo "MPI is already installed at I_MPI_ROOT=${I_MPI_ROOT}."
echo "Not taking any action."
exit 0
fi
case "$MPI" in
mpich)
if [ -f ${PREFIX}/include/mpi.h ]; then
echo "${PREFIX}/include/mpi.h found"
fi
if [ -f ${PREFIX}/lib/libmpich.so ]; then
echo "${PREFIX}/lib/libmpich.so found -- nothing to build."
else
echo "Downloading mpich source..."
wget http://www.mpich.org/static/downloads/${MPICHVER}/mpich-${MPICHVER}.tar.gz
tar xfz mpich-${MPICHVER}.tar.gz
rm mpich-${MPICHVER}.tar.gz
echo "Configuring and building mpich..."
cd mpich-${MPICHVER}
unset F90
unset F90FLAGS
${SCRIPTDIR}/reduce-output.sh ./configure \
--prefix=${PREFIX} \
--enable-static=false \
--enable-alloca=true \
--enable-threads=single \
--enable-fortran=yes \
--enable-fast=all \
--enable-g=none \
--enable-timing=none
${SCRIPTDIR}/reduce-output.sh make -j48
${SCRIPTDIR}/reduce-output.sh make install
MPI_INSTALLED=true
cd -
rm -rf mpich-${MPICHVER}
fi
;;
openmpi)
if [ -f ${PREFIX}/include/mpi.h ]; then
echo "openmpi/include/mpi.h found."
fi
if [ -f ${PREFIX}/lib/libmpi.so ] || [ -f ${PREFIX}/lib64/libmpi.so ]; then
echo "libmpi.so found -- nothing to build."
else
echo "Downloading openmpi source..."
wget --no-check-certificate https://www.open-mpi.org/software/ompi/v4.1/downloads/openmpi-$OMPIVER.tar.gz
tar -zxf openmpi-$OMPIVER.tar.gz
rm openmpi-$OMPIVER.tar.gz
echo "Configuring and building openmpi..."
cd openmpi-$OMPIVER
${SCRIPTDIR}/reduce-output.sh ./configure --prefix=${PREFIX}
${SCRIPTDIR}/reduce-output.sh make -j4
${SCRIPTDIR}/reduce-output.sh make install
MPI_INSTALLED=true
echo "localhost slots=72" >> ${PREFIX}/etc/openmpi-default-hostfile
cd -
rm -rf openmpi-$OMPIVER
fi
;;
*)
echo "Unknown MPI implementation: $MPI"
exit 1
;;
esac
;;

*)
echo "Unknown operating system: $os"
exit 1
;;
esac


if ${MPI_INSTALLED} ; then
cat > ${PREFIX}/env.sh << EOF
export MPI_HOME=${PREFIX}
export PATH=\${MPI_HOME}/bin:\${PATH}
EOF
echo "Please source ${PREFIX}/env.sh, containing:"
cat ${PREFIX}/env.sh
fi
128 changes: 128 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
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:
ECLAND_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] # Debug tests takes too long
build_type: [Release]
prec: ['DP', 'SP']
name:
- linux gnu-10
- linux gnu-14
- linux nvhpc-23.5
- 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
python-version: '3.8'
caching: true

- name: linux gnu-14
os: ubuntu-24.04
compiler: gnu-14
compiler_cc: gcc-14
compiler_cxx: g++-14
compiler_fc: gfortran-14
python-version: '3.11'
caching: true

runs-on: ${{ matrix.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- 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
sudo apt-get update
sudo apt-get install libaec-dev
sudo apt-get install ninja-build
pip3 install numpy
printenv
- name: Install MPI
shell: bash -eux {0}
run: |
FCFLAGS=-fPIC CFLAGS=-fPIC FFLAGS=-fPIC ${ECLAND_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: 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: false
force_build: true
cache_suffix: "${{ matrix.build_type }}-${{ env.CACHE_SUFFIX }}"
recreate_cache: ${{ matrix.caching == false }}
dependencies: |
ecmwf/ecbuild
ecmwf/eccodes
dependency_branch: develop
dependency_cmake_options: |
ecmwf/eccodes: "-G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DENABLE_MEMFS=ON -DENABLE_JPG=OFF -DENABLE_PNG=OFF"
cmake_options: "-G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ${{ matrix.cmake_options }} -DENABLE_MPI=ON -DENABLE_SINGLE_PRECISION=${{ matrix.prec == 'SP' }}"
ctest_options: "${{ matrix.ctest_options }}"

- name: Verify tools
run: |
export PATH=${{ steps.build-test.outputs.bin_path }}:$PATH
echo "+ ecland --info"
ecland --info
# - name: Codecov Upload
# if: steps.build-test.outputs.coverage_file
# uses: codecov/codecov-action@v2
# with:
# files: ${{ steps.build-test.outputs.coverage_file }}

0 comments on commit 453d77b

Please sign in to comment.