Communicators

Communicator

class disropt.communicators.Communicator[source]

Communicator abstract class

neighbors_exchange(send_obj, in_neighbors, out_neighbors, dict_neigh, stop_event)[source]
Return type

Dict[int, Any]

neighbors_receive(neighbors, stop_event)[source]
Return type

Dict[int, Any]

neighbors_receive_asynchronous(neighbors)[source]
Return type

Dict[int, Any]

neighbors_send(obj, neighbors)[source]

MPICommunicator

class disropt.communicators.MPICommunicator[source]

Bases: disropt.communicators.communicators.Communicator

Communicator class that performs communications through MPI. Requires mpi4py.

comm

communication world

size

size of the network.

Type

int

rank

rank of the processor

Type

int

neighbors_exchange(send_obj, in_neighbors, out_neighbors, dict_neigh=False, stop_event=None)[source]

Exchange information (synchronously) with neighbors.

Parameters
  • send_obj (Any) – object to send

  • in_neighbors (List[int]) – list of in-neighbors

  • out_neighbors (List[int]) – list of out-neighbors

  • dict_neigh (bool) – True if send_obj contains a dictionary with different objects for each neighbor. Defaults to False

  • stop_event (Optional[Event]) – an Event object that is monitored during the execution. If the event is set, the function returns immediately. Defaults to None (does not wait upon any event)

Return type

Dict[int, Any]

Returns

data received by in-neighbors

neighbors_receive(neighbors, stop_event=None)[source]

Receive data from neighbors (waits until data are received from all neighbors).

Parameters
  • neighbors (List[int]) – list of in-neighbors

  • stop_event (Optional[Event]) – an Event object that is monitored during the execution. If the event is set, the function returns immediately. Defaults to None (does not wait upon any event)

Return type

Dict[int, Any]

Returns

data received by in-neighbors

neighbors_receive_asynchronous(neighbors)[source]

Receive data (if any) from neighbors.

Parameters

neighbors (List[int]) – list of in-neighbors

Return type

Dict[int, Any]

Returns

data received by in-neighbors (if any)

neighbors_send(obj, neighbors)[source]

Send data to neighbors.

Parameters
  • obj (Any) – object to send

  • neighbors (List[int]) – list of out-neighbors