cicada.communicator.interface module
Defines abstract interfaces for network communication.
- class cicada.communicator.interface.Communicator[source]
Bases:
object
Abstract base class for objects that manage collective communications for secure multiparty computation.
- abstract allgather(value)[source]
All-to-all communication.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- abstract barrier()[source]
Block the local process until all players have entered the barrier.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- abstract broadcast(*, src, value)[source]
One-to-all communication.
The src player broadcasts a single object to all players.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- abstract free()[source]
Free the communicator.
This should be called if the communicator is no longer needed so that resources can be freed. Note that communicators cannot be reused after they have been freed, a new communicator must be created instead.
- abstract gather(*, value, dst)[source]
All-to-one communication.
Every player sends a value to dst.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- Parameters:
- Returns:
values – For the destination player, a sequence of world_size objects received from every player in rank order. For all other players, None.
- Return type:
sequence of
object
or None
- abstract gatherv(*, src, value, dst)[source]
Many-to-one communication.
A subset of players each sends a value to dst.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- abstract irecv(*, src, tag)[source]
Non-blocking one-to-one communication.
One player (the sender) sends an object to one player (the destination).
Note
Unlike collective operations, this method is only called by the receiver. It must be matched by a call to
send()
by the sender.See also
recv
Blocking one-to-one communication.
- Parameters:
- Returns:
result – A special result object that can be used to wait for and access the value sent by the sender. The result object will have a property is_completed which returns a boolean value indicating whether the result has been received; method wait, which will block indefinitely until the result is received; and property value which returns the received value or raises an exception if the value has not been received yet.
- Return type:
- abstract isend(*, value, dst, tag)[source]
Non-blocking one-to-one communication.
One player (the sender) sends an object to one player (the destination).
Note
Unlike collective operations, this method is only called by the sender. It must be matched by a call to
recv()
by the destination.See also
send
Blocking one-to-one communication.
- Parameters:
- Returns:
result – A special result object that can be used to wait until the message has been sent. The result object will have a property is_completed which returns a boolean value indicating whether the result has been sent; and a method wait which will block until the message is sent.
- Return type:
- abstract property rank
Rank of the local player.
- Returns:
rank – Player rank, in the range \([0, \text{world_size})\).
- Return type:
- property ranks
List of all ranks managed by this communicator.
- Returns:
ranks – The set of all ranks managed by this communicator.
- Return type:
sequence of
int
- abstract recv(*, src, tag)[source]
Blocking one-to-one communication.
One player (the sender) sends an object to one player (the destination).
Note
Unlike collective operations, this method is only called by the receiver. It must be matched by a call to
send()
by the sender.See also
irecv
Non-blocking one-to-one communication.
- abstract scatter(*, src, values)[source]
One-to-all communication.
One player (the sender) sends a different object to every player.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- abstract scatterv(*, src, values, dst)[source]
One-to-many communication.
One player (the sender) sends a different object to each in a subset of players.
Note
This method is a collective operation that must be called by all players that are members of the communicator.
- Parameters:
- Returns:
value – The object received by this player, or None if this player wasn’t in the list of recipients.
- Return type:
object
or None
- abstract send(value, dst, tag)[source]
Blocking one-to-one communication.
One player (the sender) sends an object to one player (the destination).
Note
Unlike collective operations, this method is only called by the sender. It must be matched by a call to
recv()
by the destination.See also
isend
Non-blocking one-to-one communication.
- class cicada.communicator.interface.Tag(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Message tags used internally by the library.
Callers can use these tags, or any other
int
, when callingCommunicator.send()
,Communicator.recv()
,Communicator.isend()
, andCommunicator.irecv()
. Note that negative integers are reserved for use by the library.- ALLGATHER = -1
- BARRIER = -2
- BEACON = -3
- BROADCAST = -4
- GATHER = -5
- GATHERV = -6
- LOGSYNC = -20
- PRZS = -30
- REVOKE = -7
- SCATTER = -8
- SCATTERV = -9
- SHRINK = -10