-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstats.cpp
More file actions
161 lines (152 loc) · 5.17 KB
/
stats.cpp
File metadata and controls
161 lines (152 loc) · 5.17 KB
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
#include "asic_core.hh"
#include "network.hh"
#include "stats.hh"
#include "common.hh"
#include "asic.hh"
stats::stats(asic *host) : _asic(host)
{
#if SGU_SLICING == 1 || SGU == 1 || GRAPHMAT_SLICING == 1 || GRAPHMAT == 1 || BLOCKED_ASYNC == 1 // remapping is used in both cases
_stat_extra_finished_edges = (int *)malloc(E * sizeof(int));
#endif
#if TREE_TRAV == 1
_start_cycle_per_query = (int *)malloc(NUM_KNN_QUERIES * sizeof(int));
#endif
for (int i = 0; i < core_cnt; ++i)
{
_stat_correct_edges[i] = 0;
_stat_incorrect_edges[i] = 0;
_stat_stall_thr[i] = 0;
_stat_finished_edges_per_core[i] = 0;
}
_stat_num_clusters = 0;
#if REUSE_STATS == 1
_stat_owned_vertex_freq_per_itn = (int *)malloc(_asic->_graph_vertices * sizeof(int));
_stat_boundary_vertex_freq_per_itn = (int *)malloc(_asic->_graph_vertices * sizeof(int));
_stat_edge_freq_per_itn = (int *)malloc(E * sizeof(int));
_stat_source_copy_vertex_count = (int *)malloc(_asic->_slice_count * sizeof(int));
_is_source_done = (bitset<V> *)malloc(_asic->_slice_count * sizeof(bitset<V>));
reset_freq_stats();
#endif
reset_cache_hit_aware_stats();
}
void stats::reset_freq_stats()
{
for (int i = 0; i < _asic->_graph_vertices; ++i)
{
_stat_owned_vertex_freq_per_itn[i] = 0;
_stat_boundary_vertex_freq_per_itn[i] = 0;
}
for (int i = 0; i < _asic->_graph_edges; ++i)
{
_stat_edge_freq_per_itn[i] = 0;
}
_stat_source_copy_vertex_count[_asic->_current_slice] = 0;
_is_source_done[_asic->_current_slice].reset();
}
int stats::get_bucket_num(int i)
{
if (i == 0)
return 0;
if (i == 1)
return 1;
int x = log2(i); // if 2,3 it will output 1+2=3, if 4 it will output
if (x + 2 > 9)
x = 7;
return x + 2;
}
/*Expectations for different algos: (Should have slicing)
*Sync: owned vertices should be high, low for bdary and 0/1 for edges
*Sync-iter: same as above, edges should have higher
*Async: all same as above (freq should be slightly higher for all)
*Bulk-async: same as sync
*Also area should vary with the algorithm
*/
// TODO: maybe need to find average across slices...
void stats::print_freq_stats()
{
int freq[10];
for (int i = 0; i < 10; ++i)
freq[i] = 0;
cout << "Owned vertices\n";
for (int i = 0; i < _asic->_graph_vertices; ++i)
{
freq[get_bucket_num(_stat_owned_vertex_freq_per_itn[i])]++;
// cout << _stat_owned_vertex_freq_per_itn[i] << " ";
}
for (int i = 0; i < 10; ++i)
{
int id = pow(2, i - 1); // for 0, this will be 0.5
cout << "ovindex: " << id << ": " << freq[i] << endl;
// if(i==0) cout << "ovindex: 0: " << freq[i] << endl;
// if(i==1) cout << "ovindex: 1: " << freq[i] << endl;
// if(i>1) cout << "start:" << pow(2,i-1) << " end: " << pow(2,i) << " ovindex: " << freq[i] << endl;
freq[i] = 0;
}
cout << endl;
cout << "Boundary vertices\n";
for (int i = 0; i < _asic->_graph_vertices; ++i)
{
freq[get_bucket_num(_stat_boundary_vertex_freq_per_itn[i])]++;
// cout << _stat_boundary_vertex_freq_per_itn[i] << " ";
}
for (int i = 0; i < 10; ++i)
{
int id = pow(2, i - 1); // for 0, this will be 0.5
cout << "bvindex: " << id << ": " << freq[i] << endl;
// if(i==0) cout << "bvindex: 0: " << freq[i] << endl;
// if(i==1) cout << "bvindex: 1: " << freq[i] << endl;
// if(i>1) cout << "start:" << pow(2,i-1) << " end: " << pow(2,i) << " bvindex: " << freq[i] << endl;
freq[i] = 0;
}
cout << endl;
cout << "Edges\n";
for (int i = 0; i < _asic->_graph_edges; ++i)
{
freq[get_bucket_num(_stat_edge_freq_per_itn[i])]++;
// cout << _stat_edge_freq_per_itn[i] << " ";
}
for (int i = 0; i < 10; ++i)
{
int id = pow(2, i - 1); // for 0, this will be 0.5
cout << "eindex: " << id << ": " << freq[i] << endl;
// if(i==0) cout << "eindex: 0: " << freq[i] << endl;
// if(i==1) cout << "eindex: 1: " << freq[i] << endl;
// if(i>1) cout << "start:" << pow(2,i-1) << " end: " << pow(2,i) << " efreq: " << freq[i] << endl;
freq[i] = 0;
}
cout << endl;
cout << "Source boundary vertices\n";
// copy vertex count for the current slice (from prev iterations)
// FIXME: It should be average over all slices (no concept of per_slice)
for (int i = 0; i < _asic->_graph_vertices; ++i)
{
if (_is_source_done[_asic->_current_slice].test(i))
{
int bucket = get_bucket_num(_asic->_offset[i + 1] - _asic->_offset[i]);
freq[bucket]++;
}
}
for (int i = 0; i < 10; ++i)
{
int id = pow(2, i - 1); // for 0, this will be 0.5
cout << "sbindex: " << id << ": " << freq[i] << endl;
// if(i==0) cout << "sbindex: 0: " << freq[i] << endl;
// if(i==1) cout << "sbindex: 1: " << freq[i] << endl;
// if(i>1) cout << "start:" << pow(2,i-1) << " end: " << pow(2,i) << " sbfreq: " << freq[i] << endl;
freq[i] = 0;
}
cout << endl;
}
void stats::reset_cache_hit_aware_stats()
{
for (int c = 0; c < core_cnt; ++c)
{
_stat_tot_prefetch_updates_occupancy[c] = 0;
_stat_tot_priority_hit_updates_occupancy[c] = 0;
_stat_tot_hit_updates_occupancy[c] = 0;
_stat_tot_miss_updates_occupancy[c] = 0;
_stat_tot_hit_updates_served[c] = 0;
_stat_tot_miss_updates_served[c] = 0;
_stat_tot_priority_hit_updates_served[c] = 0;
}
}