def run(self, b, compute, times=[], **kwargs):
        """
        if within mpirun, workers should call _run_worker instead of run
        """
        self.run_checks(b, compute, times, **kwargs)

        logger.debug("rank:{}/{} calling get_packet_and_syns".format(mpi.myrank, mpi.nprocs))
        packet, new_syns = self.get_packet_and_syns(b, compute, times, **kwargs)

        if mpi.enabled:
            # broadcast the packet to ALL workers
            mpi.comm.bcast(packet, root=0)

            # now even the master can become a worker and take on a chunk
            packet['b'] = b
            rpacketlists = self._run_chunk(**packet)

            # now receive all packetlists
            rpacketlists_per_worker = mpi.comm.gather(rpacketlists, root=0)

        else:
            rpacketlists_per_worker = [self._run_chunk(**packet)]

        return self._fill_syns(new_syns, rpacketlists_per_worker)
def run ( self , b , compute , times = [ ] , ** kwargs ) : self . run_checks ( b , compute , times , ** kwargs ) logger . debug ( "rank:{}/{} calling get_packet_and_syns" . format ( mpi . myrank , mpi . nprocs ) ) packet , new_syns = self . get_packet_and_syns ( b , compute , times , ** kwargs ) if mpi . enabled : mpi . comm . bcast ( packet , root = 0 ) packet [ 'b' ] = b rpacketlists = self . _run_chunk ( ** packet ) rpacketlists_per_worker = mpi . comm . gather ( rpacketlists , root = 0 ) else : rpacketlists_per_worker = [ self . _run_chunk ( ** packet ) ] return self . _fill_syns ( new_syns , rpacketlists_per_worker )
if within mpirun, workers should call _run_worker instead of run