Skip to content
Snippets Groups Projects
Commit 13606efe authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Add pytools.mpi: Runs a callable with a given number of MPI ranks.

parent 0ec82486
No related branches found
No related tags found
Loading
def run_with_mpi_ranks(py_script, ranks, callable, *args, **kwargs):
import os
if "BOOSTMPI_RUN_WITHIN_MPI" in os.environ:
callable(*args, **kwargs)
else:
import sys
newenv = os.environ.copy()
newenv["BOOSTMPI_RUN_WITHIN_MPI"] = "1"
from subprocess import check_call
check_call(["mpirun", "-np", str(ranks),
sys.executable, py_script], env=newenv)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment