Skip to content

Commit 1514f45

Browse files
authored
Merge pull request #62 from wkliao/openmpi
Support OpenMPI
2 parents 352a0bb + d6d0005 commit 1514f45

File tree

15 files changed

+238
-60
lines changed

15 files changed

+238
-60
lines changed

.github/workflows/openmpi.yml

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
name: Using OpenMPI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '**/*.md'
8+
- '**/*.txt'
9+
pull_request:
10+
branches:
11+
- main
12+
paths-ignore:
13+
- '**/*.md'
14+
- '**/*.txt'
15+
16+
jobs:
17+
build-linux:
18+
name: Python (${{ matrix.python-version }})
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 60
21+
env:
22+
OPENMPI_VERSION: 5.0.7
23+
OPENMPI_DIR: ${{ github.workspace }}/ompi-install
24+
PNETCDF_VERSION: 1.14.0
25+
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
26+
strategy:
27+
matrix:
28+
python-version: ["3.10"]
29+
steps:
30+
31+
- uses: actions/checkout@v4
32+
33+
- name: Set up Python ${{ matrix.python-version }}
34+
uses: actions/setup-python@v4
35+
with:
36+
python-version: ${{ matrix.python-version }}
37+
38+
- name: Install Ubuntu Dependencies
39+
run: |
40+
sudo apt-get update
41+
sudo apt-get install m4
42+
43+
- name: Build OPENMPI
44+
run: |
45+
echo "Install OpenMPI ${OPENMPI_VERSION} in $OPENMPI_DIR"
46+
VER_MAJOR=${OPENMPI_VERSION%.*}
47+
rm -rf OPENMPI ; mkdir OPENMPI ; cd OPENMPI
48+
wget -q https://download.open-mpi.org/release/open-mpi/v${VER_MAJOR}/openmpi-${OPENMPI_VERSION}.tar.gz
49+
gzip -dc openmpi-${OPENMPI_VERSION}.tar.gz | tar -xf -
50+
cd openmpi-${OPENMPI_VERSION}
51+
./configure --prefix=$OPENMPI_DIR \
52+
--with-io-romio-flags="--with-file-system=ufs" \
53+
--with-hwloc=internal \
54+
--with-pmix=internal \
55+
--with-libevent=internal \
56+
--disable-mpi-fortran \
57+
CC=gcc
58+
make -s LIBTOOLFLAGS=--silent V=1 -j 4 install > qout 2>&1
59+
make -s -j 4 distclean >> qout 2>&1
60+
61+
- name: Build PnetCDF-C official release
62+
run: |
63+
echo "Download and build PnetCDF-C release version ${PNETCDF_VERSION}"
64+
wget -q https://parallel-netcdf.github.io/Release/pnetcdf-${PNETCDF_VERSION}.tar.gz
65+
tar -xzf pnetcdf-${PNETCDF_VERSION}.tar.gz
66+
pushd pnetcdf-${PNETCDF_VERSION}
67+
./configure --prefix=$PNETCDF_DIR \
68+
--silent \
69+
--enable-shared \
70+
--enable-debug \
71+
--disable-fortran \
72+
--disable-cxx \
73+
--with-mpi=$OPENMPI_DIR
74+
make -s LIBTOOLFLAGS=--silent V=1 -j 4 install > qout 2>&1
75+
make -s -j 4 distclean >> qout 2>&1
76+
popd
77+
78+
- name: Install python dependencies via pip
79+
run: |
80+
python -m pip install --upgrade pip setuptools wheel
81+
pip install numpy cython cftime pytest twine check-manifest
82+
export MPICC=$OPENMPI_DIR/bin/mpicc
83+
pip install mpi4py
84+
pip install torch torchvision
85+
86+
- name: Install PnetCDF-Python
87+
run: |
88+
export CC=$OPENMPI_DIR/bin/mpicc
89+
pip install --verbose --no-build-isolation -e .
90+
91+
- name: Test PnetCDF-Python
92+
run: |
93+
export PATH=${OPENMPI_DIR}/bin:${PATH}
94+
make ptests TESTMPIRUN="${OPENMPI_DIR}/bin/mpiexec --oversubscribe"
95+
96+
- name: Re-install PnetCDF-Python from source distribution
97+
run: |
98+
pip uninstall -y pnetcdf
99+
make install-clean
100+
export CC=$OPENMPI_DIR/bin/mpicc
101+
python setup.py sdist
102+
pip install --verbose dist/pnetcdf-*.tar.gz
103+
104+
- name: Test PnetCDF-Python
105+
run: |
106+
export PATH=${OPENMPI_DIR}/bin:${PATH}
107+
make ptests TESTMPIRUN="${OPENMPI_DIR}/bin/mpiexec --oversubscribe"
108+
109+
# - name: Tarball
110+
# run: |
111+
# export PATH=${NETCDF_DIR}/bin:${PATH}
112+
# python setup.py --version
113+
# check-manifest --version
114+
# check-manifest --verbose
115+
# pip wheel . -w dist --no-deps
116+
# twine check dist/*

.github/workflows/pnetcdf_c_master.yml

+50-3
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,14 @@ jobs:
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 60
2121
env:
22-
MPICH_VERSION: 4.2.2
22+
MPICH_VERSION: 4.3.0
2323
MPICH_DIR: ${{ github.workspace }}/mpich-install
2424
PNETCDF_VERSION: repo
2525
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
26+
AUTOCONF_VERSION: 2.71
27+
AUTOMAKE_VERSION: 1.17
28+
LIBTOOL_VERSION: 2.5.4
29+
M4_VERSION: 1.4.19
2630

2731
strategy:
2832
matrix:
@@ -41,6 +45,43 @@ jobs:
4145
sudo apt-get update
4246
sudo apt-get install automake autoconf libtool libtool-bin m4
4347
48+
- name: Build GNU autotools
49+
run: |
50+
export PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/bin:${PATH}"
51+
export LD_LIBRARY_PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/lib:${LD_LIBRARY_PATH}"
52+
cd ${GITHUB_WORKSPACE}
53+
wget -q https://ftp.gnu.org/gnu/m4/m4-${M4_VERSION}.tar.gz
54+
gzip -dc m4-${M4_VERSION}.tar.gz | tar -xf -
55+
cd m4-${M4_VERSION}
56+
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
57+
--silent
58+
make -s -j 8 install > qout 2>&1
59+
make -s -j 8 distclean >> qout 2>&1
60+
cd ${GITHUB_WORKSPACE}
61+
wget -q https://ftp.gnu.org/gnu/autoconf/autoconf-${AUTOCONF_VERSION}.tar.gz
62+
gzip -dc autoconf-${AUTOCONF_VERSION}.tar.gz | tar -xf -
63+
cd autoconf-${AUTOCONF_VERSION}
64+
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
65+
--silent
66+
make -s -j 8 install > qout 2>&1
67+
make -s -j 8 distclean >> qout 2>&1
68+
cd ${GITHUB_WORKSPACE}
69+
wget -q https://ftp.gnu.org/gnu/automake/automake-${AUTOMAKE_VERSION}.tar.gz
70+
gzip -dc automake-${AUTOMAKE_VERSION}.tar.gz | tar -xf -
71+
cd automake-${AUTOMAKE_VERSION}
72+
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
73+
--silent
74+
make -s -j 8 install > qout 2>&1
75+
make -s -j 8 distclean >> qout 2>&1
76+
cd ${GITHUB_WORKSPACE}
77+
wget -q https://ftp.gnu.org/gnu/libtool/libtool-${LIBTOOL_VERSION}.tar.gz
78+
gzip -dc libtool-${LIBTOOL_VERSION}.tar.gz | tar -xf -
79+
cd libtool-${LIBTOOL_VERSION}
80+
./configure --prefix=${GITHUB_WORKSPACE}/AUTOTOOLS \
81+
--silent
82+
make -s -j 8 install > qout 2>&1
83+
make -s -j 8 distclean >> qout 2>&1
84+
4485
- name: Build MPICH
4586
run: |
4687
echo "Install MPICH ${MPICH_VERSION} in $MPICH_DIR"
@@ -63,6 +104,12 @@ jobs:
63104
run: |
64105
echo "Build PnetCDF-C from its master branch"
65106
cd ${GITHUB_WORKSPACE}
107+
export PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/bin:${PATH}"
108+
export LD_LIBRARY_PATH="${GITHUB_WORKSPACE}/AUTOTOOLS/lib:${LD_LIBRARY_PATH}"
109+
m4 --version
110+
autoconf --version
111+
automake --version
112+
libtool --version
66113
git clone -q https://github.com/Parallel-NetCDF/PnetCDF.git
67114
pushd PnetCDF
68115
autoreconf -i
@@ -93,7 +140,7 @@ jobs:
93140
- name: Test PnetCDF-Python
94141
run: |
95142
export PATH=${MPICH_DIR}/bin:${PATH}
96-
make ptests
143+
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"
97144
98145
- name: Re-install PnetCDF-Python from source distribution
99146
run: |
@@ -106,7 +153,7 @@ jobs:
106153
- name: Test PnetCDF-Python
107154
run: |
108155
export PATH=${MPICH_DIR}/bin:${PATH}
109-
make ptests
156+
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"
110157
# - name: Tarball
111158
# run: |
112159
# export PATH=${NETCDF_DIR}/bin:${PATH}

.github/workflows/pnetcdf_c_official.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ jobs:
1919
runs-on: ubuntu-latest
2020
timeout-minutes: 60
2121
env:
22-
MPICH_VERSION: 4.2.2
22+
MPICH_VERSION: 4.3.0
2323
MPICH_DIR: ${{ github.workspace }}/mpich-install
24-
PNETCDF_VERSION: 1.13.0
24+
PNETCDF_VERSION: 1.14.0
2525
PNETCDF_DIR: ${{ github.workspace }}/PnetCDF-install
2626
strategy:
2727
matrix:
@@ -91,7 +91,7 @@ jobs:
9191
- name: Test PnetCDF-Python
9292
run: |
9393
export PATH=${MPICH_DIR}/bin:${PATH}
94-
make ptests
94+
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"
9595
9696
- name: Re-install PnetCDF-Python from source distribution
9797
run: |
@@ -104,7 +104,7 @@ jobs:
104104
- name: Test PnetCDF-Python
105105
run: |
106106
export PATH=${MPICH_DIR}/bin:${PATH}
107-
make ptests
107+
make ptests TESTMPIRUN="${MPICH_DIR}/bin/mpiexec"
108108
109109
# - name: Tarball
110110
# run: |

README.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,16 @@ scalable I/O performance.
4040
export PNETCDF_DIR=/path/to/pnetcdf/dir
4141
pip install --no-build-isolation -e .
4242
```
43-
* Testing -- Command `"make check"` tests all the programs available in folders
44-
["test/"](./test) and ["examples/"](./examples).
43+
* Testing
44+
+ Command `"make check"` tests all the programs available in folders
45+
["test/"](./test) and ["examples/"](./examples) by running one MPI process.
46+
+ Command `"make ptests"` tests all the programs by running more than one MPI
47+
process.
48+
+ Note when using OpenMPI, use command below.
49+
```
50+
make check TESTMPIRUN="/path/to/OpenMPI/bin/mpirun --oversubscribe"
51+
make ptests TESTMPIRUN="/path/to/OpenMPI/bin/mpirun --oversubscribe"
52+
```
4553
4654
### Additional Resources
4755
* [Example python programs](./examples#pnetcdf-python-examples) available in

examples/MNIST/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ check_PROGRAMS = mnist_main.py
77

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

10+
TESTMPIRUN = $(shell dirname ${CC})/mpirun
11+
1012
all:
1113

1214
mnist_main.py:
@@ -45,7 +47,7 @@ ptests check: mnist_main.py
4547
@echo "======================================================================"
4648
@echo " examples/MNIST: Parallel testing on 4 MPI processes"
4749
@echo "======================================================================"
48-
@mpiexec -n 4 python mnist_main.py --batch-size 4 --test-batch-size 2 --epochs 3 --input-file mnist_images.nc
50+
@${TESTMPIRUN} -n 4 python mnist_main.py --batch-size 4 --test-batch-size 2 --epochs 3 --input-file mnist_images.nc
4951
@echo ""
5052

5153
clean:

examples/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ check_PROGRAMS = collective_write.py \
1717
put_var.py \
1818
get_var.py
1919

20-
20+
TESTMPIRUN = $(shell dirname ${CC})/mpirun
2121
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
2222
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
23+
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";
2324

2425
OUTPUT_DIR = _tmp_output
2526

examples/Pytorch_DDP/Makefile

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
check_PROGRAMS = torch_ddp_skeleton.py
77

88

9+
TESTMPIRUN = $(shell dirname ${CC})/mpirun
910
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
1011
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
12+
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";
1113

1214
OUTPUT_DIR = _tmp_output
1315

examples/Pytorch_DDP/parallel_run.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ for prog in $check_PROGRAMS; do
3131
printf '%-60s' "Testing $prog"
3232

3333
if test $prog = "torch_ddp_skeleton.py" ; then
34-
CMD="mpiexec -n $NPROC python $prog -q"
34+
CMD="${TESTMPIRUN} -n $NPROC python $prog -q"
3535
fi
3636
$CMD
3737
status=$?

examples/nonblocking/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ check_PROGRAMS = nonblocking_write_def.py \
77
nonblocking_write.py \
88
nonblocking_read.py
99

10-
10+
TESTMPIRUN = $(shell dirname ${CC})/mpirun
1111
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
1212
TESTS_ENVIRONMENT += export PNETCDF_DIR="${PNETCDF_DIR}";
13+
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";
1314

1415
OUTPUT_DIR = _tmp_output
1516

examples/nonblocking/parallel_run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ for prog in $check_PROGRAMS; do
6161
printf '%-60s' "Testing $prog"
6262

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

examples/parallel_run.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ for prog in $check_PROGRAMS; do
6161
printf '%-60s' "Testing $prog"
6262

6363
if test $prog = "get_var.py" ; then
64-
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/put_var.nc"
64+
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/put_var.nc"
6565
else
66-
CMD="mpiexec -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
66+
CMD="${TESTMPIRUN} -n $NPROC python $prog -q $OUT_DIR/${prog%.*}.nc"
6767
fi
6868
$CMD
6969
status=$?

0 commit comments

Comments
 (0)