Commit 5272302e authored by Dion Häfner's avatar Dion Häfner

cleanup

parent ed0797c1
......@@ -186,6 +186,10 @@ Running Veros through MPI requires some addititonal dependencies:
After you have installed everything, you can start Veros on multiple processes like so:::
$ python my_setup.py -n 2 2
Or, by explicitly using mpirun (might be required on some architectures)::
$ mpirun -n 4 python my_setup.py -n 2 2
In this case, Veros would run on 4 processes, each process computing one-quarter of the domain. The arguments of the `-n` flag specify the number of chunks in x and y-direction, respectively.
......
......@@ -76,8 +76,9 @@ def cli(run):
@click.option('-p', '--profile-mode', is_flag=True, default=False, type=click.BOOL, envvar='VEROS_PROFILE',
help='Write a performance profile for debugging (default: false)')
@click.option('-n', '--num-proc', nargs=2, default=[1, 1], type=click.INT,
help='Number of processes in x and y dimension (requires execution via mpirun)')
@click.option('--slave', default=False, is_flag=True, hidden=True)
help='Number of processes in x and y dimension')
@click.option('--slave', default=False, is_flag=True, hidden=True,
help='Indicates that this process is an MPI worker (for internal use)')
@functools.wraps(run)
def wrapped(*args, slave, **kwargs):
from veros import runtime_settings, runtime_state
......@@ -94,7 +95,15 @@ def cli(run):
)
futures = [comm.irecv(source=p) for p in range(total_proc)]
while not all(f.test()[0] for f in futures):
while True:
done, success = zip(*(f.test() for f in futures))
if any(s is False for s in success):
raise RuntimeError('An MPI worker encountered an error')
if all(done):
break
time.sleep(0.1)
return
......@@ -106,8 +115,13 @@ def cli(run):
try:
run(*args, **kwargs)
except: # noqa: E722
status = False
raise
else:
status = True
finally:
if slave:
runtime_settings.mpi_comm.Get_parent().send(None, dest=0)
runtime_settings.mpi_comm.Get_parent().send(status, dest=0)
return wrapped
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment