Skip to content
Snippets Groups Projects
Commit d6843871 authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

fix mpi bridge

parent 0a4aa2d8
No related branches found
No related tags found
2 merge requests!24Resolve "Add python3.x support",!15WIP: Resolve "HySoP with tasks"
...@@ -376,10 +376,15 @@ class BridgeOverlap(Bridge): ...@@ -376,10 +376,15 @@ class BridgeOverlap(Bridge):
def _build_send_recv_dict(self): def _build_send_recv_dict(self):
# Compute local intersections : i.e. find which grid points # Compute local intersections : i.e. find which grid points
# are on both source and target mesh. # are on both source and target mesh.
indices_source = TopoTools.gather_global_indices_overlap( # Filter out the empty slices (due to none topologies)
self._source, self.comm, self.domain) indices_source = dict([(rk, sl) for rk, sl in
indices_target = TopoTools.gather_global_indices_overlap( TopoTools.gather_global_indices_overlap(
self._target, self.comm, self.domain) self._source, self.comm, self.domain).iteritems()
if not all([_ == slice(0, 0) for _ in sl])])
indices_target = dict([(rk, sl) for rk, sl in
TopoTools.gather_global_indices_overlap(
self._target, self.comm, self.domain).iteritems()
if not all([_ == slice(0, 0) for _ in sl])])
# From now on, we have indices_source[rk] = global indices (slice) # From now on, we have indices_source[rk] = global indices (slice)
# of grid points of the source on process number rk in parent. # of grid points of the source on process number rk in parent.
......
...@@ -74,9 +74,7 @@ class TopoTools(object): ...@@ -74,9 +74,7 @@ class TopoTools(object):
if root is None: if root is None:
comm.Allgather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT]) comm.Allgather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT])
else: else:
comm.Gather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT], comm.Gather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT], root=root)
root=root)
if toslice: if toslice:
return Utils.array_to_dict(iglob_res) return Utils.array_to_dict(iglob_res)
else: else:
...@@ -133,19 +131,18 @@ class TopoTools(object): ...@@ -133,19 +131,18 @@ class TopoTools(object):
size = comm.Get_size() size = comm.Get_size()
rank = comm.Get_rank() rank = comm.Get_rank()
dimension = dom.dim dimension = dom.dim
iglob = npw.integer_zeros((size, dimension * 2)) iglob = npw.integer_zeros((dimension * 2, size), order='F')
iglob_res = npw.integer_zeros((size, dimension * 2)) iglob_res = npw.integer_zeros((dimension * 2, size), order='F')
iglob[0::2, rank] = 0
iglob[1::2, rank] = -1 iglob[1::2, rank] = -1
if root is None: if root is None:
comm.Allgather([iglob[rank, :], MPI.INT], [iglob_res, MPI.INT]) comm.Allgather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT])
else: else:
comm.Gather([iglob[rank, :], MPI.INT], [iglob_res, MPI.INT], comm.Gather([iglob[:, rank], MPI.INT], [iglob_res, MPI.INT], root=root)
root=root)
if toslice: if toslice:
return Utils.array_to_dict(iglob_res.T) return Utils.array_to_dict(iglob_res)
else: else:
return iglob_res.T return iglob_res
else: else:
return TopoTools.gather_global_indices(topo, toslice, root, comm) return TopoTools.gather_global_indices(topo, toslice, root, comm)
...@@ -286,8 +283,6 @@ class TopoTools(object): ...@@ -286,8 +283,6 @@ class TopoTools(object):
basetype = dtype_to_mpi_type(dtype) basetype = dtype_to_mpi_type(dtype)
subtype = basetype.Create_subarray(shape, subshape, substart, order=order) subtype = basetype.Create_subarray(shape, subshape, substart, order=order)
subtype.Commit() subtype.Commit()
# print 'MPI_Create_subarray(shape={}, subshape={}, substart={}, order={})'.format(
# shape, subshape, substart, 'C' if order is MPI.ORDER_C else 'F')
return subtype return subtype
@staticmethod @staticmethod
......
...@@ -100,7 +100,7 @@ class Problem(ComputationalGraph): ...@@ -100,7 +100,7 @@ class Problem(ComputationalGraph):
msg += '\n If this is required, override check_unique_clenv().' msg += '\n If this is required, override check_unique_clenv().'
raise RuntimeError(msg) raise RuntimeError(msg)
def initialize_field(self, field, **kwds): def initialize_field(self, field, mpi_params=None, **kwds):
"""Initialize a field on all its input and output topologies.""" """Initialize a field on all its input and output topologies."""
initialized = set() initialized = set()
for op in self.nodes: for op in self.nodes:
...@@ -113,6 +113,9 @@ class Problem(ComputationalGraph): ...@@ -113,6 +113,9 @@ class Problem(ComputationalGraph):
if all((df in initialized) for df in dfield.discrete_fields()): if all((df in initialized) for df in dfield.discrete_fields()):
# all contained scalar fields were already initialized # all contained scalar fields were already initialized
continue continue
elif mpi_params and mpi_params.task_id != dfield.topology.task_id:
# Topology task does not matches given mpi_params task
continue
else: else:
components = () components = ()
for (component, scalar_dfield) in dfield.nd_iter(): for (component, scalar_dfield) in dfield.nd_iter():
......
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