MPIActor

The class is specific implementation of Actor class using MPI.

The MPIActor implements 2 internal methods:

  • __getattr__() – transmits an access responsibility to the methods of native MPI Actor, held by this class, to MPIActorMethod class.

  • _remote() – creates native MPI Actor object to be held by this class.

API

class unidist.core.backends.mpi.actor.MPIActor(cls, num_cpus, resources, actor_handle=None)

The class implements the interface in Actor using MPI backend.

Parameters:
  • cls (object) – Class to be an actor class.

  • num_cpus (int) – The number of CPUs to reserve for the lifetime of the actor.

  • resources (dict) – Custom resources to reserve for the lifetime of the actor.

  • actor_handle (None or unidist.core.backends.mpi.core.Actor) – Used for proper serialization/deserialization via __reduce__.

classmethod _deserialization_helper(state)

Helper to restore the state of the object.

This is defined to make pickling work via __reduce__.

Parameters:

state (dict) – The serialized state of the object.

Return type:

MPIActor

_remote(*args, num_cpus=None, resources=None, **kwargs)

Create actor class, specific for MPI backend, from self._cls.

Parameters:
  • *args (iterable) – Positional arguments to be passed in self._cls class constructor.

  • num_cpus (int, optional) – The number of CPUs to reserve for the lifetime of the actor.

  • resources (dict, optional) – Custom resources to reserve for the lifetime of the actor.

  • **kwargs (dict) – Keyword arguments to be passed in self._cls class constructor.

Return type:

MPIActor

_serialization_helper()

Helper to save the state of the object.

This is defined to make pickling work via __reduce__.

Returns:

A dictionary of the information needed to reconstruct the object.

Return type:

dict

MPIActorMethod

The class is specific implementation of ActorMethod class using MPI.

The MPIActorMethod implements internal method _remote() that is responsible for calls of native MPI Actor class methods.

API

class unidist.core.backends.mpi.actor.MPIActorMethod(cls, method_name)

The class implements the interface in ActorMethod using MPI backend.

Parameters:
  • cls (unidist.core.backends.mpi.core.Actor) – An actor class from which method method_name will be called.

  • method_name (str) – The name of the method to be called.

_remote(*args, num_returns=None, **kwargs)

Execute self._method_name in a worker process.

Parameters:
  • *args (iterable) – Positional arguments to be passed in the method.

  • num_returns (int, optional) – Number of results to be returned. If it isn’t provided, self._num_returns will be used.

  • **kwargs (dict) – Keyword arguments to be passed in the method.

Returns:

Type of returns depends on num_returns value:

  • if num_returns == 1, ObjectRef will be returned.

  • if num_returns > 1, list of ObjectRef-s will be returned.

  • if num_returns == 0, None will be returned.

Return type:

ObjectRef, list or None