Graybat  1.1
Graph Approach for Highly Generic Communication Schemes Based on Adaptive Topologies
Roundrobin.hpp
1 #pragma once
2 
3 #include <vector> /* std::vector */
4 
5 namespace graybat {
6 
7  namespace mapping {
8  struct Roundrobin {
9 
10  template<typename T_Graph>
11  std::vector<typename T_Graph::Vertex> operator()(const unsigned processID, const unsigned processCount, T_Graph &graph){
12  typedef typename T_Graph::Vertex Vertex;
13 
14 
15  // Distribute and announce vertices
16  unsigned vertexCount = graph.getVertices().size();
17  unsigned maxVertex = ceil((float)vertexCount / processCount);
18 
19  std::vector<Vertex> myVertices;
20  if(processID <= vertexCount){
21  for(unsigned i = 0; i < maxVertex; ++i){
22  unsigned vertex_i = processID + (i * processCount);
23  if(vertex_i >= vertexCount){
24  break;
25  }
26  else {
27  myVertices.push_back(graph.getVertex(vertex_i));
28  }
29 
30  }
31  }
32  return myVertices;
33 
34  }
35 
36  };
37 
38  } /* mapping */
39 
40 } /* graybat */
Definition: Roundrobin.hpp:8
Definition: BiStar.hpp:8