changa  3.5
 All Classes Files Functions Variables Typedefs Enumerations Friends Macros Groups Pages
Opt.h
Go to the documentation of this file.
1 #ifndef __OPT_H__
2 #define __OPT_H__
3 
8 #include "codes.h"
9 
11 
12 class Opt{
13  protected:
14  int action_array[2][NUM_NODE_TYPES+1];
15  OptType type;
16  Opt(OptType _type) : type(_type) {}
17  public:
18 
22 
23  int action(int openDecision, GenericTreeNode *node){
24  return action_array[openDecision][node->getType()];
25  }
26  OptType getSelfType() {return type;}
27 };
28 
30 class RemoteOpt : public Opt{
31  public:
32  RemoteOpt() : Opt(Remote){
33  // don't need to open
34  //
35  // local data
36  action_array[0][Bucket] = DUMP;
37  action_array[0][Internal] = DUMP;
38  /*
39  action_array[0][Boundary] = COMPUTE;
40  action_array[0][NonLocal] = COMPUTE;
41  action_array[0][NonLocalBucket] = COMPUTE;
42  action_array[0][Cached] = COMPUTE;
43  action_array[0][CachedBucket] = COMPUTE;
44  */
45  action_array[0][Boundary] = DUMP;
46  // XXX - changed to COMPUTE from DUMP. see below also
47  action_array[0][NonLocal] = COMPUTE;
48  action_array[0][NonLocalBucket] = DUMP;
49 
50  // changed these two to COMPUTE from DEFER
51  action_array[0][Cached] = COMPUTE;
52  action_array[0][CachedBucket] = COMPUTE;
53 
54  action_array[0][CachedEmpty] = DUMP;
55 
56  action_array[0][Empty] = DUMP;
57  action_array[0][Top] = ERROR;
58  action_array[0][Invalid] = ERROR;
59 
60  // need to open
61  //
62  // local data
63  action_array[1][Internal] = DUMP;
64  action_array[1][Bucket] = DUMP;
65 
66  // non-local data
67  action_array[1][NonLocal] = KEEP;
68  action_array[1][NonLocalBucket] = KEEP_REMOTE_BUCKET;
69  action_array[1][Boundary] = KEEP;
70 
71  action_array[1][Cached] = KEEP;
72  action_array[1][CachedBucket] = KEEP_REMOTE_BUCKET;
73 
74  // in this case, ancestors of CachedEmpty nodes must be checked as well
75  action_array[1][CachedEmpty] = DUMP;
76 
77  action_array[1][Top] = ERROR;
78  action_array[1][Invalid] = ERROR;
79  action_array[1][Empty] = DUMP;
80 
81  }
82 
83 };
84 
86 class LocalOpt : public Opt{
87  public:
88  LocalOpt() : Opt(Local){
89  // don't need to open
90  // these nodes are your concern
91  action_array[0][Internal] = COMPUTE;
92  action_array[0][Bucket] = COMPUTE;
93 
94  action_array[0][Boundary] = COMPUTE;
95  // XXX - changed to DUMP from COMPUTE
96  action_array[0][NonLocal] = DUMP;
97  action_array[0][NonLocalBucket] = COMPUTE;
98  // changed these to DUMP from COMPUTE - remote does computation now
99  action_array[0][Cached] = DUMP;
100  action_array[0][CachedBucket] = DUMP;
101 
102  // these nodes are no one's concern
103  action_array[0][Empty] = DUMP;
104  action_array[0][CachedEmpty] = DUMP;
105  action_array[0][Top] = ERROR;
106  action_array[0][Invalid] = ERROR;
107  //--------------
108  // need to open node
109  // local data
110  action_array[1][Internal] = KEEP;
111  action_array[1][Bucket] = KEEP_LOCAL_BUCKET;
112  action_array[1][Boundary] = KEEP;
113 
114  // remote data
115  action_array[1][NonLocal] = DUMP;
116  action_array[1][NonLocalBucket] = DUMP;
117  // remote opt KEEPs Cached and KEEP_REMOTE_BUCKETs CachedBucket
118  action_array[1][CachedBucket] = DUMP;
119  action_array[1][Cached] = DUMP;
120 
121  // discard
122  action_array[1][Empty] = DUMP;
123  action_array[1][CachedEmpty] = DUMP;
124  action_array[1][Top] = ERROR;
125  action_array[1][Invalid] = ERROR;
126  }
127 
128 };
129 
131 
132 class PushGravityOpt : public Opt{
133  public:
134  PushGravityOpt() : Opt(PushGravity){
135  // don't need to open node
136  // these nodes are your concern
137  action_array[0][Internal] = COMPUTE;
138  action_array[0][Bucket] = COMPUTE;
139 
140  action_array[0][Boundary] = KEEP;
141  // XXX - changed to DUMP from COMPUTE
142  action_array[0][NonLocal] = DUMP;
143  action_array[0][NonLocalBucket] = DUMP;
144  // changed these to DUMP from COMPUTE - remote does computation now
145  action_array[0][Cached] = DUMP;
146  action_array[0][CachedBucket] = DUMP;
147 
148  // these nodes are no one's concern
149  action_array[0][Empty] = DUMP;
150  action_array[0][CachedEmpty] = DUMP;
151  action_array[0][Top] = ERROR;
152  action_array[0][Invalid] = ERROR;
153  //--------------
154  // need to open node
155  // local data
156  action_array[1][Internal] = KEEP;
157  action_array[1][Bucket] = KEEP_LOCAL_BUCKET;
158  action_array[1][Boundary] = KEEP;
159 
160  // remote data
161  action_array[1][NonLocal] = DUMP;
162  action_array[1][NonLocalBucket] = DUMP;
163  // remote opt KEEPs Cached and KEEP_REMOTE_BUCKETs CachedBucket
164  action_array[1][CachedBucket] = DUMP;
165  action_array[1][Cached] = DUMP;
166 
167  // discard
168  action_array[1][Empty] = DUMP;
169  action_array[1][CachedEmpty] = DUMP;
170  action_array[1][Top] = ERROR;
171  action_array[1][Invalid] = ERROR;
172  }
173 
174 };
175 
177 
178 class PrefetchOpt : public Opt{
179  public:
180  PrefetchOpt() : Opt(Pref){
181  for(int i = 1; i <= NUM_NODE_TYPES; i++)
182  action_array[0][i] = DUMP;
183  action_array[0][Invalid] = ERROR;
184  action_array[0][Top] = ERROR;
185 
186  action_array[1][Internal] = DUMP;
187  action_array[1][Bucket] = DUMP;
188 
189  action_array[1][Boundary] = KEEP;
190  // we KEEP NonLocal nodes, even though we don't have their
191  // children - the tw object will request the children if need be
192  action_array[1][NonLocal] = KEEP;
193  action_array[1][NonLocalBucket] = KEEP_REMOTE_BUCKET;
194  action_array[1][Cached] = KEEP;
195  action_array[1][CachedBucket] = KEEP_REMOTE_BUCKET;
196 
197  action_array[1][CachedEmpty] = DUMP;
198  action_array[1][Empty] = DUMP;
199  action_array[1][Invalid] = ERROR; // node not properly initialized
200  action_array[1][Top] = ERROR; // not handled anywhere in the original code, so ERROR
201  }
202 };
203 #endif
Optimization for Prefetch walk.
Definition: Opt.h:178
Class for optimizing remote gravity walk actions.
Definition: Opt.h:30
int action(int openDecision, GenericTreeNode *node)
Definition: Opt.h:23
Class for optimizing local gravity walk actions.
Definition: Opt.h:86
Class for optimizing experimental &quot;push&quot; gravity walk actions.
Definition: Opt.h:132
Base class for optimizing walk actions.
Definition: Opt.h:12