-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathState.h
100 lines (81 loc) · 1.84 KB
/
State.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
#ifndef __STATE_H__
#define __STATE_H__
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
using namespace std;
extern string NodeTypeString[];
class TreePiece;
struct State {
int pending;
int current;
Node<ForceData> **currentBucketPtr;
TreePiece *ownerTreePiece;
#ifdef DEBUG_TRAVERSALS
map<Key,set<Key> > bucketKeys;
string description;
#endif
#ifdef STATISTICS
CmiUInt8 numInteractions[3];
#endif
void incrPending() { pending++; }
bool decrPending() {
pending--;
return complete();
}
bool decrPending(int n){
pending -= n;
return complete();
}
bool complete() { return (pending == 0); }
State() :
pending(-1),
current(-1),
currentBucketPtr(NULL),
ownerTreePiece(NULL)
{
#ifdef STATISTICS
numInteractions[0] = 0;
numInteractions[1] = 0;
numInteractions[2] = 0;
#endif
}
void reset(TreePiece *owner, int p, Node<ForceData> **bucketPtr){
ownerTreePiece = owner;
pending = p;
current = 0;
currentBucketPtr = bucketPtr;
}
void nodeEncountered(Key bucketKey, Node<ForceData> *node);
void nodeOpened(Key bucketKey, Node<ForceData> *node);
void nodeDiscarded(Key bucketKey, Node<ForceData> *node);
void nodeComputed(Node<ForceData> *bucket, Key nodeKey);
void bucketComputed(Node<ForceData> *bucket, Key k);
void finishedIteration(){
#ifdef STATISTICS
numInteractions[0] = 0;
numInteractions[1] = 0;
numInteractions[2] = 0;
#endif
}
void insert(Key bucketKey, Key k){
}
void incrPartNodeInteractions(Key bucketKey, CmiUInt8 n){
#ifdef STATISTICS
numInteractions[0] += n;
#endif
}
void incrPartPartInteractions(Key bucketKey, CmiUInt8 n){
#ifdef STATISTICS
numInteractions[1] += n;
#endif
}
void incrOpenCriterion(){
#ifdef STATISTICS
numInteractions[2]++;
#endif
}
};
#endif