00001
00005
00006
00007 #ifndef _LBTOPOLOGY_H
00008 #define _LBTOPOLOGY_H
00009
00010 #define HOP_LINK_DELAY 10e-6
00011 #define HOP_PROC_DELAY 10e-6
00012
00013 #ifdef __cplusplus
00014
00015 class LBTopology {
00016 protected:
00017 int npes;
00018 public:
00019 LBTopology(int p): npes(p) {}
00020 virtual ~LBTopology() {}
00021 virtual int max_neighbors() = 0;
00022 virtual void neighbors(int mype, int* _n, int &nb) = 0;
00023
00024 virtual int get_dimension() { return -1;}
00025 virtual bool get_processor_coordinates(int processor_id, int* processor_coordinates) { return false; }
00026 virtual bool get_processor_id(const int* processor_coordinates, int* processor_id) { return false; }
00027 virtual bool coordinate_difference(const int* my_coordinates, const int* target_coordinates, int* difference) { return false;}
00028 virtual bool coordinate_difference(int my_processor_id, int target_processor_id, int* difference) { return false; }
00029 virtual int get_hop_count(int src,int dest);
00030 virtual int rec_hop_count(int src,int dest,int max_neigh,int count,int *visited_srcs,int min_hop_cnt);
00031 virtual double per_hop_delay(int last_hop);
00032 virtual void get_pairwise_hop_count(double **dist);
00033 };
00034
00035 #define LBTOPO_MACRO(x) \
00036 static LBTopology * create##x(int np) { \
00037 return new x(np); \
00038 }
00039
00040 class LBTopo_ring: public LBTopology {
00041 public:
00042 LBTopo_ring(int p): LBTopology(p) {}
00043 virtual int max_neighbors();
00044 virtual void neighbors(int mype, int* _n, int &nb);
00045 virtual int get_hop_count(int src,int dest);
00046 };
00047
00048 class LBTopo_torus2d: public LBTopology {
00049 private:
00050 int width;
00051 int goodcoor(int, int);
00052 public:
00053 LBTopo_torus2d(int p);
00054 virtual int max_neighbors();
00055 virtual void neighbors(int mype, int* _n, int &nb);
00056 virtual int get_hop_count(int src,int dest);
00057 };
00058
00059 class LBTopo_torus3d: public LBTopology {
00060 private:
00061 int width;
00062 int goodcoor(int, int, int);
00063 public:
00064 LBTopo_torus3d(int p);
00065 virtual int max_neighbors();
00066 virtual void neighbors(int mype, int* _n, int &nb);
00067 };
00068
00069 class LBTopo_mesh3d: public LBTopology {
00070 private:
00071 int width;
00072 int goodcoor(int, int, int);
00073 public:
00074 LBTopo_mesh3d(int p);
00075 virtual int max_neighbors();
00076 virtual void neighbors(int mype, int* _n, int &nb);
00077 };
00078
00079 class LBTopo_graph: public LBTopology {
00080 public:
00081 LBTopo_graph(int p): LBTopology(p) {}
00082 virtual int max_neighbors();
00083 virtual void neighbors(int mype, int* _n, int &nb);
00084 };
00085
00086 typedef LBTopology* (*LBtopoFn)(int);
00087
00088 #else
00089 typedef void* (*LBtopoFn)();
00090 #endif
00091
00092 #ifdef __cplusplus
00093 extern "C" {
00094 #endif
00095 LBtopoFn LBTopoLookup(const char *);
00096 int getTopoMaxNeighbors(void *topo);
00097 void getTopoNeighbors(void *topo, int myid, int* na, int *n);
00098 void printoutTopo(void);
00099 #ifdef __cplusplus
00100 }
00101 #endif
00102
00103 #endif