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

Client-Server channel type. More...

#include <ClientServer.h>

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

Public Member Functions

 ClientServer (std::map< std::string, std::string > params)
 
void send (channel_data buf, FMI::Utils::peer_num dest) override
 Constructs file / key name based on sender and recipient and then uploads the data. More...
 
void recv (channel_data buf, FMI::Utils::peer_num dest) override
 Waits until the object with the expected file / key name appears (or a timeout occurs), then downloads it. More...
 
void bcast (channel_data buf, FMI::Utils::peer_num root) override
 Root uploads its data, all other peers download the object. More...
 
void barrier () override
 All peers upload a 1 byte file and wait until num_peers files (associated to this operation based on the file name) exist. More...
 
void reduce (channel_data sendbuf, channel_data recvbuf, FMI::Utils::peer_num root, raw_function f) override
 All peers upload their data. The root peer downloads these objects and applies the function (as soon as objects become available for associative / commutative functions, left-to-right otherwise) More...
 
void scan (channel_data sendbuf, channel_data recvbuf, raw_function f) override
 All peers upload their data and download the needed files to apply the function. Left-to-right evaluation order is enforced for non-commutative / non-associative functions. More...
 
virtual void upload_object (channel_data buf, std::string name)=0
 Function to upload data with a given name / key to the server, needs to be implemented by the channels and should never be invoked directly (use upload instead). More...
 
virtual bool download_object (channel_data buf, std::string name)=0
 Function to download data with a given name / key from the server, needs to be implemented by the channels. Returns true when download was successful, false when file does not exist. More...
 
virtual void download (channel_data buf, std::string name)
 Try the download (using download_object) until the object appears or the timeout was reached. More...
 
virtual void upload (channel_data buf, std::string name)
 Uploads objects and keeps track of them. More...
 
virtual std::vector< std::string > get_object_names ()=0
 List all the currently existing objects, needs to be implemented by channels. Needed by some collectives that check for the existence of files, but do not care about their content. More...
 
virtual void delete_object (std::string name)=0
 Delete the object with the given name, needs to be implemented by channels. More...
 
void finalize () override
 Deletes all objects that were created during the execution. 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
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 allreduce (channel_data sendbuf, channel_data recvbuf, raw_function f)
 Apply function f to sendbuf of all peers, make result available to everyone. 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 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 Attributes

std::map< std::string, unsigned int > num_operations
 Ensures that there are no file / key name conflicts when a collective operation is used multiple times, values are integrated into the file / key name for these operations. More...
 
std::vector< std::string > created_objects
 Tracks all created objects such that they can be selectively deleted when finalize is called. More...
 
unsigned int timeout
 Backoff time when an object does not exist. More...
 
unsigned int max_timeout
 Maximum time to wait until an object appears, exception is thrown when this value is exceeded. 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...
 

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...
 

Detailed Description

Client-Server channel type.

This class provides optimized collectives for client-server channels and defines the interface that these channels need to implement.

Constructor & Destructor Documentation

◆ ClientServer()

FMI::Comm::ClientServer::ClientServer ( std::map< std::string, std::string >  params)
explicit

Member Function Documentation

◆ barrier()

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

All peers upload a 1 byte file and wait until num_peers files (associated to this operation based on the file name) exist.

Implements FMI::Comm::Channel.

◆ bcast()

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

Root uploads its data, all other peers download the object.

Implements FMI::Comm::Channel.

◆ delete_object()

virtual void FMI::Comm::ClientServer::delete_object ( std::string  name)
pure virtual

Delete the object with the given name, needs to be implemented by channels.

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

◆ download()

void FMI::Comm::ClientServer::download ( channel_data  buf,
std::string  name 
)
virtual

Try the download (using download_object) until the object appears or the timeout was reached.

◆ download_object()

virtual bool FMI::Comm::ClientServer::download_object ( channel_data  buf,
std::string  name 
)
pure virtual

Function to download data with a given name / key from the server, needs to be implemented by the channels. Returns true when download was successful, false when file does not exist.

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

◆ finalize()

void FMI::Comm::ClientServer::finalize ( )
overridevirtual

Deletes all objects that were created during the execution.

Reimplemented from FMI::Comm::Channel.

◆ get_object_names()

virtual std::vector< std::string > FMI::Comm::ClientServer::get_object_names ( )
pure virtual

List all the currently existing objects, needs to be implemented by channels. Needed by some collectives that check for the existence of files, but do not care about their content.

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

◆ get_operation_latency()

double FMI::Comm::ClientServer::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::ClientServer::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::ClientServer::recv ( channel_data  buf,
FMI::Utils::peer_num  dest 
)
overridevirtual

Waits until the object with the expected file / key name appears (or a timeout occurs), then downloads it.

Implements FMI::Comm::Channel.

◆ reduce()

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

All peers upload their data. The root peer downloads these objects and applies the function (as soon as objects become available for associative / commutative functions, left-to-right otherwise)

Implements FMI::Comm::Channel.

◆ scan()

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

All peers upload their data and download the needed files to apply the function. Left-to-right evaluation order is enforced for non-commutative / non-associative functions.

Implements FMI::Comm::Channel.

◆ send()

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

Constructs file / key name based on sender and recipient and then uploads the data.

Implements FMI::Comm::Channel.

◆ upload()

void FMI::Comm::ClientServer::upload ( channel_data  buf,
std::string  name 
)
virtual

Uploads objects and keeps track of them.

◆ upload_object()

virtual void FMI::Comm::ClientServer::upload_object ( channel_data  buf,
std::string  name 
)
pure virtual

Function to upload data with a given name / key to the server, needs to be implemented by the channels and should never be invoked directly (use upload instead).

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

Member Data Documentation

◆ created_objects

std::vector<std::string> FMI::Comm::ClientServer::created_objects
protected

Tracks all created objects such that they can be selectively deleted when finalize is called.

◆ max_timeout

unsigned int FMI::Comm::ClientServer::max_timeout
protected

Maximum time to wait until an object appears, exception is thrown when this value is exceeded.

◆ num_operations

std::map<std::string, unsigned int> FMI::Comm::ClientServer::num_operations
protected
Initial value:
= {
{"bcast", 0},
{"barrier", 0},
{"reduce", 0},
{"scan", 0}
}

Ensures that there are no file / key name conflicts when a collective operation is used multiple times, values are integrated into the file / key name for these operations.

◆ timeout

unsigned int FMI::Comm::ClientServer::timeout
protected

Backoff time when an object does not exist.


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