better way to handle mpi
This commit is contained in:
+4
-7
@@ -4,16 +4,13 @@ import numpy as np
|
||||
from functools import partial
|
||||
from baseprocessor import Rule
|
||||
import snapshotprocessor
|
||||
|
||||
from mypool import MyPool
|
||||
|
||||
try:
|
||||
from mpi4py.futures import MPIPoolExecutor
|
||||
|
||||
mpi = True
|
||||
mpi_loaded = True
|
||||
except ModuleNotFoundError:
|
||||
from mypool import MyPool
|
||||
|
||||
mpi = False
|
||||
mpi_loaded = False
|
||||
|
||||
|
||||
def _map_aux(fun, path, path_out, params, run_num, **kwargs):
|
||||
@@ -57,7 +54,7 @@ class Aggregator:
|
||||
map_fn = partial(
|
||||
_map_aux, func, self.path, self.path_out, self.params, **kwargs
|
||||
)
|
||||
if mpi:
|
||||
if mpi_loaded and self.params.process.mpi:
|
||||
executor = MPIPoolExecutor(max_workers=num_process)
|
||||
try:
|
||||
result = list(executor.map(map_fn, run_num, unordered=True))
|
||||
|
||||
@@ -96,6 +96,8 @@ out: # Parameters for post processing
|
||||
process: # General setting of the post-processor module
|
||||
verbose : True # Give more infos on what is going on
|
||||
num_process : 1 # Number of forks
|
||||
mpi : False # If available, use mpi4py
|
||||
allow_error : False # Catch all errors in rules involving the disk
|
||||
save_cells : True # Save cells structure on disk
|
||||
save_parts : True # Save particles on disk
|
||||
unload_cells : True # Save memory usage
|
||||
@@ -105,6 +107,7 @@ rules: # Specific rules parameters
|
||||
|
||||
|
||||
astrophysix: # Parameters for astrophysix and galactica
|
||||
generate : False # Whether to generate astrophysix objects
|
||||
simu_fmt : "{tag}_{run}" # Format of the name of simulation
|
||||
descr_fmt : "{tag}_{run}" # Format of the default description
|
||||
# The following keys are accepted
|
||||
|
||||
Reference in New Issue
Block a user