Skip to content

Commit

Permalink
github action: build openmpi from source
Browse files Browse the repository at this point in the history
  • Loading branch information
wkliao committed Feb 9, 2024
1 parent 72cd7a6 commit 37a8a21
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 20 deletions.
59 changes: 50 additions & 9 deletions .github/workflows/mac_openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ on:
- 'docs/*'
- 'test/test_installed/*'

env:
OPENMPI_VERSION: 5.0.2

jobs:
build:
runs-on: macos-latest
Expand All @@ -30,13 +33,52 @@ jobs:
- uses: actions/checkout@v3
- name: Set up dependencies
run: |
brew install gcc automake autoconf libtool m4 open-mpi zlib
echo "---- location of OpenMPI C compiler ----"
which mpicc
brew install gcc
which gcc
gcc --version
ls -l /usr/local/bin/gfortran*
version=12
ln -fs /usr/local/bin/gfortran-${version} /usr/local/bin/gfortran
ln -fs /usr/local/bin/gcc-${version} /usr/local/bin/gcc
ln -fs /usr/local/bin/g++-${version} /usr/local/bin/g++
# link lib dir for previous GCC versions to avoid missing .dylib issues
for (( i=12; i>4; i-- ))
do
gcc_lib_path="/usr/local/opt/gcc/lib/gcc/$i"
if [ -d $gcc_lib_path ]; then
echo "found $gcc_lib_path"
for (( j=$i; j>4; j-- ))
do
ln -fs /usr/local/opt/gcc/lib/gcc/$i /usr/local/opt/gcc/lib/gcc/$j
done
break
fi
done
which gfortran
gfortran --version
brew install automake autoconf libtool m4
- name: Build OPENMPI
run: |
cd ${GITHUB_WORKSPACE}
rm -rf OPENMPI ; mkdir OPENMPI ; cd OPENMPI
VER_MAJOR=${OPENMPI_VERSION%.*}
wget -q https://download.open-mpi.org/release/open-mpi/v${VER_MAJOR}/openmpi-${OPENMPI_VERSION}.tar.gz
gzip -dc openmpi-${OPENMPI_VERSION}.tar.gz | tar -xf -
cd openmpi-${OPENMPI_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/OPENMPI \
--silent \
--enable-romio \
--with-file-system=ufs \
--with-device=ch3:sock \
CC=gcc \
FC=gfortran \
FFLAGS=-fallow-argument-mismatch \
FCFLAGS=-fallow-argument-mismatch
make -s LIBTOOLFLAGS=--silent V=1 -j 8 install > qout 2>&1
make -s -j 8 distclean >> qout 2>&1
- name: Build PnetCDF
run: |
cd ${GITHUB_WORKSPACE}
export TMPDIR=/tmp
autoreconf -i
mkdir -p pnetcdf_output
./configure --enable-option-checking=fatal \
Expand All @@ -47,6 +89,7 @@ jobs:
--enable-shared \
--enable-thread-safe \
--with-pthread \
--with-mpi=${GITHUB_WORKSPACE}/OPENMPI \
TESTMPIRUN="mpiexec --oversubscribe -n NP" \
TESTOUTDIR=${GITHUB_WORKSPACE}/pnetcdf_output
make -j 8 tests
Expand All @@ -57,7 +100,6 @@ jobs:
- name: make check
run: |
cd ${GITHUB_WORKSPACE}
export TMPDIR=/tmp
make check
- name: Print test log files
if: ${{ always() }}
Expand All @@ -74,17 +116,16 @@ jobs:
- name: make ptests
run: |
cd ${GITHUB_WORKSPACE}
export TMPDIR=/tmp
make ptests
- name: make distcheck
run: |
cd ${GITHUB_WORKSPACE}
export TMPDIR=/tmp
make -j 8 distcheck DISTCHECK_CONFIGURE_FLAGS="--silent"
make -j 8 distcheck DISTCHECK_CONFIGURE_FLAGS="--silent --with-mpi=${GITHUB_WORKSPACE}/OPENMPI"
- name: Cleanup
if: ${{ always() }}
run: |
cd ${GITHUB_WORKSPACE}
make -s distclean
rm -rf pnetcdf_output
rm -rf ${GITHUB_WORKSPACE}/pnetcdf_output
rm -rf ${GITHUB_WORKSPACE}/OPENMPI
54 changes: 43 additions & 11 deletions .github/workflows/ubuntu_openmpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ on:
- 'docs/*'
- 'test/test_installed/*'

env:
OPENMPI_VERSION: 5.0.2

jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -28,27 +31,55 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install automake autoconf libtool libtool-bin m4
# zlib
sudo apt-get install zlib1g-dev
# mpi
sudo apt-get install openmpi-bin openmpi-common libopenmpi-dev libgtk2.0-dev
echo "---- location of OpenMPI C compiler ----"
which mpicc
# install gfortran
version=12
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y gcc-${version} gfortran-${version}
sudo update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-${version} 100 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-${version} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${version}
echo "---- gcc/gfortran version ------------------------------"
which gcc
which gfortran
gcc --version
gfortran --version
- name: Build OPENMPI
run: |
cd ${GITHUB_WORKSPACE}
echo "Install OPENMPI ${OPENMPI_VERSION} in ${GITHUB_WORKSPACE}/OPENMPI"
rm -rf OPENMPI ; mkdir OPENMPI ; cd OPENMPI
VER_MAJOR=${OPENMPI_VERSION%.*}
wget -q https://download.open-mpi.org/release/open-mpi/v${VER_MAJOR}/openmpi-${OPENMPI_VERSION}.tar.gz
gzip -dc openmpi-${OPENMPI_VERSION}.tar.gz | tar -xf -
cd openmpi-${OPENMPI_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/OPENMPI \
--silent \
--with-io-romio-flags="--with-file-system=ufs" \
CC=gcc \
FC=gfortran \
FFLAGS=-fallow-argument-mismatch \
FCFLAGS=-fallow-argument-mismatch
make -s LIBTOOLFLAGS=--silent V=1 -j 4 install > qout 2>&1
make -s -j 4 distclean >> qout 2>&1
- name: Build PnetCDF
run: |
cd ${GITHUB_WORKSPACE}
autoreconf -i
mkdir -p /dev/shm/pnetcdf_output
./configure --enable-option-checking=fatal \
mkdir -p pnetcdf_output
./configure --prefix=${GITHUB_WORKSPACE}/PnetCDF \
--enable-option-checking=fatal \
--enable-profiling \
pnc_ac_debug=yes \
--enable-burst_buffering \
--enable-subfiling \
--enable-shared \
--enable-thread-safe \
--with-pthread \
--with-mpi=${GITHUB_WORKSPACE}/OPENMPI \
TESTMPIRUN="mpiexec --oversubscribe -n NP" \
TESTOUTDIR=/dev/shm/pnetcdf_output
TESTOUTDIR=${GITHUB_WORKSPACE}/pnetcdf_output
make -j 8 tests
- name: Print config.log
if: ${{ always() }}
Expand Down Expand Up @@ -77,11 +108,12 @@ jobs:
- name: make distcheck
run: |
cd ${GITHUB_WORKSPACE}
make -j 8 distcheck DISTCHECK_CONFIGURE_FLAGS="--silent TESTOUTDIR=/dev/shm/pnetcdf_output"
make -j 8 distcheck DISTCHECK_CONFIGURE_FLAGS="--silent --with-mpi=${GITHUB_WORKSPACE}/OPENMPI"
- name: Cleanup
if: ${{ always() }}
run: |
cd ${GITHUB_WORKSPACE}
make -s distclean
rm -rf /dev/shm/pnetcdf_output
rm -rf ${GITHUB_WORKSPACE}/pnetcdf_output
rm -rf ${GITHUB_WORKSPACE}/OPENMPI

0 comments on commit 37a8a21

Please sign in to comment.