Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
graybat::Cage< T_CommunicationPolicy, T_GraphPolicy > Class Template Reference

The Communication And Graph Environment enables to communicate on basis of a graph with methods of a user defined communication library. More...

#include <Cage.hpp>

Classes

struct  maximum
 

Public Types

using CommunicationPolicy = T_CommunicationPolicy
 
using GraphPolicy = T_GraphPolicy
 
using Cage_t = Cage< CommunicationPolicy, GraphPolicy >
 
using VAddr = graybat::communicationPolicy::VAddr< CommunicationPolicy >
 
using Context = graybat::communicationPolicy::Context< CommunicationPolicy >
 
using Event = graybat::communicationPolicy::Event< CommunicationPolicy >
 
using CPConfig = graybat::communicationPolicy::Config< CommunicationPolicy >
 
using Edge = graybat::CommunicationEdge< Cage_t >
 
using Vertex = graybat::CommunicationVertex< Cage_t >
 
using EdgeDescription = graybat::graphPolicy::EdgeDescription< GraphPolicy >
 
using GraphDescription = graybat::graphPolicy::GraphDescription< GraphPolicy >
 
using VertexID = graybat::graphPolicy::VertexID
 
using EdgeID = graybat::graphPolicy::EdgeID
 
using GraphID = graybat::graphPolicy::GraphID
 
using Peer = size_t
 

Public Member Functions

template<class T_Functor >
 Cage (CPConfig const cpConfig, T_Functor graphFunctor)
 
 Cage (CPConfig const cpConfig)
 
Graph Operations
template<class T_Functor >
void setGraph (T_Functor graphFunctor)
 
std::vector< VertexgetVertices ()
 
Vertex getVertex (const VertexID vertexID)
 
Edge getEdge (const Vertex source, const Vertex target)
 
std::vector< VertexgetAdjacentVertices (const Vertex &v)
 
std::vector< EdgegetOutEdges (const Vertex &v)
 
std::vector< EdgegetInEdges (const Vertex v)
 
Mapping Operations
template<class T_Functor >
void distribute (T_Functor distFunctor)
 Distribution of the graph vertices to the peers of the global context. The distFunctor it the function responsible for this distribution. More...
 
void announce (const std::vector< Vertex > vertices, const bool global=true)
 Announces vertices of a graph to the network, so that other peers know that these vertices are hosted by this peer. More...
 
VAddr locateVertex (Vertex vertex)
 Returns the VAddr of the host of vertex in the graph. More...
 
std::vector< VertexgetHostedVertices (const VAddr vAddr)
 Opposite operation of locateVertex(). It returns the vertices that are hosted by the peer with vAddr
 
bool peerHostsVertex (Vertex vertex)
 Returns true if the vertex is hosted by the calling peer otherwise false.
 
std::vector< Peer > getPeers ()
 
Point to Point Communication Operations
template<typename T >
void send (const Edge edge, const T &data)
 Synchron transmission of data to the destVertex on edge. More...
 
template<typename T >
void send (const Edge edge, const T &data, std::vector< Event > &events)
 Asynchron transmission of data to the destVertex on edge. More...
 
template<typename T >
void recv (const Edge edge, T &data)
 Synchron receive of data from the srcVertex on edge. More...
 
template<typename T >
Edge recv (T &data)
 
template<typename T >
void recv (const Edge edge, T &data, std::vector< Event > &events)
 Asynchron receive of data from the srcVertex on edge. More...
 
Collective Communication Operations
template<typename T_Data , typename Op >
void reduce (const Vertex rootVertex, const Vertex srcVertex, Op op, const std::vector< T_Data > sendData, std::vector< T_Data > &recvData)
 
template<typename T_Data , typename T_Recv , typename Op >
void allReduce (const Vertex srcVertex, Op op, const std::vector< T_Data > sendData, T_Recv &recvData)
 
template<typename T_Send , typename T_Recv >
void gather (const Vertex rootVertex, const Vertex srcVertex, const T_Send sendData, T_Recv &recvData, const bool reorder)
 
template<typename T_Send , typename T_Recv >
void allGather (const Vertex srcVertex, T_Send sendData, T_Recv &recvData, const bool reorder)
 
template<typename T >
void spread (const Vertex vertex, const T &data, std::vector< Event > &events)
 Spread data from a vertex to all adjacent vertices connected by an outgoing edge (async). More...
 
template<typename T >
void spread (const Vertex vertex, const T &data)
 Spread data from a vertex to all adjacent vertices connected by an outgoing edge (sync). More...
 
template<typename T >
void collect (const Vertex vertex, T &data)
 Collects data from all incoming edges under the assumption that all vertices send the same number of data. More...
 
void synchronize ()
 
int ContextID ()
 

Public Attributes

CommunicationPolicy comm
 
GraphPolicy graph
 
Context graphContext
 
std::vector< VertexhostedVertices
 
std::map< VertexID, VAddr > vertexMap
 
std::map< GraphID, Context > graphMap
 
std::map< VAddr, std::vector< Vertex > > peerMap
 

Detailed Description

template<typename T_CommunicationPolicy, typename T_GraphPolicy>
class graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >

The Communication And Graph Environment enables to communicate on basis of a graph with methods of a user defined communication library.

A cage is defined by its Communication and Graph policy. The communication policy provides methods for point to point and collective operations. The graph policy provides methods to query graph imformation of the cage graph.

Remarks
A peer can host several vertices.
Examples:
anyrecv.cpp, chain.cpp, forward.cpp, gol.cpp, and ring.cpp.

Member Function Documentation

template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T_Send , typename T_Recv >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::allGather ( const Vertex  srcVertex,
T_Send  sendData,
T_Recv &  recvData,
const bool  reorder 
)
inline
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::announce ( const std::vector< Vertex vertices,
const bool  global = true 
)
inline

Announces vertices of a graph to the network, so that other peers know that these vertices are hosted by this peer.

The general workflow includes two steps:

  1. Each peer, that hosts vertices of the graph announces its vertices
    • Each peer will send its hosted vertices and update its vertices location
    • The host peers will create a new context for graph
  2. Vertices can now be located by locateVertex()
  3. use Graphpeer to communicate between vertices
Remarks
This is a collective Operation on which either all host peers of the supergraph of graph have to take part or when graph has no supergraph then all Communicatos from the globalContext (which should be all peers in the network).
Parameters
[in]graphIts vertices will be announced
[in]verticesA set of vertices, that will be hosted by this peer
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::collect ( const Vertex  vertex,
T &  data 
)
inline

Collects data from all incoming edges under the assumption that all vertices send the same number of data.

Parameters
[in]vertexthat collects data
[in]datawere collected data will be stored
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<class T_Functor >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::distribute ( T_Functor  distFunctor)
inline

Distribution of the graph vertices to the peers of the global context. The distFunctor it the function responsible for this distribution.

Parameters
distFunctorFunction for vertex distribution with the following interface: distFunctor(OwnVAddr, ContextSize, Graph)
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
VAddr graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::locateVertex ( Vertex  vertex)
inline

Returns the VAddr of the host of vertex in the graph.

Parameters
[in]vertexWill be located.
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::recv ( const Edge  edge,
T &  data 
)
inline

Synchron receive of data from the srcVertex on edge.

Parameters
[in]graphThe graph in which the communication takes place.
[in]edgeEdge over which the data will be transmitted.
[out]dataData that will be received
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::recv ( const Edge  edge,
T &  data,
std::vector< Event > &  events 
)
inline

Asynchron receive of data from the srcVertex on edge.

Parameters
[in]graphThe graph in which the communication takes place.
[in]edgeEdge over which the data will be transmitted.
[out]dataData that will be received
[out]Listof events the send event will be added to.
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::send ( const Edge  edge,
const T &  data 
)
inline

Synchron transmission of data to the destVertex on edge.

Parameters
[in]graphThe graph in which the communication takes place.
[in]edgeEdge over which the data will be transmitted.
[in]dataData that will be send.
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::send ( const Edge  edge,
const T &  data,
std::vector< Event > &  events 
)
inline

Asynchron transmission of data to the destVertex on edge.

Parameters
[in]graphThe graph in which the communication takes place.
[in]edgeEdge over which the data will be transmitted.
[in]dataData that will be send.
[out]Listof events the send event will be added to.
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::spread ( const Vertex  vertex,
const T &  data,
std::vector< Event > &  events 
)
inline

Spread data from a vertex to all adjacent vertices connected by an outgoing edge (async).

Parameters
[in]vertexto spread data from
[in]datathat will be spreaded
[out]eventswhere the events for this async operations will be inserted.
template<typename T_CommunicationPolicy , typename T_GraphPolicy >
template<typename T >
void graybat::Cage< T_CommunicationPolicy, T_GraphPolicy >::spread ( const Vertex  vertex,
const T &  data 
)
inline

Spread data from a vertex to all adjacent vertices connected by an outgoing edge (sync).

Parameters
[in]vertexto spread data from
[in]datathat will be spreaded

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