Example #1
0
def _get_comm():
    """Get the correct MPI world object."""
    if 'mpi4py' in sys.modules:
        return MPI4PY()
    if '_gpaw' in sys.modules:
        import _gpaw
        if hasattr(_gpaw, 'Communicator'):
            return _gpaw.Communicator()
    return DummyMPI()
Example #2
0
def rank():
    # Check for special MPI-enabled Python interpreters:
    if '_gpaw' in sys.builtin_module_names:
        import _gpaw  # http://wiki.fysik.dtu.dk/gpaw
        world = _gpaw.Communicator()
    elif '_asap' in sys.builtin_module_names:
        import _asap  # http://wiki.fysik.dtu.dk/asap, can't import asap3.mpi here (import deadlock)
        world = _asap.Communicator()
    elif 'asapparallel3' in sys.modules:  # Older version of Asap
        import asapparallel3
        world = asapparallel3.Communicator()
    elif 'Scientific_mpi' in sys.modules:
        from Scientific.MPI import world
    elif 'mpi4py' in sys.modules:
        world = MPI4PY()
    else:
        world = DummyMPI()  # This is a standard Python interpreter:
    rank = world.rank
    size = world.size
    return rank
Example #3
0
        if not requests:
            return
        raise NotImplementedError('Calls to mpi waitall should not happen in '
                                  'serial mode')

    def get_members(self):
        return np.array([0])

    def get_c_object(self):
        raise NotImplementedError('Should not get C-object for serial comm')


serial_comm = SerialCommunicator()

try:
    world = _gpaw.Communicator()
except AttributeError:
    world = serial_comm

    
class DryRunCommunicator(SerialCommunicator):
    def __init__(self, size=1, parent=None):
        self.size = size
        self.parent = parent
    
    def new_communicator(self, ranks):
        return DryRunCommunicator(len(ranks), parent=self)

    def get_c_object(self):
        return None  # won't actually be passed to C