Skip to content

Support OpenMPI #62

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

Merged
merged 6 commits into from
Apr 6, 2025
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
116 changes: 116 additions & 0 deletions .github/workflows/openmpi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: Using OpenMPI
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
- '**/*.txt'
pull_request:
branches:
- main
paths-ignore:
- '**/*.md'
- '**/*.txt'

jobs:
build-linux:
name: Python (${{ matrix.python-version }})
runs-on: ubuntu-latest
timeout-minutes: 60
env:
OPENMPI_VERSION: 5.0.7
OPENMPI_DIR: ${{ github.workspace }}/ompi-install
PNETCDF_VERSION: 1.14.0
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
strategy:
matrix:
python-version: ["3.10"]
steps:

- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install Ubuntu Dependencies
run: |
sudo apt-get update
sudo apt-get install m4

- name: Build OPENMPI
run: |
echo "Install OpenMPI ${OPENMPI_VERSION} in $OPENMPI_DIR"
VER_MAJOR=${OPENMPI_VERSION%.*}
rm -rf OPENMPI ; mkdir OPENMPI ; cd OPENMPI
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=$OPENMPI_DIR \
--with-io-romio-flags="--with-file-system=ufs" \
--with-hwloc=internal \
--with-pmix=internal \
--with-libevent=internal \
--disable-mpi-fortran \
CC=gcc
make -s LIBTOOLFLAGS=--silent V=1 -j 4 install > qout 2>&1
make -s -j 4 distclean >> qout 2>&1

- name: Build PnetCDF-C official release
run: |
echo "Download and build PnetCDF-C release version ${PNETCDF_VERSION}"
wget -q https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
pushd pnetcdf-${PNETCDF_VERSION}
./configure --prefix=$PNETCDF_DIR \
--silent \
--enable-shared \
--enable-debug \
--disable-fortran \
--disable-cxx \
--with-mpi=$OPENMPI_DIR
make -s LIBTOOLFLAGS=--silent V=1 -j 4 install > qout 2>&1
make -s -j 4 distclean >> qout 2>&1
popd

- name: Install python dependencies via pip
run: |
python -m pip install --upgrade pip setuptools wheel
pip install numpy cython cftime pytest twine check-manifest
export MPICC=$OPENMPI_DIR/bin/mpicc
pip install mpi4py
pip install torch torchvision

- name: Install PnetCDF-Python
run: |
export CC=$OPENMPI_DIR/bin/mpicc
pip install --verbose --no-build-isolation -e .

- name: Test PnetCDF-Python
run: |
export PATH=${OPENMPI_DIR}/bin:${PATH}
make ptests TESTMPIRUN="${OPENMPI_DIR}/bin/mpiexec --oversubscribe"

- name: Re-install PnetCDF-Python from source distribution
run: |
pip uninstall -y pnetcdf
make install-clean
export CC=$OPENMPI_DIR/bin/mpicc
python setup.py sdist
pip install --verbose dist/pnetcdf-*.tar.gz

- name: Test PnetCDF-Python
run: |
export PATH=${OPENMPI_DIR}/bin:${PATH}
make ptests TESTMPIRUN="${OPENMPI_DIR}/bin/mpiexec --oversubscribe"

# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
# python setup.py --version
# check-manifest --version
# check-manifest --verbose
# pip wheel . -w dist --no-deps
# twine check dist/*
53 changes: 50 additions & 3 deletions .github/workflows/pnetcdf_c_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
MPICH_VERSION: 4.2.2
MPICH_VERSION: 4.3.0
MPICH_DIR: ${{ github.workspace }}/mpich-install
PNETCDF_VERSION: repo
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
AUTOCONF_VERSION: 2.71
AUTOMAKE_VERSION: 1.17
LIBTOOL_VERSION: 2.5.4
M4_VERSION: 1.4.19

strategy:
matrix:
Expand All @@ -41,6 +45,43 @@ jobs:
sudo apt-get update
sudo apt-get install automake autoconf libtool libtool-bin m4

- name: Build GNU autotools
run: |
export PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/bin:${PATH}"
export LD_LIBRARY_PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/lib:${LD_LIBRARY_PATH}"
cd ${GITHUB_WORKSPACE}
wget -q https://ftp.gnu.org/gnu/m4/m4-${M4_VERSION}.tar.gz
gzip -dc m4-${M4_VERSION}.tar.gz | tar -xf -
cd m4-${M4_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
--silent
make -s -j 8 install > qout 2>&1
make -s -j 8 distclean >> qout 2>&1
cd ${GITHUB_WORKSPACE}
wget -q https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz
gzip -dc autoconf-${AUTOCONF_VERSION}.tar.gz | tar -xf -
cd autoconf-${AUTOCONF_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
--silent
make -s -j 8 install > qout 2>&1
make -s -j 8 distclean >> qout 2>&1
cd ${GITHUB_WORKSPACE}
wget -q https://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.gz
gzip -dc automake-${AUTOMAKE_VERSION}.tar.gz | tar -xf -
cd automake-${AUTOMAKE_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
--silent
make -s -j 8 install > qout 2>&1
make -s -j 8 distclean >> qout 2>&1
cd ${GITHUB_WORKSPACE}
wget -q https://ftp.gnu.org/gnu/libtool/libtool-${LIBTOOL_VERSION}.tar.gz
gzip -dc libtool-${LIBTOOL_VERSION}.tar.gz | tar -xf -
cd libtool-${LIBTOOL_VERSION}
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
--silent
make -s -j 8 install > qout 2>&1
make -s -j 8 distclean >> qout 2>&1

- name: Build MPICH
run: |
echo "Install MPICH ${MPICH_VERSION} in $MPICH_DIR"
Expand All @@ -63,6 +104,12 @@ jobs:
run: |
echo "Build PnetCDF-C from its master branch"
cd ${GITHUB_WORKSPACE}
export PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/bin:${PATH}"
export LD_LIBRARY_PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/lib:${LD_LIBRARY_PATH}"
m4 --version
autoconf --version
automake --version
libtool --version
git clone -q https://github.com/Parallel-NetCDF/PnetCDF.git
pushd PnetCDF
autoreconf -i
Expand Down Expand Up @@ -93,7 +140,7 @@ jobs:
- name: Test PnetCDF-Python
run: |
export PATH=${MPICH_DIR}/bin:${PATH}
make ptests
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"

- name: Re-install PnetCDF-Python from source distribution
run: |
Expand All @@ -106,7 +153,7 @@ jobs:
- name: Test PnetCDF-Python
run: |
export PATH=${MPICH_DIR}/bin:${PATH}
make ptests
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"
# - name: Tarball
# run: |
# export PATH=${NETCDF_DIR}/bin:${PATH}
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/pnetcdf_c_official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 60
env:
MPICH_VERSION: 4.2.2
MPICH_VERSION: 4.3.0
MPICH_DIR: ${{ github.workspace }}/mpich-install
PNETCDF_VERSION: 1.13.0
PNETCDF_VERSION: 1.14.0
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
strategy:
matrix:
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
- name: Test PnetCDF-Python
run: |
export PATH=${MPICH_DIR}/bin:${PATH}
make ptests
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"

- name: Re-install PnetCDF-Python from source distribution
run: |
Expand All @@ -104,7 +104,7 @@ jobs:
- name: Test PnetCDF-Python
run: |
export PATH=${MPICH_DIR}/bin:${PATH}
make ptests
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"

# - name: Tarball
# run: |
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ scalable I/O performance.
export PNETCDF_DIR=/path/to/pnetcdf/dir
pip install --no-build-isolation -e .
```
* Testing -- Command `"make check"` tests all the programs available in folders
["test/"](./test) and ["examples/"](./examples).
* Testing
+ Command `"make check"` tests all the programs available in folders
["test/"](./test) and ["examples/"](./examples) by running one MPI process.
+ Command `"make ptests"` tests all the programs by running more than one MPI
process.
+ Note when using OpenMPI, use command below.
```
make check TESTMPIRUN="/path/to/OpenMPI/bin/mpirun --oversubscribe"
make ptests TESTMPIRUN="/path/to/OpenMPI/bin/mpirun --oversubscribe"
```

### Additional Resources
* [Example python programs](./examples#pnetcdf-python-examples) available in
Expand Down
4 changes: 3 additions & 1 deletion examples/MNIST/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ check_PROGRAMS = mnist_main.py

MNIST_URL = https://raw.githubusercontent.com/pytorch/examples/main/mnist/main.py

TESTMPIRUN = $(shell dirname ${CC})/mpirun

all:

mnist_main.py:
Expand Down Expand Up @@ -45,7 +47,7 @@ ptests check: mnist_main.py
@echo "======================================================================"
@echo " examples/MNIST: Parallel testing on 4 MPI processes"
@echo "======================================================================"
@mpiexec -n 4 python mnist_main.py --batch-size 4 --test-batch-size 2 --epochs 3 --input-file mnist_images.nc
@${TESTMPIRUN} -n 4 python mnist_main.py --batch-size 4 --test-batch-size 2 --epochs 3 --input-file mnist_images.nc
@echo ""

clean:
Expand Down
3 changes: 2 additions & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ check_PROGRAMS = collective_write.py \
put_var.py \
get_var.py


TESTMPIRUN = $(shell dirname ${CC})/mpirun
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";

OUTPUT_DIR = _tmp_output

Expand Down
2 changes: 2 additions & 0 deletions examples/Pytorch_DDP/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
check_PROGRAMS = torch_ddp_skeleton.py


TESTMPIRUN = $(shell dirname ${CC})/mpirun
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";

OUTPUT_DIR = _tmp_output

Expand Down
2 changes: 1 addition & 1 deletion examples/Pytorch_DDP/parallel_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ for prog in $check_PROGRAMS; do
printf '%-60s' "Testing $prog"

if test $prog = "torch_ddp_skeleton.py" ; then
CMD="mpiexec -n $NPROC python $prog -q"
CMD="${TESTMPIRUN} -n $NPROC python $prog -q"
fi
$CMD
status=$?
Expand Down
3 changes: 2 additions & 1 deletion examples/nonblocking/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ check_PROGRAMS = nonblocking_write_def.py \
nonblocking_write.py \
nonblocking_read.py


TESTMPIRUN = $(shell dirname ${CC})/mpirun
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";

OUTPUT_DIR = _tmp_output

Expand Down
4 changes: 2 additions & 2 deletions examples/nonblocking/parallel_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ for prog in $check_PROGRAMS; do
printf '%-60s' "Testing $prog"

if test "x$prog" = "xnonblocking_read.py" ; then
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/nonblocking_write.nc"
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/nonblocking_write.nc"
else
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
fi
# echo "$CMD"

Expand Down
4 changes: 2 additions & 2 deletions examples/parallel_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ for prog in $check_PROGRAMS; do
printf '%-60s' "Testing $prog"

if test $prog = "get_var.py" ; then
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/put_var.nc"
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/put_var.nc"
else
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
fi
$CMD
status=$?
Expand Down
Loading