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

Interface that defines channel operations. Only provides a few default implementations, the rest is implemented in the specific ClientServer or PeerToPeer channel types. More...

#include <Channel.h>

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

Public Member Functions

virtual void send (channel_data buf, FMI::Utils::peer_num dest)=0
 Send data to peer with id dest, must match a recv call. More...
 
virtual void recv (channel_data buf, FMI::Utils::peer_num src)=0
 Receive data from peer with id src, must match a send call. More...
 
virtual void bcast (channel_data buf, FMI::Utils::peer_num root)=0
 Broadcast data. Buf only needs to contain useful data for root, the buffer is overwritten for all other peers. More...
 
virtual void barrier ()=0
 Barrier synchronization collective. More...
 
virtual void gather (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root)
 Root gathers data from all peers. More...
 
virtual void scatter (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root)
 Scatter data from root to all peers. More...
 
virtual void reduce (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root, raw_function f)=0
 Apply function f to sendbuf of all peers. More...
 
virtual void allreduce (channel_data sendbuf, channel_data recvbuf, raw_function f)
 Apply function f to sendbuf of all peers, make result available to everyone. More...
 
virtual void scan (channel_data sendbuf, channel_data recvbuf, raw_function f)=0
 Inclusive prefix scan, recvbuf / sendbuf needs to be set for all peers. More...
 
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...
 
virtual double get_operation_latency (Utils::OperationInfo op_info)=0
 Performance model for collective operations, provides the latency for the given operation. More...
 
virtual double get_operation_price (Utils::OperationInfo op_info)=0
 Cost model for collective operations, provides the price for the given operation. More...
 

Static Public Member Functions

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

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

Interface that defines channel operations. Only provides a few default implementations, the rest is implemented in the specific ClientServer or PeerToPeer channel types.

Member Function Documentation

◆ allreduce()

void FMI::Comm::Channel::allreduce ( channel_data  sendbuf,
channel_data  recvbuf,
raw_function  f 
)
virtual

Apply function f to sendbuf of all peers, make result available to everyone.

Provides a default implementation with a reduce, followed by a broadcast. Channel types / implementations can provide more optimized ones. The same considerations for the evaluation order (as with reduce) hold

Parameters
sendbufData that is sent by every peer
recvbufRelevant for all peers in contrast to reduce
f

Reimplemented in FMI::Comm::PeerToPeer.

◆ barrier()

virtual void FMI::Comm::Channel::barrier ( )
pure virtual

Barrier synchronization collective.

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ bcast()

virtual void FMI::Comm::Channel::bcast ( channel_data  buf,
FMI::Utils::peer_num  root 
)
pure virtual

Broadcast data. Buf only needs to contain useful data for root, the buffer is overwritten for all other peers.

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ finalize()

virtual void FMI::Comm::Channel::finalize ( )
inlinevirtual

Called before communicator is destructed, can be used by channels to clean up (e.g., delete resources)

Note that we provide an explicit finalize function on purpose (and do not use a virtual destructor), because derived classes may require that some values of parent classes still exist when cleaning up.

Reimplemented in FMI::Comm::ClientServer.

◆ gather()

void FMI::Comm::Channel::gather ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root 
)
virtual

Root gathers data from all peers.

Channel provides a default implementation where peers use send for sending the buffers to the root peer. Child classes may create more optimized implementations.

Parameters
sendbufData that is sent to the root
recvbufBuffer to receive data in, only relevant for root. Needs to have a size of (at least) num_peers * sendbuf.size

Reimplemented in FMI::Comm::PeerToPeer.

◆ get_channel()

std::shared_ptr< FMI::Comm::Channel > FMI::Comm::Channel::get_channel ( std::string  name,
std::map< std::string, std::string >  params,
std::map< std::string, std::string >  model_params 
)
static

Create a new channel with the given config and model params.

This function is only used for the bundled channels, all other should be instantiated outside of the framework and added over the Communicator interface.

◆ get_latency()

virtual double FMI::Comm::Channel::get_latency ( Utils::peer_num  producer,
Utils::peer_num  consumer,
std::size_t  size_in_bytes 
)
pure virtual

Performance model of an individual channel, provides latency for a simple exchange with a number of producers / consumers.

Implemented in FMI::Comm::Direct, FMI::Comm::Redis, and FMI::Comm::S3.

◆ get_operation_latency()

virtual double FMI::Comm::Channel::get_operation_latency ( Utils::OperationInfo  op_info)
pure virtual

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

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ get_operation_price()

virtual double FMI::Comm::Channel::get_operation_price ( Utils::OperationInfo  op_info)
pure virtual

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

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ get_price()

virtual double FMI::Comm::Channel::get_price ( Utils::peer_num  producer,
Utils::peer_num  consumer,
std::size_t  size_in_bytes 
)
pure virtual

Cost model of an individual channel, provides price for a simple exchange with a number of producers / consumers.

Implemented in FMI::Comm::Direct, FMI::Comm::Redis, and FMI::Comm::S3.

◆ recv()

virtual void FMI::Comm::Channel::recv ( channel_data  buf,
FMI::Utils::peer_num  src 
)
pure virtual

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

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ reduce()

virtual void FMI::Comm::Channel::reduce ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root,
raw_function  f 
)
pure virtual

Apply function f to sendbuf of all peers.

When f is not commutative / associative, a strict left-to-right evaluation order is guaranteed. Otherwise, the implementation is free to choose the order, but two executions with the same topology should result in the same order / result.

Parameters
sendbufData that is sent by every peer
recvbufOnly relevant for root. Needs to have the same size as sendbuf
fAssociativity / Commutativity of f controls choice of algorithm, depending on the channel / channel type

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ scan()

virtual void FMI::Comm::Channel::scan ( channel_data  sendbuf,
channel_data  recvbuf,
raw_function  f 
)
pure virtual

Inclusive prefix scan, recvbuf / sendbuf needs to be set for all peers.

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ scatter()

void FMI::Comm::Channel::scatter ( channel_data  sendbuf,
channel_data  recvbuf,
FMI::Utils::peer_num  root 
)
virtual

Scatter data from root to all peers.

Channel provides a default implementation where root sends the relevant slice to all peers, which use recv to receive it.

Parameters
sendbufOnly relevant for root, contains the data that is scattered and needs to have a (divisible) size of num_peers * recvbuf.size
recvbufBuffer to receive the data (of size sendbuf.size / num_peers), needs to be set by all peers

Reimplemented in FMI::Comm::PeerToPeer.

◆ send()

virtual void FMI::Comm::Channel::send ( channel_data  buf,
FMI::Utils::peer_num  dest 
)
pure virtual

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

Implemented in FMI::Comm::ClientServer, and FMI::Comm::PeerToPeer.

◆ set_comm_name()

void FMI::Comm::Channel::set_comm_name ( std::string  communication_name)
inline

Helper utility to set the communicator name, should be set before first collective operation to avoid conflicts with empty communicator name.

◆ set_num_peers()

void FMI::Comm::Channel::set_num_peers ( FMI::Utils::peer_num  num)
inline

Helper utility to set number of peers, needs to be set before first collective operation.

◆ set_peer_id()

void FMI::Comm::Channel::set_peer_id ( FMI::Utils::peer_num  num)
inline

Helper utility to set peer id, ID needs to be set before first collective operation.

Member Data Documentation

◆ comm_name

std::string FMI::Comm::Channel::comm_name
protected

Can optionally be used by channels to avoid resource conflicts that may occur because of multiple concurrent communicators.

For instance, the communicator name can be used as a prefix for key or file names. Some channels might not need this because other mechanisms exist, but every channel has to ensure that multiple concurrent communicators work as expected.

◆ num_peers

FMI::Utils::peer_num FMI::Comm::Channel::num_peers
protected

◆ peer_id

FMI::Utils::peer_num FMI::Comm::Channel::peer_id
protected

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