Skip to content

Commit

Permalink
Merge pull request #1514 from Libensemble/feature/no_mpi_handling
Browse files Browse the repository at this point in the history
Improve handling when no MPI found.
  • Loading branch information
shuds13 authored Feb 18, 2025
2 parents b7317db + 69f40cc commit f7270d5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 19 deletions.
34 changes: 20 additions & 14 deletions libensemble/executors/mpi_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,29 +47,32 @@ class MPIExecutor(Executor):
information using the ``custom_info`` argument. This takes
a dictionary of values.
The allowable fields are::
The allowable fields are:
'mpi_runner' [string]:
Select runner: 'mpich', 'openmpi', 'aprun', 'srun', 'jsrun', 'custom'
All except 'custom' relate to runner classes in libEnsemble.
.. parsed-literal::
**'mpi_runner'** [string]:
Select runner: `'mpich'`, `'openmpi'`, `'aprun'`, `'srun'`, `'jsrun'`, `'custom'`
All except `'custom'` relate to runner classes in libEnsemble.
Custom allows user to define their own run-lines but without parsing
arguments or making use of auto-resources.
'runner_name' [string]:
Runner name: Replaces run command if present. All runners have a default
except for 'custom'.
'subgroup_launch' [bool]:
**'runner_name'** [string]:
The literal string that appears at the front of the run command.
This is typically 'mpirun', 'srun', etc., and can be a full path.
Defaults exist for all runners except 'custom'.
**'subgroup_launch'** [bool]:
Whether MPI runs should be initiated in a new process group. This needs
to be correct for kills to work correctly. Use the standalone test at
libensemble/tests/standalone_tests/kill_test to determine correct value
`libensemble/tests/standalone_tests/kill_test` to determine correct value
for a system.
For example::
For example::
customizer = {'mpi_runner': 'mpich',
'runner_name': 'wrapper -x mpich'}
customizer = {'mpi_runner': 'mpich',
'runner_name': 'wrapper -x mpich'}
from libensemble.executors.mpi_executor import MPIExecutor
exctr = MPIExecutor(custom_info=customizer)
from libensemble.executors.mpi_executor import MPIExecutor
exctr = MPIExecutor(custom_info=customizer)
"""
Expand Down Expand Up @@ -336,6 +339,9 @@ def submit(
else:
mpi_runner_obj = self.mpi_runner_obj or self._create_mpi_runner_from_attr()

if env_script is None and mpi_runner_obj is None:
raise ExecutorException("No valid MPI runner was found")

mpi_specs = mpi_runner_obj.get_mpi_specs(
task,
num_procs,
Expand Down
12 changes: 7 additions & 5 deletions libensemble/executors/mpi_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ def get_runner(mpi_runner_type, runner_name=None, platform_info=None):
"msmpi": MSMPI_MPIRunner,
"custom": MPIRunner,
}
mpi_runner = mpi_runners[mpi_runner_type]
if runner_name is not None:
runner = mpi_runner(run_command=runner_name, platform_info=platform_info)
else:
runner = mpi_runner(platform_info=platform_info)
runner = None
if mpi_runner_type is not None:
mpi_runner = mpi_runners[mpi_runner_type]
if runner_name is not None:
runner = mpi_runner(run_command=runner_name, platform_info=platform_info)
else:
runner = mpi_runner(platform_info=platform_info)
return runner

def __init__(self, run_command="mpiexec", platform_info=None):
Expand Down

0 comments on commit f7270d5

Please sign in to comment.