Skip to content

Commit 6d810d5

Browse files
committed
A pile of comment text cleanups
1 parent b9ca54d commit 6d810d5

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

mpi4.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
1212
You should run this, not with `python`, but with `mpirun`.
1313
Or, you can run it in a SLURM job, using `srun` (or `mpirun`).
14-
Read the README.rst for more details!
14+
Read the README.md for more details!
1515
"""
1616

1717
# Import MPI at the start, as we'll use it everywhere.
@@ -64,8 +64,8 @@ def main():
6464
else:
6565
return mpi_nonroot(mpi_comm)
6666

67-
# This program has two parts: The root part and the non-root part.
68-
# The root part is executed by rank 0; the non-root part by everyone else.
67+
# This program has two parts: The controller and the worker part.
68+
# The controller is executed by rank 0; the workers by everyone else.
6969
# SOME TERMINOLOGY:
7070
# MPI World: All of the MPI processes, spawned by `mpirun` or SLURM/srun.
7171
# MPI Size: The number of MPI slots (or SLURM tasks).
@@ -95,6 +95,10 @@ def mpi_root(mpi_comm):
9595
Once all results are gathered, output each result (the gathered array is
9696
sorted by MPI rank). Verify that each int returned is correct, by doing
9797
the math (`returned int == random_number + MPI_rank`) locally.
98+
99+
At the end, send each worker (via a unicast message) an `int` zero. Then,
100+
wait for everyone to be at the same point in code (via a battier). Then
101+
we're done!
98102
"""
99103

100104
# We import `random` here because we only use it here.
@@ -104,7 +108,7 @@ def mpi_root(mpi_comm):
104108
# NOTE: The lower-case methods (like `bcast()`) take Python object, and do
105109
# the serialization for us (yay!).
106110
# `bast()` is blocking, in the sense that it does not return until
107-
# the data has been sent, but it is _not_ synchronizing.
111+
# the data have been sent, but it is _not_ synchronizing.
108112
# There's also no guarantee as to _how_ the data were conveyed.
109113
# NOTE: In Python 3.6+, we should use `secret` instead of `random`.
110114
random_number = random.randrange(2**32)
@@ -209,6 +213,12 @@ def mpi_nonroot(mpi_comm):
209213
Return, via the gather process, a tuple with two items:
210214
* The MPI "CPU Identifier" (normally a hostname)
211215
* The calculated number, above.
216+
217+
Then, enter a loop: We receive a number (an `int`) from the controller. If
218+
the number is zero, we exit the loop. Otherwise, we divide the number by
219+
two, convert the result to an int, and send the result to the controller.
220+
221+
Finally, after the loop is over, we synchronize via an MPI barrier.
212222
"""
213223

214224
# Get our MPI rank.

mpi4.py.sbatch

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PYTHON_PROGRAM=${PYTHON_PROGRAM:-python3}
3838

3939
# What MPI runner do we use?
4040
# This is important, because it sets up all of the inter-process communications,
41-
# on both this node, and all of the other nodes running this job.
41+
# on both this node and all of the other nodes running this job.
4242
# We prefer letting SLURM handle MPI setup, via `srun --mpi=openmpi`.
4343
# But, you can override it by setting the RUN_COMMAND environment variable.
4444
# NOTE that SLURM's slurm.conf specifies a default MPI to use (in case `--mpi`

0 commit comments

Comments
 (0)