Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def share(self, root=0):
"""
Share across MPI processes. (requires mpi4py to use).
All attributes are put in shared memory.
"""
if mpi is None:
raise ImportError("You need mpi4py to use this method. "
"Install it by running pip install pyuvsim[sim] "
"or pip install pyuvsim[all] if you also want the "
"line_profiler installed.")
mpi.start_mpi()
self.Ncomponents = mpi.world_comm.bcast(self.Ncomponents, root=root)
# Get list of attributes that are set.
isset = None
if mpi.rank == root:
isset = [key for key, value in self.__dict__.items() if value is not None]
isset = mpi.world_comm.bcast(isset, root=root)
for key in isset:
attr = getattr(self, key)
if key in self.put_in_shared:
val = mpi.shared_mem_bcast(attr, root=root)
else:
val = mpi.world_comm.bcast(attr, root=root)
if val is not None:
setattr(self, key, val)
Share across MPI processes. (requires mpi4py to use).
All attributes are put in shared memory.
"""
if mpi is None:
raise ImportError("You need mpi4py to use this method. "
"Install it by running pip install pyuvsim[sim] "
"or pip install pyuvsim[all] if you also want the "
"line_profiler installed.")
mpi.start_mpi()
self.Ncomponents = mpi.world_comm.bcast(self.Ncomponents, root=root)
# Get list of attributes that are set.
isset = None
if mpi.rank == root:
isset = [key for key, value in self.__dict__.items() if value is not None]
isset = mpi.world_comm.bcast(isset, root=root)
for key in isset:
attr = getattr(self, key)
if key in self.put_in_shared:
val = mpi.shared_mem_bcast(attr, root=root)
else:
val = mpi.world_comm.bcast(attr, root=root)
if val is not None:
setattr(self, key, val)
mpi.world_comm.Barrier()
"line_profiler installed.")
mpi.start_mpi()
self.Ncomponents = mpi.world_comm.bcast(self.Ncomponents, root=root)
# Get list of attributes that are set.
isset = None
if mpi.rank == root:
isset = [key for key, value in self.__dict__.items() if value is not None]
isset = mpi.world_comm.bcast(isset, root=root)
for key in isset:
attr = getattr(self, key)
if key in self.put_in_shared:
val = mpi.shared_mem_bcast(attr, root=root)
else:
val = mpi.world_comm.bcast(attr, root=root)
if val is not None:
setattr(self, key, val)
mpi.world_comm.Barrier()