PaCO++  0.05
paco_libgraph_comScheduling.h
Go to the documentation of this file.
1 #ifndef LIBGRAPH_COMSCHEDULE_IS_DEFINED
2 #define LIBGRAPH_COMSCHEDULE_IS_DEFINED
3 
4 #include <kbps.h>
6 
8 {
9 protected:
10  kbps_approximation* _kbps;
11 
12  unsigned int* _tmp_idx; // helper array for phase,id -> k
13  inline unsigned int _idx(const unsigned phase, const unsigned id)
14  {
15  return _tmp_idx[phase]+id;
16  }
17 
18 public:
19  paco_comSchedule_libgraph(kbps_approximation* k) : _kbps(k), _tmp_idx(NULL) {}
20 
21  kbps_approximation* get_kbps() const { return _kbps; }
22 
23  void build_idx()
24  {
25  if (_tmp_idx) {
26  delete[] _tmp_idx;
27  }
28 
29  _tmp_idx = new unsigned int[this->getNbPhases()];
30  _tmp_idx[0]=0;
31  for(unsigned i=1;i<getNbPhases(); i++)
32  _tmp_idx[i]=_tmp_idx[i-1]+getElementPhase(i-1);
33  }
34 
35  unsigned int getNbPhases() {
36  return _kbps->infophases[0];
37  }
38  unsigned int getElementPhase(const unsigned phase)
39  {
40  return _kbps->infophases[phase+1];
41  }
42  unsigned int getSrc(const unsigned phase, const unsigned id)
43  {
44  return _kbps->comms[_idx(phase, id)].src;
45  }
46  unsigned int getDst(const unsigned phase, const unsigned id)
47  {
48  return _kbps->comms[_idx(phase, id)].dst;
49  }
50  unsigned int getSize(const unsigned phase, const unsigned id)
51  {
52  return _kbps->comms[_idx(phase, id)].weight;
53  }
54 
55  void* getInfo(const unsigned phase, const unsigned id)
56  {
57  return _kbps->comms[_idx(phase, id)].info;
58  }
59 
60 };
61 
63 {
64 public:
65 
67  virtual ~paco_comScheduling_libgraph();
68 
69  void set_beta(unsigned int beta); // reset all schedule memory (but no communication memory)
70  void set_k(unsigned int k); // reset all schedule memory (but no communication memory)
71 
72  unsigned int get_beta();
73  unsigned int get_k();
74 
75  paco_comSchedule* computeScheduling(unsigned rank,
76  PaCO::PacoTopology_t* srctopo, PaCO::PacoTopology_t* dsttopo,
77  unsigned **com_matrix, void** info_vector[]);
78 
79 protected:
81  virtual void initializeBigraph(PaCO::PacoTopology_t* srctopo, PaCO::PacoTopology_t* dsttopo);
82 
83  unsigned int _beta;
84  unsigned int _k;
85 
86  bigraph * _g; // MUST be configured only by configureLibGraph
87  node ** _client_nodes;
88  node ** _server_nodes;
89 
90 };
91 
93 {
94  public:
96  return new paco_comScheduling_libgraph();
97  }
98 };
99 
100 #endif
paco_comScheduling * create_comScheduling()
paco_comSchedule_libgraph(kbps_approximation *k)
unsigned int getDst(const unsigned phase, const unsigned id)
unsigned int getElementPhase(const unsigned phase)
unsigned int getSize(const unsigned phase, const unsigned id)
void * getInfo(const unsigned phase, const unsigned id)
unsigned int getSrc(const unsigned phase, const unsigned id)
unsigned int _idx(const unsigned phase, const unsigned id)
kbps_approximation * get_kbps() const