OpenAtom  Version1.5a
Uber.h
1 /** addtogroup Uber
2  * @{
3  *
4  * Uber Arrays connect multiple arrays by referring to them by Uber Indexed
5  * collections. So all elements which have Uarr[i][j][k] are one logical
6  * instance.
7  *
8  * Where we formerly had readonly proxies we now have readonly CkVec's of
9  * proxies. Each index tuple (i,j,k) will have an associated proxyOffset (PO).
10  * someProxy[PO] will have the proxy for the tuple associated with PO for all
11  * proxies.
12  *
13  * POs will be assigned using a dense 3D enumeration with k the innermost. So
14  * the PO is always derivable from the tuple and visa versa, but we keep PO to
15  * avoid recalculation overhead. No race condition for the ID space. Not that
16  * this matters since we don't have a scenario in which we create instances in
17  * parallel.
18  *
19  * PO=(i*Jmax+j) * Kmax +k;
20  *
21  * In practice, typical array objects only need a minority subset of the
22  * proxies in their instance, and perhaps 1 proxy outside their instance.
23  * These can be constructed local to the object without a great proliferation
24  * of proxies. They simply copy the proxy from someProxy[proxyOffset] for
25  * frequently used proxies.
26  */
27 
28 #ifndef _UBER_H
29 #define _UBER_H
30 
31 #include "configure.h"
32 #include "pup.h"
33 
34 extern Config config;
35 
36 class UberIndex {
37  public:
38  unsigned char x;
39  unsigned char y;
40  unsigned char z;
41  unsigned char s;
42  UberIndex(unsigned char _x, unsigned char _y=0, unsigned char _z=0, unsigned char _s=0) : x(_x), y(_y), z(_z), s(_s){}
43  UberIndex(){x=y=z=s=0;}
44  UberIndex(const UberIndex &obj){x=obj.x;y=obj.y;z=obj.z;s=obj.s;}
45  ~UberIndex(){}
46  inline UberIndex & operator=(const UberIndex &obj) {
47  x=obj.x;
48  y=obj.y;
49  z=obj.z;
50  s=obj.s;
51  return *this;
52  }
53  void pup(PUP::er &p)
54  {
55  p|x;
56  p|y;
57  p|z;
58  p|s;
59  }
60 
61  inline bool operator==(const UberIndex &obj) const {
62  return(x==obj.x && y==obj.y && z==obj.z && s==obj.s);}
63  inline bool operator<(const UberIndex &obj) const {
64  return(x<obj.x && y<=obj.y && z<=obj.z && s <=obj.s);}
65 };
66 
67 //! holds the UberIndex and the offset for proxies
69  public:
70  UberIndex idxU;
71  unsigned char proxyOffset;
72  UberCollection(UberIndex _idxU) : idxU(_idxU) {
73  proxyOffset=calcPO();
74  }
75  UberCollection(unsigned char PO, unsigned char _x, unsigned char _y=0, unsigned char _z=0, unsigned char _s=0) : proxyOffset(PO), idxU(_x,_y,_z,_s) {
76  }
77  UberCollection(unsigned char _proxyOffset) :proxyOffset(_proxyOffset)
78  { // reverse map from the offset onto the index
79  idxU.x = proxyOffset % config.UberImax;
80  idxU.y = (proxyOffset % (config.UberImax * config.UberJmax)) / config.UberImax;
81  idxU.z = (proxyOffset % (config.UberImax * config.UberJmax * config.UberKmax))/(config.UberImax*config.UberJmax);
82  idxU.s = proxyOffset / (config.UberImax * config.UberJmax * config.UberKmax);
83  //CkAssert(calcPO() == _proxyOffset); ///< @note: Commented out just to avoid including extra headers for CkAssert
84  }
85 
86  UberCollection() {}
87  void pup(PUP::er &p)
88  {
89  p|idxU;
90  p|proxyOffset;
91  }
92  inline UberCollection & operator=(const UberCollection &obj) {
93  idxU=obj.idxU;
94  proxyOffset=obj.proxyOffset;
95  return *this;
96  }
97  inline bool operator==(const UberCollection &obj) const {
98  return(idxU==obj.idxU);}
99  inline bool operator<(const UberCollection &obj) const {
100  return(idxU<obj.idxU); }
101 
102  inline unsigned char calcPO()
103  { return (idxU.x + (idxU.y + (idxU.z + idxU.s*config.UberKmax) * config.UberJmax) * config.UberImax);}
104  inline unsigned char getPO() const { return proxyOffset; }
105  inline unsigned char setPO(){ proxyOffset=calcPO(); return proxyOffset;}
106  inline unsigned char setPO(int inPO){ proxyOffset=inPO; return proxyOffset;}
107 
108 };
109 /* @} */
110 #endif
holds the UberIndex and the offset for proxies
Definition: Uber.h:68
Config config
addtogroup Uber
Definition: cpaimd.ci:233
Definition: Uber.h:36