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