Skip to content

Commit

Permalink
Fix a bug in the ground filter triggered when running without MPI. (#370
Browse files Browse the repository at this point in the history
)

* Fix a bug in the ground filter triggered when running without MPI.  Backport the toast3 environment variable for disabling MPI at runtime.

* Explicitly disable MPI in serial tests, to catch improper handling of passing None for world communicator.

* Update changelog
  • Loading branch information
tskisner authored Oct 16, 2020
1 parent 3ce2e2e commit 00351c9
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py36 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py36 python -c 'import toast.tests; toast.tests.run()'
run: docker run -e MPI_DISABLE=1 test_runner:py36 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py36 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
py37:
Expand All @@ -46,7 +46,7 @@ jobs:
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py37 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py37 python -c 'import toast.tests; toast.tests.run()'
run: docker run -e MPI_DISABLE=1 test_runner:py37 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py37 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
py38:
Expand All @@ -66,6 +66,6 @@ jobs:
- name: Test Documentation Build
run: docker run -v "$(pwd)":/home/toast test_runner:py38 /home/toast/docs/build_docs.sh
- name: Run Serial Tests
run: docker run test_runner:py38 python -c 'import toast.tests; toast.tests.run()'
run: docker run -e MPI_DISABLE=1 test_runner:py38 python -c 'import toast.tests; toast.tests.run()'
- name: Run MPI Tests
run: docker run test_runner:py38 mpirun -np 2 python -c 'import toast.tests; toast.tests.run()'
7 changes: 7 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ Change Log

* No changes yet.

2.3.9.post1 (2020-10-15)
~~~~~~~~~~~~~~~~~~~~~~~~~

* Run serial unit tests without MPI. Fix bug in ground filter (PR `#370`_).

.. _`#370`: https://github.com/hpc4cmb/toast/pull/370

2.3.9 (2020-10-15)
~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion src/toast/RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.10a1
2.3.9.post1
44 changes: 25 additions & 19 deletions src/toast/mpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@
MPI = None

if use_mpi is None:
# Special handling for running on a NERSC login node. This is for convenience.
# The same behavior could be implemented with environment variables set in a
# shell resource file.
at_nersc = False
if "NERSC_HOST" in os.environ:
at_nersc = True
in_slurm = False
if "SLURM_JOB_NAME" in os.environ:
in_slurm = True
if not at_nersc or in_slurm:
try:
import mpi4py.MPI as MPI

use_mpi = True
except:
# There could be many possible exceptions raised...
log = Logger.get()
log.info("mpi4py not found- using serial operations only")
use_mpi = False
# See if the user has explicitly disabled MPI.
if "MPI_DISABLE" in os.environ:
use_mpi = False
else:
# Special handling for running on a NERSC login node. This is for convenience.
# The same behavior could be implemented with environment variables set in a
# shell resource file.
at_nersc = False
if "NERSC_HOST" in os.environ:
at_nersc = True
in_slurm = False
if "SLURM_JOB_NAME" in os.environ:
in_slurm = True
if (not at_nersc) or in_slurm:
try:
import mpi4py.MPI as MPI

use_mpi = True
except:
# There could be many possible exceptions raised...
from ._libtoast import Logger

log = Logger.get()
log.info("mpi4py not found- using serial operations only")
use_mpi = False


def get_world():
Expand Down
6 changes: 5 additions & 1 deletion src/toast/todmap/groundfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def fit_templates(self, tod, det, templates, ref, good):
ngood = np.sum(good)
else:
ngood = 0
ngood_tot = comm.allreduce(ngood)
ngood_tot = None
if comm is None:
ngood_tot = ngood
else:
ngood_tot = comm.allreduce(ngood)
if ngood_tot == 0:
return None

Expand Down

0 comments on commit 00351c9

Please sign in to comment.