Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
graybat::communicationPolicy::BMPI Class Reference

Implementation of the Cage communicationPolicy interface based on the MPI implementation boost::mpi. More...

#include <BMPI.hpp>

Inheritance diagram for graybat::communicationPolicy::BMPI:
graybat::communicationPolicy::Base< BMPI >

Public Types

using Tag = typename graybat::communicationPolicy::Tag< BMPI >
 
using ContextID = typename graybat::communicationPolicy::ContextID< BMPI >
 
using MsgType = typename graybat::communicationPolicy::MsgType< BMPI >
 
using VAddr = typename graybat::communicationPolicy::VAddr< BMPI >
 
using Context = typename graybat::communicationPolicy::Context< BMPI >
 
using Event = typename graybat::communicationPolicy::Event< BMPI >
 
using Config = typename graybat::communicationPolicy::Config< BMPI >
 
using Uri = int
 
- Public Types inherited from graybat::communicationPolicy::Base< BMPI >
using CommunicationPolicy = BMPI
 
using VAddr = typename graybat::communicationPolicy::VAddr< CommunicationPolicy >
 
using Tag = typename graybat::communicationPolicy::Tag< CommunicationPolicy >
 
using Context = typename graybat::communicationPolicy::Context< CommunicationPolicy >
 
using Event = typename graybat::communicationPolicy::Event< CommunicationPolicy >
 

Public Member Functions

 BMPI (Config const config)
 
Point to Point Communication Interface
template<typename T_Send >
void send (const VAddr destVAddr, const Tag tag, const Context context, const T_Send &sendData)
 Blocking transmission of a message sendData to peer with virtual address destVAddr. More...
 
template<typename T_Send >
Event asyncSend (const VAddr destVAddr, const Tag tag, const Context context, const T_Send &sendData)
 Non blocking transmission of a message sendData to peer with virtual address destVAddr. More...
 
template<typename T_Recv >
void recv (const VAddr srcVAddr, const Tag tag, const Context context, T_Recv &recvData)
 Blocking receive of a message recvData from peer with virtual address srcVAddr. More...
 
template<typename T_Recv >
Event recv (const Context context, T_Recv &recvData)
 
template<typename T_Recv >
Event asyncRecv (const VAddr srcVAddr, const Tag tag, const Context context, T_Recv &recvData)
 Non blocking receive of a message recvData from peer with virtual address srcVAddr. More...
 
Collective Communication Interface
template<typename T_Send , typename T_Recv >
void gather (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData)
 Collects sendData from all peers of the context and transmits it as a list to the peer with rootVAddr. Data of all peers has to be from the same size. More...
 
template<typename T_Send , typename T_Recv >
void gatherVar (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData, std::vector< unsigned > &recvCount)
 Collects sendData from all members of the context with varying size and transmits it as a list to peer with rootVAddr. More...
 
template<typename T_Send , typename T_Recv >
void allGather (Context context, const T_Send &sendData, T_Recv &recvData)
 Collects sendData from all members of the context and transmits it as a list to every peer in the context More...
 
template<typename T_Send , typename T_Recv >
void allGatherVar (const Context context, const T_Send &sendData, T_Recv &recvData, std::vector< unsigned > &recvCount)
 Collects sendData from all peers of the context. Size of sendData can vary in size. The data is received by every peer in the context. More...
 
template<typename T_Send , typename T_Recv >
void scatter (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData)
 Distributes sendData from peer rootVAddr to all peers in context. Every peer will receive different data. More...
 
template<typename T_Send , typename T_Recv >
void allToAll (const Context context, const T_Send &sendData, T_Recv &recvData)
 Distributes sendData of all peer in the context to all peers in the context. Every peer will receive data from every other peer (also the own data) More...
 
template<typename T_Send , typename T_Recv , typename T_Op >
void reduce (const VAddr rootVAddr, const Context context, const T_Op op, const T_Send &sendData, T_Recv &recvData)
 Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by the peer with rootVAddr. Binary operations like std::plus, std::minus can be used. But, they can also be defined as binary operator simular to std::plus etc. More...
 
template<typename T_Send , typename T_Recv , typename T_Op >
void allReduce (const Context context, T_Op op, const T_Send &sendData, T_Recv &recvData)
 Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by all peers. More...
 
template<typename T_SendRecv >
void broadcast (const VAddr rootVAddr, const Context context, T_SendRecv &data)
 Send sendData from peer rootVAddr to all peers in context. Every peer will receive the same data. More...
 
void synchronize (const Context context)
 Synchronizes all peers within context to the same point in the programm execution (barrier).
 
void synchronize ()
 Synchronizes all peers within the globalContext in the programm execution (barrier). More...
 
Context Management Interface
Context splitContext (const bool isMember, const Context oldContext)
 Creates a new context with all peers that declared isMember as true.
 
Context getGlobalContext ()
 Returns the context that contains all peers.
 
- Public Member Functions inherited from graybat::communicationPolicy::Base< BMPI >
void send (const VAddr destVAddr, const Tag tag, const Context context, const T_Send &sendData)=delete
 
Event asyncSend (const VAddr destVAddr, const Tag tag, const Context context, const T_Send &sendData)=delete
 
void recv (const VAddr srcVAddr, const Tag tag, const Context context, T_Recv &recvData)=delete
 
Event recv (const Context context, T_Recv &recvData)=delete
 
Event asyncRecv (const VAddr srcVAddr, const Tag tag, const Context context, T_Recv &recvData)=delete
 
void gather (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData)
 Collects sendData from all peers of the context and transmits it as a list to the peer with rootVAddr. Data of all peers has to be from the same size. More...
 
void gatherVar (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData, std::vector< unsigned > &recvCount)
 Collects sendData from all members of the context with varying size and transmits it as a list to peer with rootVAddr. More...
 
void allGather (Context context, const T_Send &sendData, T_Recv &recvData)
 Collects sendData from all members of the context and transmits it as a list to every peer in the context More...
 
void allGatherVar (const Context context, const T_Send &sendData, T_Recv &recvData, std::vector< unsigned > &recvCount)
 Collects sendData from all peers of the context. Size of sendData can vary in size. The data is received by every peer in the context. More...
 
void scatter (const VAddr rootVAddr, const Context context, const T_Send &sendData, T_Recv &recvData)
 Distributes sendData from peer rootVAddr to all peers in context. Every peer will receive different data. More...
 
void allScatter (const Context context, const T_Send &sendData, T_Recv &recvData)
 Distributes sendData of all peer in the context to all peers in the context. Every peer will receive data from every other peer (also the own data) More...
 
void reduce (const VAddr rootVAddr, const Context context, const T_Op op, const T_Send &sendData, T_Recv &recvData)
 Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by the peer with rootVAddr. Binary operations like std::plus, std::minus can be used. But, they can also be defined as binary operator simular to std::plus etc. More...
 
void allReduce (const Context context, T_Op op, const T_Send &sendData, T_Recv &recvData)
 Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by all peers. More...
 
void broadcast (const VAddr rootVAddr, const Context context, T_SendRecv &data)
 Send sendData from peer rootVAddr to all peers in context. Every peer will receive the same data. More...
 
void synchronize (const Context context)
 Synchronizes all peers within context to the same point in the programm execution (barrier).
 

Detailed Description

Implementation of the Cage communicationPolicy interface based on the MPI implementation boost::mpi.

Examples:
anyrecv.cpp, chain.cpp, forward.cpp, gol.cpp, and ring.cpp.

Member Function Documentation

template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::allGather ( Context  context,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Collects sendData from all members of the context and transmits it as a list to every peer in the context

Parameters
[in]contextSet of peers that want to send Data
[in]sendDataData that every peer in the context sends with same size
[out]recvDataData from all context members, that all peers* will receive.
template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::allGatherVar ( const Context  context,
const T_Send &  sendData,
T_Recv &  recvData,
std::vector< unsigned > &  recvCount 
)
inline

Collects sendData from all peers of the context. Size of sendData can vary in size. The data is received by every peer in the context.

Parameters
[in]contextSet of peers that want to send Data
[in]sendDataData that every peer in the context sends with varying size
[out]recvDataData from all context members, that all peers* will receive.
[out]recvCountNumber of elements each peer sends (can by varying).
template<typename T_Send , typename T_Recv , typename T_Op >
void graybat::communicationPolicy::BMPI::allReduce ( const Context  context,
T_Op  op,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by all peers.

Parameters
[in]contextSet of peers that
[in]opBinary operator that should be used for reduction
[in]sendDataData that every peer contributes to the reduction
[out]recvDataReduced sendData that will be received by all peers. It will have same size of sendData and contains the ith reduced sendData values.
template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::allToAll ( const Context  context,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Distributes sendData of all peer in the context to all peers in the context. Every peer will receive data from every other peer (also the own data)

Parameters
[in]contextSet of peers that want to receive Data
[in]sendDataData that each peer wants to send. Each peer will receive same number of data elements, but not the same data elements. sendData will be divided in equal chunks of data and is then distributed.
[out]recvDataData from all peer.
template<typename T_Recv >
Event graybat::communicationPolicy::BMPI::asyncRecv ( const VAddr  srcVAddr,
const Tag  tag,
const Context  context,
T_Recv &  recvData 
)
inline

Non blocking receive of a message recvData from peer with virtual address srcVAddr.

Parameters
[in]srcVAddrVAddr of peer that sended the message
[in]tagDescription of the message to better distinguish messages types
[in]contextContext in which both sender and receiver are included
[out]recvDataData reference of template type T will be received from sender peer. T need to provide the function data(), that returns the pointer to the data memory address. And the function size(), that return the amount of data elements to send. Notice, that std::vector and std::array implement this interface.
Returns
Event
template<typename T_Send >
Event graybat::communicationPolicy::BMPI::asyncSend ( const VAddr  destVAddr,
const Tag  tag,
const Context  context,
const T_Send &  sendData 
)
inline

Non blocking transmission of a message sendData to peer with virtual address destVAddr.

Parameters
[in]destVAddrVAddr of peer that will receive the message
[in]tagDescription of the message to better distinguish messages types
[in]contextContext in which both sender and receiver are included
[in]sendDataData reference of template type T will be. T need to provide the function data(), that returns the pointer to the data memory address. And the function size(), that return the amount of data elements to send. Notice, that std::vector and std::array implement this interface.
Returns
Event
template<typename T_SendRecv >
void graybat::communicationPolicy::BMPI::broadcast ( const VAddr  rootVAddr,
const Context  context,
T_SendRecv &  data 
)
inline

Send sendData from peer rootVAddr to all peers in context. Every peer will receive the same data.

Remarks
In Contrast to scatter where every peer receives different data
Parameters
[in]rootVAddrSource peer
[in]contextSet of peers that want to receive Data
[in]sendDataData that peer with rootVAddr will send to the peers of the context
[out]recvDataData from peer with rootVAddr.
template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::gather ( const VAddr  rootVAddr,
const Context  context,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Collects sendData from all peers of the context and transmits it as a list to the peer with rootVAddr. Data of all peers has to be from the same size.

Parameters
[in]rootVAddrPeer that will receive collcted data from context members
[in]contextSet of peers that want to send Data
[in]sendDataData that every peer in the context sends. Data of all peers in the context need to have same size().
[out]recvDataData from all context members, that peer with virtual address rootVAddr will receive. recvData of all other members of the context will be empty.
template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::gatherVar ( const VAddr  rootVAddr,
const Context  context,
const T_Send &  sendData,
T_Recv &  recvData,
std::vector< unsigned > &  recvCount 
)
inline

Collects sendData from all members of the context with varying size and transmits it as a list to peer with rootVAddr.

Parameters
[in]rootVAddrPeer that will receive collcted data from context members
[in]contextSet of peers that want to send Data
[in]sendDataData that every peer in the context sends. The Data can have varying size
[out]recvDataData from all context peers, that peer with rootVAddr will receive. recvData of all other peers of the context will be empty. The received data is ordered by the VAddr of the peers.
[out]recvCountNumber of elements each peer sends (can by varying).
template<typename T_Recv >
void graybat::communicationPolicy::BMPI::recv ( const VAddr  srcVAddr,
const Tag  tag,
const Context  context,
T_Recv &  recvData 
)
inline

Blocking receive of a message recvData from peer with virtual address srcVAddr.

Parameters
[in]srcVAddrVAddr of peer that sended the message
[in]tagDescription of the message to better distinguish messages types
[in]contextContext in which both sender and receiver are included
[out]recvDataData reference of template type T will be received from sender peer. T need to provide the function data(), that returns the pointer to the data memory address. And the function size(), that return the amount of data elements to send. Notice, that std::vector and std::array implement this interface.
template<typename T_Send , typename T_Recv , typename T_Op >
void graybat::communicationPolicy::BMPI::reduce ( const VAddr  rootVAddr,
const Context  context,
const T_Op  op,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Performs a reduction with a binary operator op on all sendData elements from all peers whithin the context. The result will be received by the peer with rootVAddr. Binary operations like std::plus, std::minus can be used. But, they can also be defined as binary operator simular to std::plus etc.

Parameters
[in]rootVAddrpeer that will receive the result of reduction
[in]contextSet of peers that
[in]opBinary operator that should be used for reduction
[in]sendDataData that every peer contributes to the reduction
[out]recvDataReduced sendData that will be received by peer with rootVAddr. It will have same size of sendData and contains the ith reduced sendData values.
template<typename T_Send , typename T_Recv >
void graybat::communicationPolicy::BMPI::scatter ( const VAddr  rootVAddr,
const Context  context,
const T_Send &  sendData,
T_Recv &  recvData 
)
inline

Distributes sendData from peer rootVAddr to all peers in context. Every peer will receive different data.

Remarks
In Contrast to broadcast where every peer receives the same data
Parameters
[in]rootVAddrpeer that want to distribute its data
[in]contextSet of peers that want to receive Data
[in]sendDataData that peer with rootVAddr will distribute over the peers of the context
[out]recvDataData from peer with rootVAddr.
template<typename T_Send >
void graybat::communicationPolicy::BMPI::send ( const VAddr  destVAddr,
const Tag  tag,
const Context  context,
const T_Send &  sendData 
)
inline

Blocking transmission of a message sendData to peer with virtual address destVAddr.

Parameters
[in]destVAddrVAddr of peer that will receive the message
[in]tagDescription of the message to better distinguish messages types
[in]contextContext in which both sender and receiver are included
[in]sendDataData reference of template type T will be send to receiver peer. T need to provide the function data(), that returns the pointer to the data memory address. And the function size(), that return the amount of data elements to send. Notice, that std::vector and std::array implement this interface.
void graybat::communicationPolicy::BMPI::synchronize ( )
inline

Synchronizes all peers within the globalContext in the programm execution (barrier).

See also
getGlobalContext()

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