FMI 1.0
FaaS Message Interface
Public Member Functions | List of all members
FMI::Communicator Class Reference

Interface that is exposed to the user for interaction with the FMI system. More...

#include <Communicator.h>

Collaboration diagram for FMI::Communicator:
Collaboration graph

Public Member Functions

 Communicator (FMI::Utils::peer_num peer_id, FMI::Utils::peer_num num_peers, std::string config_path, std::string comm_name, unsigned int faas_memory=128)
 
 ~Communicator ()
 Finalizes all active channels. More...
 
template<typename T >
void send (Comm::Data< T > &buf, FMI::Utils::peer_num dest)
 Send buf to peer dest. More...
 
template<typename T >
void recv (Comm::Data< T > &buf, FMI::Utils::peer_num src)
 Receive data from src and store data into the provided buf. More...
 
template<typename T >
void bcast (Comm::Data< T > &buf, FMI::Utils::peer_num root)
 Broadcast the data that is in the provided buf of the root peer. Result is stored in buf for all peers. More...
 
void barrier ()
 Barrier synchronization collective. More...
 
template<typename T >
void gather (Comm::Data< T > &sendbuf, Comm::Data< T > &recvbuf, FMI::Utils::peer_num root)
 Gather the data of the individuals peers (in sendbuf) into the recvbuf of root. More...
 
template<typename T >
void scatter (Comm::Data< T > &sendbuf, Comm::Data< T > &recvbuf, FMI::Utils::peer_num root)
 Scatter the data from root's sendbuf to the recvbuf of all peers. More...
 
template<typename T >
void reduce (Comm::Data< T > &sendbuf, Comm::Data< T > &recvbuf, FMI::Utils::peer_num root, FMI::Utils::Function< T > f)
 Perform a reduction with the reduction function f. More...
 
template<typename T >
void allreduce (Comm::Data< T > &sendbuf, Comm::Data< T > &recvbuf, FMI::Utils::Function< T > f)
 Perform a reduction with the reduction function f and make the result available to all peers. More...
 
template<typename T >
void scan (Comm::Data< T > &sendbuf, Comm::Data< T > &recvbuf, FMI::Utils::Function< T > f)
 Inclusive prefix scan. More...
 
void register_channel (std::string name, std::shared_ptr< FMI::Comm::Channel >)
 Add a new channel to the communicator with the given name by providing a pointer to it. More...
 
void set_channel_policy (std::shared_ptr< FMI::Utils::ChannelPolicy > policy)
 Change the channel policy the communicator is using. More...
 
void hint (FMI::Utils::Hint hint)
 Set the hint (optimization objective) of the channel selection procedure. More...
 

Detailed Description

Interface that is exposed to the user for interaction with the FMI system.

Constructor & Destructor Documentation

◆ Communicator()

FMI::Communicator::Communicator ( FMI::Utils::peer_num  peer_id,
FMI::Utils::peer_num  num_peers,
std::string  config_path,
std::string  comm_name,
unsigned int  faas_memory = 128 
)
Parameters
peer_idID of the peer in the range [0 .. num_peers - 1]
num_peersNumber of peers participating in the communicator
config_pathPath to the FMI JSON configuration file
comm_nameName of the communicator, needs to be unique when multiple communicators are used concurrently
faas_memoryAmount of memory (in MiB) that is allocated to the function, used for performance model calculations.

◆ ~Communicator()

FMI::Communicator::~Communicator ( )

Finalizes all active channels.

Member Function Documentation

◆ allreduce()

template<typename T >
void FMI::Communicator::allreduce ( Comm::Data< T > &  sendbuf,
Comm::Data< T > &  recvbuf,
FMI::Utils::Function< T >  f 
)
inline

Perform a reduction with the reduction function f and make the result available to all peers.

Depending on the associativity / commutativity of f, a different implementation for the reduction may be used. However, in the same topology, the evaluation order should always be the same, irrespectively of the associativity / commutativitiy.

Parameters
sendbufData to send, relevant for all peers.
recvbufReceive buffer that contains the final result, relevant for all peers. Needs to have the same size as the sendbuf.

◆ barrier()

void FMI::Communicator::barrier ( )
inline

Barrier synchronization collective.

◆ bcast()

template<typename T >
void FMI::Communicator::bcast ( Comm::Data< T > &  buf,
FMI::Utils::peer_num  root 
)
inline

Broadcast the data that is in the provided buf of the root peer. Result is stored in buf for all peers.

◆ gather()

template<typename T >
void FMI::Communicator::gather ( Comm::Data< T > &  sendbuf,
Comm::Data< T > &  recvbuf,
FMI::Utils::peer_num  root 
)
inline

Gather the data of the individuals peers (in sendbuf) into the recvbuf of root.

Parameters
sendbufData to send to root, needs to be the same size for all peers.
recvbufReceive buffer, only relevant for the root process. Size needs to be num_peers * sendbuf.size

◆ hint()

void FMI::Communicator::hint ( FMI::Utils::Hint  hint)

Set the hint (optimization objective) of the channel selection procedure.

◆ recv()

template<typename T >
void FMI::Communicator::recv ( Comm::Data< T > &  buf,
FMI::Utils::peer_num  src 
)
inline

Receive data from src and store data into the provided buf.

◆ reduce()

template<typename T >
void FMI::Communicator::reduce ( Comm::Data< T > &  sendbuf,
Comm::Data< T > &  recvbuf,
FMI::Utils::peer_num  root,
FMI::Utils::Function< T >  f 
)
inline

Perform a reduction with the reduction function f.

Depending on the associativity / commutativity of f, a different implementation for the reduction may be used. However, in the same topology, the evaluation order should always be the same, irrespectively of the associativity / commutativitiy.

Parameters
sendbufData to send, relevant for all peers.
recvbufReceive buffer that contains the final result, only relevant for root. Needs to have the same size as the sendbuf.

◆ register_channel()

void FMI::Communicator::register_channel ( std::string  name,
std::shared_ptr< FMI::Comm::Channel c 
)

Add a new channel to the communicator with the given name by providing a pointer to it.

◆ scan()

template<typename T >
void FMI::Communicator::scan ( Comm::Data< T > &  sendbuf,
Comm::Data< T > &  recvbuf,
FMI::Utils::Function< T >  f 
)
inline

Inclusive prefix scan.

Depending on the associativity / commutativity of f, a different implementation for the reduction may be used. However, in the same topology, the evaluation order should always be the same, irrespectively of the associativity / commutativitiy.

Parameters
sendbufData to send, relevant for all peers.
recvbufReceive buffer that contains the final result, relevant for all peers. Needs to have the same size as the sendbuf.

◆ scatter()

template<typename T >
void FMI::Communicator::scatter ( Comm::Data< T > &  sendbuf,
Comm::Data< T > &  recvbuf,
FMI::Utils::peer_num  root 
)
inline

Scatter the data from root's sendbuf to the recvbuf of all peers.

Parameters
sendbufThe data to scatter, size needs to be recvbuf.size * num_peers (i.e., divisible by the number of peers). Only relevant for the root peer.
recvbufBuffer to receive the data, relevant for all peers.

◆ send()

template<typename T >
void FMI::Communicator::send ( Comm::Data< T > &  buf,
FMI::Utils::peer_num  dest 
)
inline

Send buf to peer dest.

◆ set_channel_policy()

void FMI::Communicator::set_channel_policy ( std::shared_ptr< FMI::Utils::ChannelPolicy policy)

Change the channel policy the communicator is using.


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