Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
AbstractTopology.h
Go to the documentation of this file.
1 
6 /*
7  * @author János Végh (jvegh)
8  * @bug No known bugs.
9 */
10 
11 
12 #ifndef ABSTRACTTOPOLOGY_H
13 #define ABSTRACTTOPOLOGY_H
14 
18 //#include <iomanip> // std::setfill, std::setw
19 //#include <vector>
20 //#include <iostream> // std::cout, std::ios
21 //#include <sstream> // std::ostringstream
22 //#include <bitset> // std::bitset
23 //#include "GridPoint.h"
24 #include "MemoryClustering.h"
25 class GridPoint;
26 
27 using namespace std;
28 
29 const std::vector<char> GridXOffset {0,0,1, 1, 0,-1,-1};
30 const std::vector<char> GridYOffset {0,2,1,-1,-2,-1, 1};
31 
32 // Here a is assumed for the physical scGridPoints
33 // and the HThreads running on the , sharing its resources
34 // The core exists only in one instantiation, but data structures
35 // belonging to independent HThreads are partly stored in the scGridPoint, in arrays
36 
37 extern int YFromPosition_Get(int x, int y);
53 {
54  public:
79  AbstractTopology(void);
80  virtual ~AbstractTopology(void); // Must be overridden
81  int NumberOfGridPoints_Get(void) {return GRID_SIZE_X * GRID_SIZE_Y; }
82  int NumberOfClusters_Get(void){return mClusters.size();}
83  // Accessor functions: without thread, the physical access (0th HThread)
84  GridPoint*
85  ByID_Get(const int N);
86  GridPoint*
87  ByIndex_Get(const int X, const int Y);
88  GridPoint*
89  ByPosition_Get(int X, int Y);
90  // Helper functions for address calculation
91  int
92  LinearAddressFromCoordinates_Get( int X, int Y)
93  { assert(!(X<0 || X>=GRID_SIZE_X)); assert(!(Y<0 || Y>=GRID_SIZE_Y));
94  return X*GRID_SIZE_Y + Y; }
95  int
96  LinearAddressFromPosition_Get(int X, int Y)
97  {return LinearAddressFromCoordinates_Get(X,Y/2); }
98  int
99  LinearAddressFromPosition_Get(GridPoint* GP) ;
100  // {return LinearAddressFromCoordinates_Get(GP->X,GP->Y); }
106  GridPoint*
107  ByClusterAddress_Get(ClusterAddress_t C);
116  GridPoint*
117  ByClusterMember_Get(unsigned short int CN, ClusterNeighbor CM = cm_Head, ClusterNeighbor CP = cm_Head);
124  GridPoint*
125  ByClusterPointer_Get(GridPoint* P, ClusterNeighbor CM = cm_Head);
130  void
131  Cluster_Create(GridPoint* P);
143  void
144  Cluster_Create(int X, int Y);
145  GridPoint*
146  ClusterHeadOfMember_Get(GridPoint* GP);
147  //
154  void
155  ClusterStatus_Set(GridPoint* P, ClusterNeighbor N, ClusterStatus S);
157  ClusterStatus_Get(GridPoint* P, ClusterNeighbor N);
159  ClusterAddress_Get(GridPoint* P);
161  ClusterAddressFromLinear_Get(int N);
162  int
163  NeighborIndexInCluster_Get(GridPoint* Head, GridPoint* Neighbor);
164 
165 #ifdef DRAW
166  Valuable and works, but needed only when changing the number of points or debugging
167  void
168  DrawPoint(int i,int j, ostringstream &oss);
169  void
170  Draw(void);
171 #endif // DRAW
172 
176  void
177  CreateClusters(void);
178 
185  GridPoint*
186  ClusterHead_Get(unsigned int N)
187  {
188  assert (!(N<0) || (N>=mClusters.size())); // Illegal member
189  return mClusters[N]; // We always have a 0-th thread
190  }
196  string
197  StringOfClusterAddress_Get(GridPoint* GP);
198 /* string /// Return the proxy string, if any, of the proxy of GridPoint GP
199  StringOfProxy_Get(GridPoint* GP);*/
200  SC_ADDRESS_TYPE
201  PC_Get() { return mProgramCounter;}
202  void
203  PC_Set(SC_ADDRESS_TYPE PC) { mProgramCounter = PC;}
204 
205  protected:
206  // The SAME physical points are stored in different structures
207  vector<vector<GridPoint*> >
209  vector<GridPoint*>
211  SC_ADDRESS_TYPE
213  };// of class AbstractTopology
215 #endif // ABSTRACTTOPOLOGY_H
AbstractTopology::mProgramCounter
SC_ADDRESS_TYPE mProgramCounter
The architecture itself has a global program counter.
Definition: AbstractTopology.h:212
AbstractTopology
Definition: AbstractTopology.h:52
GridPoint
This class handles the topological information for the modules. Provides a lot of math-only utility f...
Definition: GridPoint.h:33
AbstractTopology::mGrid
vector< vector< GridPoint * > > mGrid
The gridpoints form a 2-dim grid, addressable by their index.
Definition: AbstractTopology.h:208
AbstractTopology::ClusterHead_Get
GridPoint * ClusterHead_Get(unsigned int N)
Return pointer to the cluster head of the Nth cluster.
Definition: AbstractTopology.h:186
ClusterNeighbor
ClusterNeighbor
The neighborship in the cluster: the members are referred to with their geographic direction.
Definition: Clustering.h:34
ClusterAddress_t
A GridPoint can be addressed also by its cluster address of type ClusterAddress_t....
Definition: Clustering.h:58
cm_Head
@ cm_Head
The central gridpoint.
Definition: Clustering.h:35
AbstractTopology::mClusters
vector< GridPoint * > mClusters
The clustered gridpoints are accessible through their clusters, too.
Definition: AbstractTopology.h:210
ClusterStatus
ClusterStatus
The gridpoints can be the head of the cluster, a member of a cluster, or neither (stand-alone)
Definition: Clustering.h:24