Skip to content

Commit 4c64c65

Browse files
committed
support OpenMPI used to build mpi4py and PnetCDF
1 parent 502c989 commit 4c64c65

File tree

10 files changed

+28
-12
lines changed

10 files changed

+28
-12
lines changed

README.md

Lines changed: 10 additions & 2 deletions
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

Lines changed: 3 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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=$?

test/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ check_PROGRAMS = tst_atts.py \
5050
tst_wait.py \
5151
tst_libver.py
5252

53+
TESTMPIRUN = $(shell dirname ${CC})/mpirun
5354
TESTS_ENVIRONMENT = export check_PROGRAMS="${check_PROGRAMS}";
55+
TESTS_ENVIRONMENT += export TESTMPIRUN="$(TESTMPIRUN)";
5456
OUTPUT_DIR = _tmp_output
5557

5658
all:

test/parallel_run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ for prog in ${check_PROGRAMS} ; do
3131
printf '%-60s' "Testing $prog "
3232

3333
if test $prog = "tst_libver.py" ; then
34-
CMD="mpiexec -n $NPROC python $prog -q"
34+
CMD="${TESTMPIRUN} -n $NPROC python $prog -q"
3535
else
36-
CMD="mpiexec -n $NPROC python $prog $OUT_DIR"
36+
CMD="${TESTMPIRUN} -n $NPROC python $prog $OUT_DIR"
3737
fi
3838
$CMD
3939
status=$?

0 commit comments

Comments
 (0)