Skip to content

Commit b686c77

Browse files
committed
Add more docs
1 parent 0f616e9 commit b686c77

File tree

3 files changed

+127
-5
lines changed

3 files changed

+127
-5
lines changed

doc/development.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ The are some tests that only run on Cori at NERSC and these are not
144144
run as part of the :ref:`CI <continuous integration>` and must be run
145145
manually. To run those test you need to add the option ``--runcori``
146146
to the ``pytest``. There are tests for the :ref:`shifter
147-
functionally<dask_shifter>` that is Cori specific. There are also test
148-
for the srun command built with different ``task_ppn`` and
147+
functionally<dask_shifter>` that is Cori specific. There are also
148+
tests for the srun commands built with different ``task_ppn`` and
149149
``task_cpp`` options in
150150
:meth:`~ipsframework.services.ServicesProxy.launch_task`.
151151

@@ -166,7 +166,8 @@ An example batch script for running the unit tests is:
166166
module load python/3.8-anaconda-2020.11
167167
python -m pytest --runcori
168168
169-
The check the output in ``pytest.out`` to see that all the tests passed.
169+
Then check the output in ``pytest.out`` to see that all the tests
170+
passed.
170171

171172
Writing Tests
172173
~~~~~~~~~~~~~

doc/user_guides/advanced_guide.rst

Lines changed: 122 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,128 @@ Component invocation in the IPS means one component is calling another component
291291
Task Launch
292292
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
293293

294-
The task launch interface allows components to launch and manage the execution of (parallel) executables. Similar to the component invocation interface, the behavior of *launch_task* and the *wait_task* variants are controlled using the *block* keyword argument and different interfaces to *wait_task*.
294+
The task launch interface allows components to launch and manage the
295+
execution of (parallel) executables. Similar to the component
296+
invocation interface, the behavior of
297+
:py:meth:`~ipsframework.services.ServicesProxy.launch_task` and the
298+
:py:meth:`~ipsframework.services.ServicesProxy.wait_task` variants are
299+
controlled using the *block* keyword argument and different interfaces
300+
to *wait_task*.
301+
302+
The ``task_ppn`` and ``task_cpp`` options all greater control over how
303+
commands are made. ``task_ppn`` will limit the number of task per
304+
node, ``task_ccp`` will limit the number of cores assigned to each
305+
process, this is only used when ``MPIRUN=srun``, if ``task_cpp`` is
306+
not set it will be calculated automatically.
307+
308+
~~~~~~~~~~~~~~
309+
Slurm examples
310+
~~~~~~~~~~~~~~
311+
312+
The following examples show the behavior if you are running on a `Cori
313+
<https://docs.nersc.gov/systems/cori>`_ with 32 cores per node.
314+
315+
Using the `check-mpi.gnu.cori
316+
<https://docs.nersc.gov/jobs/affinity/#use-nersc-prebuilt-binaries>`_
317+
binary provided on Cori with ``nproc=8`` without specifying other
318+
options:
319+
320+
.. code-block:: python
321+
322+
self.services.launch_task(8, cwd, "check-mpi.gnu.cori")
323+
324+
the ``srun`` command created will be ``srun -N 1 -n 8 -c
325+
4 --threads-per-core=1 --cpu-bind=cores check-mpi.gnu.cori`` along
326+
with settings the environment variables for OpenMP
327+
``OMP_PLACES=threads OMP_PROC_BIND=spread OMP_NUM_THREADS=4``. The
328+
resulting core affinity is
329+
330+
.. code-block:: text
331+
332+
Hello from rank 0, on nid00025. (core affinity = 0-3)
333+
Hello from rank 1, on nid00025. (core affinity = 16-19)
334+
Hello from rank 2, on nid00025. (core affinity = 4-7)
335+
Hello from rank 3, on nid00025. (core affinity = 20-23)
336+
Hello from rank 4, on nid00025. (core affinity = 8-11)
337+
Hello from rank 5, on nid00025. (core affinity = 24-27)
338+
Hello from rank 6, on nid00025. (core affinity = 12-15)
339+
Hello from rank 7, on nid00025. (core affinity = 28-31)
340+
341+
If you also include the option ``task_ppn=4``:
342+
343+
.. code-block:: python
344+
345+
self.services.launch_task(8, cwd, "check-mpi.gnu.cori", task_ppn=4)
346+
347+
then the command created will be ``srun -N 2 -n 8 -c
348+
8 --threads-per-core=1 --cpu-bind=cores check-mpi.gnu.cori`` along
349+
with settings the environment variables for OpenMP
350+
``OMP_PLACES=threads OMP_PROC_BIND=spread OMP_NUM_THREADS=8``. The
351+
resulting core affinity is
352+
353+
.. code-block:: text
354+
355+
Hello from rank 0, on nid00025. (core affinity = 0-7)
356+
Hello from rank 1, on nid00025. (core affinity = 16-23)
357+
Hello from rank 2, on nid00025. (core affinity = 8-15)
358+
Hello from rank 3, on nid00025. (core affinity = 24-31)
359+
Hello from rank 4, on nid00026. (core affinity = 0-7)
360+
Hello from rank 5, on nid00026. (core affinity = 16-23)
361+
Hello from rank 6, on nid00026. (core affinity = 8-15)
362+
Hello from rank 7, on nid00026. (core affinity = 24-31)
363+
364+
You can limit the ``--cpus-per-task`` of the ``srun`` command by
365+
setting ``task_cpp``, adding ``task_cpp=2``
366+
367+
.. code-block:: python
368+
369+
self.services.launch_task(8, cwd, "check-mpi.gnu.cori", task_ppn=4, task_cpp=2)
370+
371+
will create the command ``srun -N 2 -n 8 -c
372+
2 --threads-per-core=1 --cpu-bind=cores check-mpi.gnu.cori`` and set
373+
``OMP_PLACES=threads OMP_PROC_BIND=spread OMP_NUM_THREADS=2``. This
374+
will result in under-utilizing the nodes, which may be needed if your
375+
task is memory bound. The resulting core affinity is
376+
377+
.. code-block:: text
378+
379+
Hello from rank 0, on nid00025. (core affinity = 0,1)
380+
Hello from rank 1, on nid00025. (core affinity = 16,17)
381+
Hello from rank 2, on nid00025. (core affinity = 2,3)
382+
Hello from rank 3, on nid00025. (core affinity = 18,19)
383+
Hello from rank 4, on nid00026. (core affinity = 0,1)
384+
Hello from rank 5, on nid00026. (core affinity = 16,17)
385+
Hello from rank 6, on nid00026. (core affinity = 2,3)
386+
Hello from rank 7, on nid00026. (core affinity = 18,19)
387+
388+
Using the `check-hybrid.gnu.cori
389+
<https://docs.nersc.gov/jobs/affinity/#use-nersc-prebuilt-binaries>`_
390+
binary with the same options:
391+
392+
.. code-block:: python
393+
394+
self.services.launch_task(8, cwd, "check-hybrid.gnu.cori", task_ppn=4, task_cpp=2)
395+
396+
the resulting core affinity of the OpenMP threads are:
397+
398+
.. code-block:: text
399+
400+
Hello from rank 0, thread 0, on nid00025. (core affinity = 0)
401+
Hello from rank 0, thread 1, on nid00025. (core affinity = 1)
402+
Hello from rank 1, thread 0, on nid00025. (core affinity = 16)
403+
Hello from rank 1, thread 1, on nid00025. (core affinity = 17)
404+
Hello from rank 2, thread 0, on nid00025. (core affinity = 2)
405+
Hello from rank 2, thread 1, on nid00025. (core affinity = 3)
406+
Hello from rank 3, thread 0, on nid00025. (core affinity = 18)
407+
Hello from rank 3, thread 1, on nid00025. (core affinity = 19)
408+
Hello from rank 4, thread 0, on nid00026. (core affinity = 0)
409+
Hello from rank 4, thread 1, on nid00026. (core affinity = 1)
410+
Hello from rank 5, thread 0, on nid00026. (core affinity = 16)
411+
Hello from rank 5, thread 1, on nid00026. (core affinity = 17)
412+
Hello from rank 6, thread 0, on nid00026. (core affinity = 2)
413+
Hello from rank 6, thread 1, on nid00026. (core affinity = 3)
414+
Hello from rank 7, thread 0, on nid00026. (core affinity = 18)
415+
Hello from rank 7, thread 1, on nid00026. (core affinity = 19)
295416
296417
.. automethod:: ipsframework.services.ServicesProxy.launch_task
297418
:noindex:

ipsframework/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def launch_task(self, nproc, working_dir, binary, *args, **keywords):
554554
manage how the binary is launched. Keywords may be the following:
555555
556556
* *task_ppn* : the processes per node value for this task
557-
* *task_cpp* : the cores per process
557+
* *task_cpp* : the cores per process, only used when ``MPIRUN=srun`` commands
558558
* *block* : specifies that this task will block (or raise an
559559
exception) if not enough resources are available to run
560560
immediately. If ``True``, the task will be retried until it

0 commit comments

Comments
 (0)