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

Function get_group_masters

python/simulation.py:6283–6307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6281
6282
6283def get_group_masters():
6284 # Lazy import
6285 from mpi4py import MPI
6286
6287 comm = MPI.COMM_WORLD
6288 num_workers = comm.Get_size()
6289 num_groups = mp.get_num_groups
6290
6291 # Check if current worker is a group master
6292 is_group_master = True if mp.my_rank() == 0 else False
6293 group_master_idx = np.zeros((num_workers,), dtype=np.bool_)
6294
6295 # Formulate send and receive packets
6296 smsg = [np.array([is_group_master]), ([1] * num_workers, [0] * num_workers)]
6297 rmsg = [group_master_idx, ([1] * num_workers, list(range(num_workers)))]
6298
6299 # Send and receive
6300 comm.Alltoallv(smsg, rmsg)
6301
6302 # get rank of each group master
6303 group_masters = np.arange(num_workers)[
6304 group_master_idx
6305 ] # rank index of each group leader
6306
6307 return group_masters
6308
6309
6310def merge_subgroup_data(data):

Callers 1

merge_subgroup_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected