You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorial_advanced.rst
+59-2Lines changed: 59 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -576,8 +576,6 @@ The trick here is to replace the parallel launcher with the local one, which pra
576
576
The :func:`~reframe.core.backends.getlauncher` function takes the `registered <config_reference.html#systems-.partitions-.launcher>`__ name of a launcher and returns the class that implements it.
577
577
You then instantiate the launcher and assign to the :attr:`~reframe.core.schedulers.Job.launcher` attribute of the job descriptor.
578
578
579
-
An alternative to this approach would be to define your own custom parallel launcher and register it with the framework.
580
-
You could then use it as the scheduler of a system partition in the configuration, but this approach is less test-specific.
581
579
582
580
Adding more parallel launch commands
583
581
====================================
@@ -628,6 +626,65 @@ Let's see how the generated job script looks like:
628
626
The first three ``srun`` commands are emitted through the :attr:`prerun_cmds` whereas the last one comes from the test's :attr:`executable` attribute.
629
627
630
628
629
+
Adding a custom launcher to a partition
630
+
=======================================
631
+
632
+
.. versionadded:: 4.0.0
633
+
634
+
An alternative to the approaches above would be to define your own custom parallel launcher and register it with the framework.
635
+
You could then use it as the launcher of a system partition in the configuration and use it in multiple tests.
636
+
637
+
Each `launcher <regression_test_api.html#reframe.core.launchers.JobLauncher>`__ needs to implement the :func:`~reframe.core.launchers.JobLauncher.command` method and can optionally change the default :func:`~reframe.core.launchers.JobLauncher.run_command` method.
638
+
639
+
As an example of how easy it is to define a new parallel launcher backend, here is the actual implementation of the ``mpirun`` launcher:
640
+
641
+
.. code:: python
642
+
643
+
from reframe.core.backends import register_launcher
644
+
from reframe.core.launchers import JobLauncher
645
+
646
+
647
+
@register_launcher('mpirun')
648
+
classMpirunLauncher(JobLauncher):
649
+
defcommand(self, job):
650
+
return ['mpirun', '-np', str(job.num_tasks)]
651
+
652
+
653
+
The :func:`~reframe.core.launchers.JobLauncher.command` returns a list of command tokens that will be combined with any user-supplied `options <regression_test_api.html#reframe.core.launchers.JobLauncher.options>`__ by the :func:`~reframe.core.launchers.JobLauncher.run_command` method to generate the actual launcher command line.
654
+
Notice you can use the ``job`` argument to get job-specific information that will allow you to construct the correct launcher invocation.
655
+
656
+
If you use a Python-based configuration file, you can define your custom launcher directly inside your config as follows:
657
+
658
+
.. code:: python
659
+
660
+
from reframe.core.backends import register_launcher
0 commit comments