Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
GridPoint.h
Go to the documentation of this file.
1 /* @author János Végh (jvegh)
2 * @bug No known bugs.
3 */
9 #ifndef GRIDPOINT_H
10 #define GRIDPOINT_H
11 //#include <iostream>
12 #include <sstream>
13 #include "MemoryClustering.h"
14 using namespace std;
15 class scHThread;
16 
17 
33 class GridPoint
34 {
35  public:
36  // Arranged in a two-dimensional hexagonal grid; with the H HThread, 3 dimensional
37  GridPoint(char xx=0,char yy=0, ClusterStatus CS=cs_NONE):X(xx),Y(yy){
38  mClusterAddress.HThread = 0,
39  mClusterAddress.Reserved = 0, //reserved
40  mClusterAddress.Rack= 0,//Rack
41  mClusterAddress.Topology= 0,//Topology (like Processor)
42  mClusterAddress.Card= 0,//Card
43  mClusterAddress.Cluster = MAX_CLUSTERS_LIMIT,//Cluster
44  mClusterAddress.Member=cm_Head,//Member
45  mClusterAddress.Proxy =cm_Head;//Proxy
46  mClusterAddress.Status = CS;
47 // mMyHThreads = 0; // Initially, no HThreads are
48  }
49  virtual
50  ~GridPoint(){}
51 
53  ClusterAddress_Get(void){ return mClusterAddress;}
54  void
55  ClusterAddress_Set(ClusterAddress_t CA){ mClusterAddress = CA;}
56  void
57  ClusterAddressHThread_Set(int H){ mClusterAddress.HThread = H;}
59  ClusterStatus_Get(void){ return (ClusterStatus)mClusterAddress.Status;}
60  void
61  ClusterStatus_Set(ClusterStatus CS){ mClusterAddress.Status = (int)CS;}
62  int8_t X,
63  Y;
66  int
67  YPosition_Get(void){ return Y*2 +moduloN(X,2); }
70 
76  bool
78  {
79  if(!(GP)) return false; // The candidate GridPoint is outside
80  // Check N and S
81  if( (X == GP->X) && (abs(YPosition_Get() - GP->YPosition_Get()) == 2)) return true;
82  // Check NE, SE, SW, NW positions
83  return( (abs(X - GP->X) == 1) && (abs(YPosition_Get() - GP->YPosition_Get()) == 1) );
84  }
85 
86 
92  bool
94  {
95  if(!(GP)) return false; // The candidate GridPoint is outside
96  // Both points are within the grid
97  // Check N and S
98  if( (abs(X - GP->X)== 0) && (abs(YPosition_Get() - GP->YPosition_Get()) == 4)) return true;
99  // Check E and W
100  if( (abs(X - GP->X)== 2) && (abs(YPosition_Get() - GP->YPosition_Get()) == 0)) return true;
101  // Check NNE, SE, SW, NNW positions
102  if( (abs(X - GP->X) == 1) && (abs(YPosition_Get() - GP->YPosition_Get()) == 3) ) return true;
103  // Check NNE, SSE, SSW, NNW positions
104  if( (abs(X - GP->X) == 2) && (abs(YPosition_Get() - GP->YPosition_Get()) == 2) ) return true;
105  return false;
106  }
107 
113  bool
115  {
116  if(!GP) return false;
117  return this == GP;
118  }
124  bool
126  {
127  if(!GP) return false;
128  return mClusterAddress.Cluster == GP->ClusterAddress_Get().Cluster;
129  }
130 
131 #if 0
132 
136  string
137  StringOfProxy_Get(void
138  )
139  { ostringstream oss;
140  ClusterAddress_t CA = ClusterAddress_Get();
141  if(CA.Proxy) {oss << ":" << ClusterMembers[CA.Proxy].name;}
142  return oss.str();
143  }
144 #endif //0
145 
149  string
151  )
152  { ostringstream oss;
153  ClusterAddress_t CA = ClusterAddress_Get();
154 // if(CA.HThread)
155  oss << CA.HThread;
156  return oss.str();
157  }
165  string
167  {
168  ostringstream oss;
169  oss << '{' << (int16_t)X << ',' << (int16_t)YPosition_Get() << '}' << '=';
170  oss << "(" ;
171  ClusterAddress_t CA = ClusterAddress_Get();
172  oss << CA.Cluster << "." << ClusterMembers[CA.Member].name;
173  if(CA.Proxy) {oss << ":" << ClusterMembers[CA.Proxy].name;}
174 // oss << StringOfProxy_Get() << ")";
175  if(CA.HThread) oss << '/' << StringOfThread_Get();
176  return oss.str();
177  }
178 
179 };
180 
181 #endif // GRIDPOINT_H
GridPoint::Is2ndNeighborOf
bool Is2ndNeighborOf(GridPoint *GP)
Return true if we are a second neighbor of GP.
Definition: GridPoint.h:93
GridPoint::Y
int8_t Y
The Y index of the gridpont.
Definition: GridPoint.h:63
GridPoint::ClusterAddressHThread_Set
void ClusterAddressHThread_Set(int H)
Set the cluster address of the gridpoint.
Definition: GridPoint.h:57
GridPoint
This class handles the topological information for the modules. Provides a lot of math-only utility f...
Definition: GridPoint.h:33
GridPoint::StringOfClusterAddressName_Get
string StringOfClusterAddressName_Get(void)
Return the string form of our cluster address.
Definition: GridPoint.h:166
scHThread
The scHThread class.
Definition: scHThread.h:138
GridPoint::StringOfThread_Get
string StringOfThread_Get()
Return the string describing the actual thread.
Definition: GridPoint.h:150
GridPoint::ClusterStatus_Get
ClusterStatus ClusterStatus_Get(void)
Return the status of the gridpoint.
Definition: GridPoint.h:59
GridPoint::mClusterAddress
ClusterAddress_t mClusterAddress
The ClusterAddress_t address of the gridpoint.
Definition: GridPoint.h:65
ClusterAddress_t::Cluster
uint32_t Cluster
The sequence number of the cluster.
Definition: Clustering.h:62
ClusterAddress_t
A GridPoint can be addressed also by its cluster address of type ClusterAddress_t....
Definition: Clustering.h:58
cs_NONE
@ cs_NONE
not specified (untouched)
Definition: Clustering.h:25
GridPoint::ClusterAddress_Get
ClusterAddress_t ClusterAddress_Get(void)
< Return the cluster address of the gridpoint, stored in the matrix
Definition: GridPoint.h:53
ClusterAddress_t::Proxy
uint32_t Proxy
Reachable through this neighbor (Relative to the core)
Definition: Clustering.h:61
GridPoint::IsNeighborOf
bool IsNeighborOf(GridPoint *GP)
Return true if we are an immediate neighbor of GP.
Definition: GridPoint.h:77
GridPoint::ClusterAddress_Set
void ClusterAddress_Set(ClusterAddress_t CA)
Set the cluster address of the gridpoint.
Definition: GridPoint.h:55
GridPoint::IsTheSameAs
bool IsTheSameAs(GridPoint *GP)
Return true if GridPoint GP is identical with us.
Definition: GridPoint.h:114
GridPoint::IsInTheSameClusterAs
bool IsInTheSameClusterAs(GridPoint *GP)
Return true if we and GridPoint GP are in the same cluster.
Definition: GridPoint.h:125
cm_Head
@ cm_Head
The central gridpoint.
Definition: Clustering.h:35
ClusterAddress_t::HThread
uint32_t HThread
The 'hardware thread' the module handles.
Definition: Clustering.h:59
GridPoint::X
int8_t X
The X index of the gridpont.
Definition: GridPoint.h:62
ClusterStatus
ClusterStatus
The gridpoints can be the head of the cluster, a member of a cluster, or neither (stand-alone)
Definition: Clustering.h:24
GridPoint::ClusterStatus_Set
void ClusterStatus_Set(ClusterStatus CS)
Set the cstatus of the gridpoint.
Definition: GridPoint.h:61
ClusterAddress_t::Member
uint32_t Member
Definition: Clustering.h:60