FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
PerformanceAnalysis/test/test_ad.cpp at master · CODARcode/PerformanceAnalysis · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
CODARcode
/
PerformanceAnalysis
Public
Notifications
You must be signed in to change notification settings
Fork
5
Star
2
Code
Issues
0
Pull requests
11
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
PerformanceAnalysis
/
test
/
test_ad.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
412 lines (339 loc) · 12.7 KB
Breadcrumbs
PerformanceAnalysis
/
test
/
test_ad.cpp
Copy path
File metadata and controls
executable file
·
412 lines (339 loc) · 12.7 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#
include
<
chimbuko_config.h
>
#
ifdef
USE_MPI
#
include
<
mpi.h
>
#
endif
#
include
"
chimbuko/modules/performance_analysis/chimbuko.hpp
"
#
include
<
gtest/gtest.h
>
#
include
<
chrono
>
#
include
<
thread
>
using
namespace
chimbuko
;
using
namespace
chimbuko
::modules::performance_analysis
;
#
ifdef
USE_MPI
class
ADTest
: public ::testing::Test
{
protected:
int
world_rank, world_size;
virtual
void
SetUp
()
{
MPI_Comm_rank
(
MPI_COMM_WORLD
, &world_rank);
MPI_Comm_size
(
MPI_COMM_WORLD
, &world_size);
}
virtual
void
TearDown
()
{
}
template
<
typename
K,
typename
V>
void
show_map
(
const
std::unordered_map<K, V>& m)
{
for
(
const
auto
& it : m)
{
std::cout << it.
first
<<
"
:
"
<< it.
second
<< std::endl;
}
}
};
TEST_F
(ADTest, EnvTest)
{
EXPECT_EQ
(
4
, world_size);
}
TEST_F
(ADTest, BpfileTest)
{
const
std::vector<
int
>
N_STEPS
{
7
,
7
,
7
,
7
};
//
Below indexed by [rank][step] for 4 ranks
const
std::vector<std::vector<
size_t
>>
N_FUNC
{
{
57077
,
51845
,
60561
,
63278
,
64628
,
66484
,
42233
},
{
41215
,
51375
,
56620
,
57683
,
58940
,
61010
,
41963
},
{
41108
,
50820
,
57237
,
56590
,
63458
,
63931
,
42486
},
{
40581
,
51127
,
59175
,
58158
,
60465
,
62516
,
41238
}
};
const
std::vector<std::vector<
size_t
>>
N_COMM
{
{
89349
,
107207
,
121558
,
123381
,
128682
,
131611
,
83326
},
{
78250
,
94855
,
106301
,
107222
,
111581
,
114273
,
77817
},
{
77020
,
93355
,
105238
,
106608
,
114192
,
118530
,
79135
},
{
77332
,
93027
,
107856
,
107628
,
112019
,
116468
,
74517
}
};
const
std::vector<std::vector<
unsigned
long
>>
N_OUTLIERS
{
{
137
,
82
,
94
,
95
,
90
,
91
,
51
},
{
90
,
60
,
78
,
75
,
54
,
68
,
37
},
{
94
,
79
,
80
,
87
,
92
,
92
,
47
},
{
93
,
81
,
100
,
81
,
78
,
85
,
61
}
};
ChimbukoParams params;
params.
base_params
.
rank
= world_rank;
params.
trace_data_dir
=
"
./data
"
;
params.
trace_inputFile
=
"
tau-metrics-
"
+
std::to_string
(world_rank) +
"
.bp
"
;
params.
trace_engineType
=
"
BPFile
"
;
params.
base_params
.
prov_outputpath
=
"
./temp
"
;
//
have to output somewhere if provdb not in use
params.
base_params
.
algo_params
.
sstd_sigma
=
6.0
;
params.
base_params
.
algo_params
.
algorithm
=
"
sstd
"
;
params.
base_params
.
only_one_frame
=
true
;
//
just analyze first IO frame
params.
anom_win_size
=
0
;
Chimbuko driver;
int
step;
unsigned
long
n_outliers =
0
, frames =
0
;
unsigned
long
long
n_func_events =
0
, n_comm_events =
0
, n_counter_events =
0
;
try
{
driver.
initialize
(params);
}
catch
(
const
std::exception &e){
std::cerr <<
"
Caught exception during driver init:
"
<< e.
what
() << std::endl;
throw
e;
}
std::vector<std::vector<
unsigned
long
> >
N_FUNC_ACTUAL
(
4
);
std::vector<std::vector<
unsigned
long
> >
N_COMM_ACTUAL
(
4
);
std::vector<std::vector<
unsigned
long
> >
N_OUTLIERS_ACTUAL
(
4
);
while
( driver.
get_status
() )
{
try
{
frames = driver.
run
();
}
catch
(
const
std::exception &e){
std::cerr <<
"
Caught exception in driver run:
"
<< e.
what
() << std::endl;
throw
e;
}
if
(frames ==
0
)
break
;
//
last call to run will not analyze any frames
//
if (driver.getStep() == -1)
//
break;
step = driver.
getStep
()-
1
;
//
this is the index of the step just completed; the current step is the one after!
std::cout <<
"
Checking results for step
"
<< step << std::endl;
//
FIXME: Add an expect for the counter events
EXPECT_EQ
(
N_FUNC
[world_rank][step], driver.
getRunStats
().
n_func_events
);
EXPECT_EQ
(
N_COMM
[world_rank][step], driver.
getRunStats
().
n_comm_events
);
EXPECT_EQ
(
N_OUTLIERS
[world_rank][step], driver.
getBaseRunStats
().
n_outliers
);
N_FUNC_ACTUAL
[world_rank].
push_back
(driver.
getRunStats
().
n_func_events
);
N_COMM_ACTUAL
[world_rank].
push_back
(driver.
getRunStats
().
n_comm_events
);
N_OUTLIERS_ACTUAL
[world_rank].
push_back
(driver.
getBaseRunStats
().
n_outliers
);
}
int
nstep = step+
1
;
EXPECT_EQ
(
N_STEPS
[world_rank], nstep);
if
(!world_rank) std::cout <<
"
Steps performed:
"
<< nstep << std::endl;
MPI_Barrier
(
MPI_COMM_WORLD
);
//
For gathering actual event counts, check
int
nsteps_check[
4
] = {
0
,
0
,
0
,
0
};
nsteps_check[world_rank] = nstep;
MPI_Allreduce
(
MPI_IN_PLACE
, nsteps_check,
4
,
MPI_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
bool
fail =
false
;
for
(
int
i=
0
;i<
4
;i++)
if
(nsteps_check[i] != nstep){
fail =
true
;
break
;
}
if
(!fail){
//
Fill in zeroes for other ranks
for
(
int
i=
0
;i<
4
;i++){
if
(i!=world_rank){
N_FUNC_ACTUAL
[i].
resize
(nstep,
0
);
N_COMM_ACTUAL
[i].
resize
(nstep,
0
);
N_OUTLIERS_ACTUAL
[i].
resize
(nstep,
0
);
}
}
//
Use global sum to sync all data to root
for
(
int
i=
0
;i<
4
;i++){
MPI_Allreduce
(
MPI_IN_PLACE
,
N_FUNC_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
MPI_IN_PLACE
,
N_COMM_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
MPI_IN_PLACE
,
N_OUTLIERS_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
}
if
(world_rank ==
0
){
std::cout <<
"
Actual value tables:
"
<< std::endl;
std::cout <<
"
FUNC:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_FUNC_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
std::cout <<
"
COMM:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_COMM_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
std::cout <<
"
OUTLIERS:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_OUTLIERS_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
}
}
//
Check an end-to-end run without breaking up into steps
driver.
finalize
();
params.
base_params
.
only_one_frame
=
false
;
driver.
initialize
(params);
try
{
frames = driver.
run
();
}
catch
(
const
std::exception &e){
std::cerr <<
"
Caught exception in driver run:
"
<< e.
what
() << std::endl;
throw
e;
}
EXPECT_EQ
(
N_STEPS
[world_rank], frames);
unsigned
long
func_tot =
0
, comm_tot=
0
, outlier_tot =
0
;
for
(
int
step=
0
;step<
N_STEPS
[world_rank];step++){
func_tot +=
N_FUNC
[world_rank][step];
comm_tot +=
N_COMM
[world_rank][step];
outlier_tot +=
N_OUTLIERS
[world_rank][step];
}
EXPECT_EQ
(func_tot, driver.
getRunStats
().
n_func_events
);
EXPECT_EQ
(comm_tot, driver.
getRunStats
().
n_comm_events
);
EXPECT_EQ
(outlier_tot, driver.
getBaseRunStats
().
n_outliers
);
}
TEST_F
(ADTest, BpfileWithNetTest)
{
const
std::vector<
int
>
N_STEPS
{
7
,
7
,
7
,
7
};
const
std::vector<std::vector<
size_t
>>
N_FUNC
{
{
57077
,
51845
,
60561
,
63278
,
64628
,
66484
,
42233
},
{
41215
,
51375
,
56620
,
57683
,
58940
,
61010
,
41963
},
{
41108
,
50820
,
57237
,
56590
,
63458
,
63931
,
42486
},
{
40581
,
51127
,
59175
,
58158
,
60465
,
62516
,
41238
}
};
//
[rank][step]
const
std::vector<std::vector<
size_t
>>
N_COMM
{
{
89349
,
107207
,
121558
,
123381
,
128682
,
131611
,
83326
},
{
78250
,
94855
,
106301
,
107222
,
111581
,
114273
,
77817
},
{
77020
,
93355
,
105238
,
106608
,
114192
,
118530
,
79135
},
{
77332
,
93027
,
107856
,
107628
,
112019
,
116468
,
74517
}
};
//
[rank][step]
const
std::vector<std::vector<
unsigned
long
>>
N_OUTLIERS
{
{
137
,
52
,
67
,
71
,
64
,
74
,
30
},
{
102
,
64
,
85
,
80
,
55
,
61
,
33
},
{
76
,
50
,
56
,
63
,
83
,
76
,
52
},
{
77
,
55
,
94
,
61
,
49
,
68
,
33
}
};
//
[rank][step]
ChimbukoParams params;
params.
base_params
.
rank
= world_rank;
params.
base_params
.
verbose
= world_rank ==
0
;
params.
trace_data_dir
=
"
./data
"
;
params.
trace_inputFile
=
"
tau-metrics-
"
+
std::to_string
(world_rank) +
"
.bp
"
;
params.
trace_engineType
=
"
BPFile
"
;
params.
base_params
.
prov_outputpath
=
"
./temp
"
;
params.
anom_win_size
=
0
;
params.
base_params
.
pserver_addr
=
"
tcp://localhost:5559
"
;
//
connect to the pserver
#
ifdef
_PERF_METRIC
params.
base_params
.
perf_outputpath
=
"
./perf
"
;
params.
base_params
.
perf_step
=
1
;
#
endif
params.
base_params
.
algo_params
.
sstd_sigma
=
6.0
;
params.
base_params
.
algo_params
.
algorithm
=
"
sstd
"
;
params.
base_params
.
only_one_frame
=
true
;
Chimbuko driver;
int
step;
unsigned
long
n_outliers =
0
, frames =
0
;
unsigned
long
long
n_func_events =
0
, n_comm_events =
0
, n_counter_events =
0
;
try
{
driver.
initialize
(params);
}
catch
(
const
std::exception &e){
std::cerr <<
"
Caught exception during driver init:
"
<< e.
what
() << std::endl;
throw
e;
}
std::vector<std::vector<
unsigned
long
> >
N_FUNC_ACTUAL
(
4
);
std::vector<std::vector<
unsigned
long
> >
N_COMM_ACTUAL
(
4
);
std::vector<std::vector<
unsigned
long
> >
N_OUTLIERS_ACTUAL
(
4
);
while
( driver.
get_status
() )
{
//
for the test purpose, we serialize the excution for run()
int
token =
1
;
if
(world_rank !=
0
) {
MPI_Recv
(&token,
1
,
MPI_INT
, world_rank-
1
,
0
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
}
try
{
frames = driver.
run
();
}
catch
(
const
std::exception &e){
std::cerr <<
"
Caught exception in driver run:
"
<< e.
what
() << std::endl;
throw
e;
}
MPI_Send
(&token,
1
,
MPI_INT
, (world_rank+
1
)%world_size,
0
,
MPI_COMM_WORLD
);
if
(world_rank ==
0
) {
MPI_Recv
(&token,
1
,
MPI_INT
, world_size-
1
,
0
,
MPI_COMM_WORLD
,
MPI_STATUS_IGNORE
);
}
if
(frames >
0
)
{
step = driver.
getStep
() -
1
;
//
the step that just completed; the current value is for the next step
if
(!world_rank) std::cout <<
"
Checking data for step
"
<< step << std::endl;
//
FIXME: Add expect for counter events
EXPECT_EQ
(
N_FUNC
[world_rank][step], driver.
getRunStats
().
n_func_events
);
EXPECT_EQ
(
N_COMM
[world_rank][step], driver.
getRunStats
().
n_comm_events
);
EXPECT_EQ
(
N_OUTLIERS
[world_rank][step], driver.
getBaseRunStats
().
n_outliers
);
N_FUNC_ACTUAL
[world_rank].
push_back
(driver.
getRunStats
().
n_func_events
);
N_COMM_ACTUAL
[world_rank].
push_back
(driver.
getRunStats
().
n_comm_events
);
N_OUTLIERS_ACTUAL
[world_rank].
push_back
(driver.
getBaseRunStats
().
n_outliers
);
}
}
int
nstep = step+
1
;
EXPECT_EQ
(
N_STEPS
[world_rank], nstep);
if
(!world_rank) std::cout <<
"
Steps performed:
"
<< nstep << std::endl;
MPI_Barrier
(
MPI_COMM_WORLD
);
//
For gathering actual event counts, check
int
nsteps_check[
4
] = {
0
,
0
,
0
,
0
};
nsteps_check[world_rank] = nstep;
MPI_Allreduce
(
MPI_IN_PLACE
, nsteps_check,
4
,
MPI_INT
,
MPI_SUM
,
MPI_COMM_WORLD
);
bool
fail =
false
;
for
(
int
i=
0
;i<
4
;i++)
if
(nsteps_check[i] != nstep){
fail =
true
;
break
;
}
if
(!fail){
//
Fill in zeroes for other ranks
for
(
int
i=
0
;i<
4
;i++){
if
(i!=world_rank){
N_FUNC_ACTUAL
[i].
resize
(nstep,
0
);
N_COMM_ACTUAL
[i].
resize
(nstep,
0
);
N_OUTLIERS_ACTUAL
[i].
resize
(nstep,
0
);
}
}
//
Use global sum to sync all data to root
for
(
int
i=
0
;i<
4
;i++){
MPI_Allreduce
(
MPI_IN_PLACE
,
N_FUNC_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
MPI_IN_PLACE
,
N_COMM_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
MPI_Allreduce
(
MPI_IN_PLACE
,
N_OUTLIERS_ACTUAL
[i].
data
(), nstep,
MPI_UNSIGNED_LONG
,
MPI_SUM
,
MPI_COMM_WORLD
);
}
if
(world_rank ==
0
){
std::cout <<
"
Actual value tables:
"
<< std::endl;
std::cout <<
"
FUNC:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_FUNC_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
std::cout <<
"
COMM:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_COMM_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
std::cout <<
"
OUTLIERS:
"
<< std::endl;
for
(
int
i=
0
;i<
4
;i++){
for
(
int
j=
0
;j<nstep;j++)
std::cout <<
N_OUTLIERS_ACTUAL
[i][j] << (j==nstep-
1
?
"
"
:
"
,
"
);
std::cout << std::endl;
}
}
}
}
TEST_F
(ADTest, ReadExecDataTest)
{
//
TODO: Update to check provenance data dump
#
if
0
const std::vector<int> N_STEPS{6, 6, 6, 6};
const std::vector<std::vector<unsigned long>> N_OUTLIERS{
{137, 52, 67, 71, 64, 74, 30},
{102, 64, 85, 80, 55, 61, 33},
{76, 50, 56, 63, 83, 76, 52},
{77, 55, 94, 61, 49, 68, 33}
}; //[rank][step]
std::string execOutput = "temp/0/" + std::to_string(world_rank);
for (int i = 0; i < N_STEPS[world_rank]; i++)
{
std::ifstream f;
f.open(execOutput + "/" + std::to_string(i) + ".json");
ASSERT_TRUE(f.is_open());
nlohmann::json j;
std::string s;
f.seekg(0, std::ios::end);
s.reserve(f.tellg());
f.seekg(0, std::ios::beg);
s.assign(std::istreambuf_iterator<char>(f), std::istreambuf_iterator<char>());
j = nlohmann::json::parse(s);
// if (world_rank == 0 && i == 0)
// {
// std::cout << j.dump(2) << std::endl;
// }
EXPECT_EQ(N_OUTLIERS[world_rank][i], j["exec"].size());
}
#
endif
}
#
endif
Back
|
FazBrowse Home
|
New Git URL