FMI 1.0
FaaS Message Interface
Public Member Functions | Protected Member Functions | List of all members
FMI::Comm::PeerToPeer Class Referenceabstract

Peer-To-Peer channel type. More...

#include <PeerToPeer.h>

Inheritance diagram for FMI::Comm::PeerToPeer:
Inheritance graph
Collaboration diagram for FMI::Comm::PeerToPeer:
Collaboration graph

Public Member Functions

void send (channel_data buf, FMI::Utils::peer_num dest) override
 Send data to peer with id dest, must match a recv call. More...
 
void recv (channel_data buf, FMI::Utils::peer_num src) override
 Receive data from peer with id src, must match a send call. More...
 
void bcast (channel_data buf, FMI::Utils::peer_num root) override
 Binomial tree broadcast implementation. More...
 
void barrier () override
 Calls allreduce with a (associative and commutative) NOP operation. More...
 
void gather (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root) override
 Binomial tree gather. More...
 
void scatter (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root) override
 Binomial tree scatter. More...
 
void reduce (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root, raw_function f) override
 Calls reduce_no_order for associative and commutative functions, reduce_ltr otherwise. More...
 
void allreduce (channel_data sendbuf, channel_data recvbuf, raw_function f) override
 For associative and commutative functions, allreduce_no_order is called. Otherwise, reduce followed by bcast is used. More...
 
void scan (channel_data sendbuf, channel_data recvbuf, raw_function f) override
 For associative and commutative functions, scan_no_order is called. Otherwise, scan_ltr is called. More...
 
virtual void send_object (channel_data buf, Utils::peer_num peer_id)=0
 Send an object to peer with ID peer_id. Needs to be implemented by the channels. More...
 
virtual void recv_object (channel_data buf, Utils::peer_num peer_id)=0
 Receive an object from peer with ID peer_id. Needs to be implemented by the channels. More...
 
double get_operation_latency (Utils::OperationInfo op_info) override
 Performance model for collective operations, provides the latency for the given operation. More...
 
double get_operation_price (Utils::OperationInfo op_info) override
 Cost model for collective operations, provides the price for the given operation. More...
 
- Public Member Functions inherited from FMI::Comm::Channel
void set_peer_id (FMI::Utils::peer_num num)
 Helper utility to set peer id, ID needs to be set before first collective operation. More...
 
void set_num_peers (FMI::Utils::peer_num num)
 Helper utility to set number of peers, needs to be set before first collective operation. More...
 
void set_comm_name (std::string communication_name)
 Helper utility to set the communicator name, should be set before first collective operation to avoid conflicts with empty communicator name. More...
 
virtual void finalize ()
 Called before communicator is destructed, can be used by channels to clean up (e.g., delete resources) More...
 
virtual double get_latency (Utils::peer_num producer, Utils::peer_num consumer, std::size_t size_in_bytes)=0
 Performance model of an individual channel, provides latency for a simple exchange with a number of producers / consumers. More...
 
virtual double get_price (Utils::peer_num producer, Utils::peer_num consumer, std::size_t size_in_bytes)=0
 Cost model of an individual channel, provides price for a simple exchange with a number of producers / consumers. More...
 

Protected Member Functions

void reduce_ltr (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root, const raw_function &f)
 Reduction with left-to-right evaluation, gather followed by a function evaluation on the root peer. More...
 
void reduce_no_order (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root, const raw_function &f)
 Binomial tree reduction where all peers apply the function in every step. More...
 
void allreduce_no_order (channel_data sendbuf, channel_data recvbuf, const raw_function &f)
 Recursive doubling allreduce implementation. When num_peers is not a power of two, there is an additional message in the beginning and end for every peer where they send their value / receive the reduced value. More...
 
void scan_ltr (channel_data sendbuf, channel_data recvbuf, const raw_function &f)
 Linear function application / sending. More...
 
void scan_no_order (channel_data sendbuf, channel_data recvbuf, const raw_function &f)
 Binomial tree with up- and down-phase. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from FMI::Comm::Channel
static std::shared_ptr< Channelget_channel (std::string name, std::map< std::string, std::string > params, std::map< std::string, std::string > model_params)
 Create a new channel with the given config and model params. More...
 
- Protected Attributes inherited from FMI::Comm::Channel
FMI::Utils::peer_num peer_id
 
FMI::Utils::peer_num num_peers
 
std::string comm_name
 Can optionally be used by channels to avoid resource conflicts that may occur because of multiple concurrent communicators. More...
 

Detailed Description

Peer-To-Peer channel type.

This class provides optimized collectives for channels where clients can address each other directly and defines the interface that these channels need to implement.

Member Function Documentation

◆ allreduce()

void FMI::Comm::PeerToPeer::allreduce ( channel_data  sendbuf,
channel_data  recvbuf,
raw_function  f 
)
overridevirtual

For associative and commutative functions, allreduce_no_order is called. Otherwise, reduce followed by bcast is used.

Reimplemented from FMI::Comm::Channel.

◆ allreduce_no_order()

void FMI::Comm::PeerToPeer::allreduce_no_order ( channel_data  sendbuf,
channel_data  recvbuf,
const raw_function f 
)
protected

Recursive doubling allreduce implementation. When num_peers is not a power of two, there is an additional message in the beginning and end for every peer where they send their value / receive the reduced value.

◆ barrier()

void FMI::Comm::PeerToPeer::barrier ( )
overridevirtual

Calls allreduce with a (associative and commutative) NOP operation.

Implements FMI::Comm::Channel.

◆ bcast()

void FMI::Comm::PeerToPeer::bcast ( channel_data  buf,
FMI::Utils::peer_num  root 
)
overridevirtual

Binomial tree broadcast implementation.

Implements FMI::Comm::Channel.

◆ gather()

void FMI::Comm::PeerToPeer::gather ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root 
)
overridevirtual

Binomial tree gather.

In the beginning, the needed buffer size (largest value that this peer will receive) is determined and a buffer is allocated. If the ID of the root is not 0, we cannot necessarily receive all values directly in recvbuf because we need to wrap around (e.g., when we get from peer N - 1 the values for N - 1, 0, and 1). This is solved by allocating a temporary buffer and copying the values.

Reimplemented from FMI::Comm::Channel.

◆ get_operation_latency()

double FMI::Comm::PeerToPeer::get_operation_latency ( Utils::OperationInfo  op_info)
overridevirtual

Performance model for collective operations, provides the latency for the given operation.

Implements FMI::Comm::Channel.

◆ get_operation_price()

double FMI::Comm::PeerToPeer::get_operation_price ( Utils::OperationInfo  op_info)
overridevirtual

Cost model for collective operations, provides the price for the given operation.

Implements FMI::Comm::Channel.

◆ recv()

void FMI::Comm::PeerToPeer::recv ( channel_data  buf,
FMI::Utils::peer_num  src 
)
overridevirtual

Receive data from peer with id src, must match a send call.

Implements FMI::Comm::Channel.

◆ recv_object()

virtual void FMI::Comm::PeerToPeer::recv_object ( channel_data  buf,
Utils::peer_num  peer_id 
)
pure virtual

Receive an object from peer with ID peer_id. Needs to be implemented by the channels.

Implemented in FMI::Comm::Direct.

◆ reduce()

void FMI::Comm::PeerToPeer::reduce ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root,
raw_function  f 
)
overridevirtual

Calls reduce_no_order for associative and commutative functions, reduce_ltr otherwise.

Implements FMI::Comm::Channel.

◆ reduce_ltr()

void FMI::Comm::PeerToPeer::reduce_ltr ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root,
const raw_function f 
)
protected

Reduction with left-to-right evaluation, gather followed by a function evaluation on the root peer.

◆ reduce_no_order()

void FMI::Comm::PeerToPeer::reduce_no_order ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root,
const raw_function f 
)
protected

Binomial tree reduction where all peers apply the function in every step.

◆ scan()

void FMI::Comm::PeerToPeer::scan ( channel_data  sendbuf,
channel_data  recvbuf,
raw_function  f 
)
overridevirtual

For associative and commutative functions, scan_no_order is called. Otherwise, scan_ltr is called.

Implements FMI::Comm::Channel.

◆ scan_ltr()

void FMI::Comm::PeerToPeer::scan_ltr ( channel_data  sendbuf,
channel_data  recvbuf,
const raw_function f 
)
protected

Linear function application / sending.

◆ scan_no_order()

void FMI::Comm::PeerToPeer::scan_no_order ( channel_data  sendbuf,
channel_data  recvbuf,
const raw_function f 
)
protected

Binomial tree with up- and down-phase.

◆ scatter()

void FMI::Comm::PeerToPeer::scatter ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root 
)
overridevirtual

Binomial tree scatter.

Similarly to gather, the root may need to send values from its sendbuf that is not consecutive when its ID is not 0, which is solved with a temporary buffer.

Reimplemented from FMI::Comm::Channel.

◆ send()

void FMI::Comm::PeerToPeer::send ( channel_data  buf,
FMI::Utils::peer_num  dest 
)
overridevirtual

Send data to peer with id dest, must match a recv call.

Implements FMI::Comm::Channel.

◆ send_object()

virtual void FMI::Comm::PeerToPeer::send_object ( channel_data  buf,
Utils::peer_num  peer_id 
)
pure virtual

Send an object to peer with ID peer_id. Needs to be implemented by the channels.

Implemented in FMI::Comm::Direct.


The documentation for this class was generated from the following files: