MCPcopy Create free account
hub / github.com/NanoComp/meep / merge_subgroup_data

Function merge_subgroup_data

python/simulation.py:6310–6351  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

6308
6309
6310def merge_subgroup_data(data):
6311 # Lazy import
6312 from mpi4py import MPI
6313
6314 comm = MPI.COMM_WORLD
6315 num_workers = comm.Get_size()
6316 num_groups = get_num_groups()
6317
6318 # Initialize new input and output datasets
6319 input = np.array(data, copy=True, order="F")
6320 shape = input.shape
6321 size = input.size
6322 out_shape = shape + (num_groups,)
6323 output = np.zeros(out_shape, input.dtype, order="F")
6324
6325 # Get group masters
6326 group_masters = get_group_masters()
6327
6328 # Specify how much talking each proc will do. Only group masters send data.
6329 if mp.my_rank() == 0:
6330 scount = np.array([size] * num_workers)
6331 else:
6332 scount = np.array([0] * num_workers)
6333 rcount = np.array([0] * num_workers)
6334 rcount[group_masters] = size
6335
6336 # Specify array mapping
6337 sdsp = [0] * num_workers
6338 rdsp = [0] * num_workers
6339 buf_idx = 0
6340 for grpidx in group_masters:
6341 rdsp[grpidx] = buf_idx # offset group leader worker by size of each count
6342 buf_idx += size
6343
6344 # Formulate send and receive packets
6345 smsg = [input, (scount, sdsp)]
6346 rmsg = [output, (rcount, rdsp)]
6347
6348 # Send and receive
6349 comm.Alltoallv(smsg, rmsg)
6350
6351 return output
6352
6353
6354class BinaryPartition:

Callers

nothing calls this directly

Calls 2

get_num_groupsFunction · 0.85
get_group_mastersFunction · 0.85

Tested by

no test coverage detected