# MPIRedirect class

Class containing a kind of RMI implementation over MPI.

class pypdevs.MPIRedirect.LocalRedirect(server)

  Local redirector class

  __getattr__(name)

    Determine whether or not we should redirect the call to the local or the remote server

    Parameters

      name – the name of the function to call

    Returns

      function – function to be actually called to perform the action

  __getinitargs__()

    For pickling

    Returns

      list containing the rank

  __getstate__()

    For pickling

    Returns

      dictionary containing the rank and the oneway list

  __init__(server)

    Constructor.

    Parameters

      server – the local server

  __setstate__(state)

    For pickling

    Parameters

      state – the dictionary provided by the __getstate__ method

  __weakref__

    list of weak references to the object (if defined)

  localCall(method, *args, **kwargs)

    Actually perform the local call

    Parameters

      method – the name of the method

    Returns

      the return value of the function, None if it is a oneway call

class pypdevs.MPIRedirect.MPIFaker

  A dummy implementation of MPI4Py if none is found

  static Get_rank()

    Return the rank of the current process in the MPI world. Always 0, since it is only used in cases where local simulation is done.

    Returns

      int – rank of the current process

  static Get_size()

    Return the size of the MPI world. Always 1, since it is only used in cases where local simulation is done.

    Returns

      int – number of MPI processes running

  __weakref__

    list of weak references to the object (if defined)

class pypdevs.MPIRedirect.MPIRedirect(rank)

  Redirect all calls to an instantiation of this class to the server for which it was created, uses MPI (or the dummy implementation).

  For speed, it contains an optimisation when the call is actually done locally (it will simply start a thread then). This complete implemenation is based on so called ‘magic functions’ from Python.

  __getattr__(name)

    Determine whether or not we should redirect the call to the local or the remote server

    Parameters

      name – the name of the function to call

    Returns

      function – function to be actually called to perform the action

  __getinitargs__()

    For pickling

    Returns

      list containing the rank

  __getstate__()

    For pickling

    Returns

      dictionary containing the rank and the oneway list

  __init__(rank)

    Constructor.

    Parameters

      - rank – the rank of the server to redirect the call to

      - oneways – iterable containing all functions that should be done without waiting for completion

  __setstate__(state)

    For pickling

    Parameters

      state – the dictionary provided by the __getstate__ method

  __weakref__

    list of weak references to the object (if defined)

  remoteCall(method, *args, **kwargs)

    Make the remote call

    Parameters

      method – method name to call (as a string)

    Returns

      return value of the called method; always None in case it is a one-way call

pypdevs.MPIRedirect.cleaning()

  Clean up the list of all waiting asynchronous connections

  Should be ran on a seperate thread and will simply wait on the connection status to be ‘complete’. This is necessary for the MPI specification.