Bug #1062: Fix linking errors by moving definition of userDrivenMode to machine-commo...
[charm.git] / src / conv-ldb / topology.h
blob4847f28bd4473fe41cdbab6f898e0977e615ebcc
1 /**
2 * \addtogroup CkLdb
3 */
4 /*@{*/
7 #ifndef _LBTOPOLOGY_H
8 #define _LBTOPOLOGY_H
10 #define HOP_LINK_DELAY 10e-6
11 #define HOP_PROC_DELAY 10e-6
13 #ifdef __cplusplus
15 class LBTopology {
16 protected:
17 int npes;
18 public:
19 LBTopology(int p): npes(p) {}
20 virtual ~LBTopology() {}
21 virtual int max_neighbors() = 0;
22 virtual void neighbors(int mype, int* _n, int &nb) = 0;
23 //added by zshao1, these defaults mean the the topology does not support these methods
24 virtual int get_dimension() { return -1;}
25 virtual bool get_processor_coordinates(int processor_id, int* processor_coordinates) { return false; }
26 virtual bool get_processor_id(const int* processor_coordinates, int* processor_id) { return false; }
27 virtual bool coordinate_difference(const int* my_coordinates, const int* target_coordinates, int* difference) { return false;}
28 virtual bool coordinate_difference(int my_processor_id, int target_processor_id, int* difference) { return false; }
29 virtual int get_hop_count(int src,int dest);
30 virtual int rec_hop_count(int src,int dest,int max_neigh,int count,int *visited_srcs,int min_hop_cnt);
31 virtual double per_hop_delay(int last_hop);
32 virtual void get_pairwise_hop_count(double **dist);
35 #define LBTOPO_MACRO(x) \
36 static LBTopology * create##x(int np) { \
37 return new x(np); \
40 class LBTopo_ring: public LBTopology {
41 public:
42 LBTopo_ring(int p): LBTopology(p) {}
43 virtual int max_neighbors();
44 virtual void neighbors(int mype, int* _n, int &nb);
45 virtual int get_hop_count(int src,int dest);
48 class LBTopo_torus2d: public LBTopology {
49 private:
50 int width;
51 int goodcoor(int, int);
52 public:
53 LBTopo_torus2d(int p);
54 virtual int max_neighbors();
55 virtual void neighbors(int mype, int* _n, int &nb);
56 virtual int get_hop_count(int src,int dest);
59 class LBTopo_torus3d: public LBTopology {
60 private:
61 int width;
62 int goodcoor(int, int, int);
63 public:
64 LBTopo_torus3d(int p);
65 virtual int max_neighbors();
66 virtual void neighbors(int mype, int* _n, int &nb);
69 class LBTopo_mesh3d: public LBTopology {
70 private:
71 int width;
72 int goodcoor(int, int, int);
73 public:
74 LBTopo_mesh3d(int p);
75 virtual int max_neighbors();
76 virtual void neighbors(int mype, int* _n, int &nb);
79 class LBTopo_graph: public LBTopology {
80 public:
81 LBTopo_graph(int p): LBTopology(p) {}
82 virtual int max_neighbors();
83 virtual void neighbors(int mype, int* _n, int &nb);
86 typedef LBTopology* (*LBtopoFn)(int);
88 #else
89 typedef void* (*LBtopoFn)();
90 #endif /* __cplusplus */
92 #ifdef __cplusplus
93 extern "C" {
94 #endif
95 LBtopoFn LBTopoLookup(char *);
96 int getTopoMaxNeighbors(void *topo);
97 void getTopoNeighbors(void *topo, int myid, int* na, int *n);
98 void printoutTopo();
99 #ifdef __cplusplus
101 #endif
103 #endif