-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathnet_test.c
More file actions
348 lines (321 loc) · 12 KB
/
net_test.c
File metadata and controls
348 lines (321 loc) · 12 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
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
/*
This file is part of SystemConfidence.
Copyright (C) 2012, UT-Battelle, LLC.
This product includes software produced by UT-Battelle, LLC under Contract No.
DE-AC05-00OR22725 with the Department of Energy.
This program is free software; you can redistribute it and/or modify
it under the terms of the New BSD 3-clause software license (LICENSE).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
LICENSE for more details.
For more information please contact the SystemConfidence developers at:
systemconfidence-info@googlegroups.com
*/
/**
* \brief Tests a single (simultaneous, bidirectional) exchange, but extracts
* both one-sided and pairwise variability.
*
* Pros:
* - Assesses both one-sided and pairwise variability with minimal averaging
* - Provides a Least Upper Bound of the network's minimum latency
* - Quantifies network topology effects
* - Provides a baseline minimum for comparison
*
* Cons:
* - Requires additional storage
*/
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdio.h>
#include <errno.h>
#include "config.h"
#include "orbtimer.h"
#include "comm.h"
#include "tests.h"
#include "measurement.h"
#ifdef SHMEM
#include <mpp/shmem.h>
#else
#include <mpi.h>
#endif
/* number of network latency histograms */
#define NET_LEN 9
/* histograms for network latency measurements */
enum net_vars {
/* timer overhead */
timer,
/* local communication */
onNodeOnesided, onNodePairwise,
onNodeOnesidedMinimum, onNodePairwiseMinimum,
/* remote communication */
offNodeOnesided, offNodePairwise,
offNodeOnesidedMinimum, offNodePairwiseMinimum
};
char *net_labels[] = {
/* timer overhead */
"timer",
/* local communication */
"onNodeOnesided", "onNodePairwise",
"onNodeOnesidedMinimum", "onNodePairwiseMinimum",
/* remote communication */
"offNodeOnesided", "offNodePairwise",
"offNodeOnesidedMinimum", "offNodePairwiseMinimum"
};
/**
\brief Create the measurement struct for the test
\param tst Will tell the test how many times to run
\param label A label for the measurement struct
*/
measurement_p net_measurement_create(test_p tst, char *label) {
int i;
measurement_p m = measurement_real_create(tst, label, NET_LEN);
for (i = 0; i < NET_LEN; i++)
strncpy(m->hist[i].label,net_labels[i],LABEL_LEN);
return m;
}
/**
\brief Exchanges messages between all the nodes on the system to test the network connections between them
\param tst Tells how many cycles to run the test
\param m Collects measurement data from the test
*/
void net_SHMEM_test(test_p tst, measurement_p m) {
#ifdef SHMEM
static int sync;
sync = my_rank;
buffer_t *sbuf, *rbuf;
double *cos, *cpw, *t;
int i, icycle, istage, partner_rank;
ORB_t t1, t2, t3;
//Make
sbuf = comm_newbuffer(m->buflen); /* exchange buffers */
rbuf = comm_newbuffer(m->buflen);
cos = (double *)shmalloc(tst->num_messages * sizeof(double)); /* array for onesided kernel timings */
assert(cos != NULL);
cpw = (double *)malloc(tst->num_messages * sizeof(double)); /* array for pairwise kernel timings */
assert(cpw != NULL);
t = (double *)malloc(tst->num_messages * sizeof(double)); /* array for timer overhead timings */
assert(t != NULL);
// Exec
/* calibrate timer */
ORB_calibrate();
/* pre-synchronize all tasks */
shmem_barrier_all();
/*****************************************************************************
* A full set of samples for this task consists of message exchanges with each
* possible partner. The innermost loop below exchanges some number of messages
* between a particular pairing of partners. The middle loop steps through the
* possible partners. While the outmost allows us to aggregate multiple sets
* of samples to increase the total number of samples.
*****************************************************************************/
for (icycle = 0; icycle < tst->num_cycles; icycle++) {
/* step through the stage schedule */
for (istage = 0; istage < tst->num_stages; istage++) {
shmem_barrier_all();
/* who's my buddy for this stage? */
partner_rank = my_rank ^ istage;
/* valid pairing */
if ((partner_rank < num_ranks) && (partner_rank != my_rank)) {
/* valid pair, proceed with test */
/***************************************/
/* warm-up / pre-synchronize this pair */
/***************************************/
for (i = 0; i < tst->num_warmup; i++) {
ORB_read(t1);
ORB_read(t2);
shmem_getmem(rbuf->data, sbuf->data, m->buflen, partner_rank);
ORB_read(t3);
}
/* synchronize partners */
shmem_int_p(&sync, my_rank, partner_rank);
shmem_int_wait_until(&sync, SHMEM_CMP_EQ, partner_rank);
sync = my_rank;
/************************************************************/
/* BEGIN PERFORMANCE KERNEL -- gather samples for this pair */
/************************************************************/
for (i = 0; i < tst->num_messages; i++) {
/* for timer overhead estimate */
ORB_read(t1);
ORB_read(t2);
/***************************************/
/* begin timed communication primitive */
/***************************************/
shmem_getmem(rbuf->data, sbuf->data, m->buflen, partner_rank);
/*************************************/
/* end timed communication primitive */
/*************************************/
ORB_read(t3);
/* save the timings */
t[i] = ORB_seconds(t2, t1);
cos[i] = ORB_seconds(t3, t2);
}
/************************************************************/
/* END PERFORMANCE KERNEL -- samples gathered for this pair */
/************************************************************/
/* ensure partner has completed sample collection */
shmem_int_p(&sync, my_rank, partner_rank);
shmem_int_wait_until(&sync, SHMEM_CMP_EQ, partner_rank);
sync = my_rank;
/* get partner's array of local timings */
shmem_double_get(cpw, cos, tst->num_messages, partner_rank);
/* pairwise as average, comparable to one-sided */
for (i = 0; i < tst->num_messages; i++) {
cpw[i] = (cpw[i] + cos[i]) / 2.0;
}
/* bin the t, cos, and cpw results for this cycle of this pair in p */
net_measurement_bin(tst, m, t, cos, cpw, (node_id[my_rank] == node_id[partner_rank]));
} /* if valid pairing */
} /* for istage */
} /* for icycle */
// Kill
free(t);
free(cpw);
shfree(cos);
comm_freebuffer(rbuf);
comm_freebuffer(sbuf);
#endif
return;
}
/**
\brief Exchanges messages between all the nodes on the system to test the network connections between them
\param tst Tells how many cycles to run the test
\param m Collects measurement data from the test
*/
void net_MPI_test(test_p tst, measurement_p m) {
#ifndef SHMEM
buffer_t *sbuf, *rbuf;
double *cos, *cpw, *t;
int i, icycle, istage, ierr, partner_rank;
ORB_t t1, t2, t3;
MPI_Status mpistatus;
sbuf = comm_newbuffer(m->buflen); /* exchange buffers */
rbuf = comm_newbuffer(m->buflen);
cos = (double *)malloc(tst->num_messages * sizeof(double)); /* array for onesided kernel timings */
assert(cos != NULL);
cpw = (double *)malloc(tst->num_messages * sizeof(double)); /* array for pairwise kernel timings */
assert(cpw != NULL);
t = (double *)malloc(tst->num_messages * sizeof(double)); /* array for timer overhead timings */
assert(t != NULL);
/* calibrate timer */
ORB_calibrate();
/* pre-synchronize all tasks */
ierr = MPI_Barrier(MPI_COMM_WORLD);
/*****************************************************************************
* A full set of samples for this task consists of message exchanges with each
* possible partner. The innermost loop below exchanges some number of messages
* between a particular pairing of partners. The middle loop steps through the
* possible partners. While the outmost allows us to aggregate multiple sets
* of samples to increase the total number of samples.
*****************************************************************************/
for (icycle = 0; icycle < tst->num_cycles; icycle++) {
/* step through the stage schedule */
for (istage = 0; istage < tst->num_stages; istage++) {
/* who's my buddy for this stage? */
partner_rank = my_rank ^ istage;
/* valid pairing */
if ((partner_rank < num_ranks) && (partner_rank != my_rank)) {
/* valid pair, proceed with test */
ierr = 0;
/***************************************/
/* warm-up / pre-synchronize this pair */
/***************************************/
for (i = 0; i < tst->num_warmup; i++) {
ORB_read(t1);
ORB_read(t2);
ierr += MPI_Sendrecv(sbuf->data, m->buflen, MPI_BYTE, partner_rank, 0,
rbuf->data, m->buflen, MPI_BYTE, partner_rank, 0,
MPI_COMM_WORLD, &mpistatus);
ORB_read(t3);
}
assert(ierr == 0);
/************************************************************/
/* BEGIN PERFORMANCE KERNEL -- gather samples for this pair */
/************************************************************/
for (i = 0; i < tst->num_messages; i++) {
/* for timer overhead estimate */
ORB_read(t1);
ORB_read(t2);
/***************************************/
/* begin timed communication primitive */
/***************************************/
ierr += MPI_Sendrecv(sbuf->data, m->buflen, MPI_BYTE, partner_rank, 0,
rbuf->data, m->buflen, MPI_BYTE, partner_rank, 0,
MPI_COMM_WORLD, &mpistatus);
/*************************************/
/* end timed communication primitive */
/*************************************/
ORB_read(t3);
/* save the timings */
t[i] = ORB_seconds(t2, t1);
cos[i] = ORB_seconds(t3, t2);
}
/************************************************************/
/* END PERFORMANCE KERNEL -- samples gathered for this pair */
/************************************************************/
assert(ierr == 0);
/* exchange array of local timings with partner */
ierr += MPI_Sendrecv(cos, tst->num_messages, MPI_DOUBLE, partner_rank, 0,
cpw, tst->num_messages, MPI_DOUBLE, partner_rank, 0,
MPI_COMM_WORLD, &mpistatus);
assert(ierr == 0);
/* pairwise as average, comparable to one-sided */
for (i = 0; i < tst->num_messages; i++) {
cpw[i] = (cpw[i] + cos[i]) / 2.0;
}
/* bin the t, cos, and cpw results for this cycle of this pair in p */
net_measurement_bin(tst, m, t, cos, cpw, (node_id[my_rank] == node_id[partner_rank]));
} /* if valid pairing */
} /* for istage */
} /* for icycle */
free(t);
free(cpw);
free(cos);
comm_freebuffer(rbuf);
comm_freebuffer(sbuf);
#endif
return;
}
/**
\brief Converts the time measurements to bin
*/
void net_measurement_bin(test_p tst, measurement_p m, double *t, double *cos, double *cpw, int LOCAL) {
double cosmin, cpwmin;
uint64_t *ptimd, *posd, *ppwd, *posmd, *ppwmd;
int i;
if (LOCAL) { /* bin these values as local communication */
posd = m->hist[onNodeOnesided].dist;
ppwd = m->hist[onNodePairwise].dist;
posmd = m->hist[onNodeOnesidedMinimum].dist;
ppwmd = m->hist[onNodePairwiseMinimum].dist;
} else { /* bin these values as remote communication */
posd = m->hist[offNodeOnesided].dist;
ppwd = m->hist[offNodePairwise].dist;
posmd = m->hist[offNodeOnesidedMinimum].dist;
ppwmd = m->hist[offNodePairwiseMinimum].dist;
}
ptimd = m->hist[timer].dist;
cosmin = cpwmin = 1.0e+16;
for (i = 0; i < tst->num_messages; i++) {
/* bin the individual results */
if (t != NULL) {
if (t[i] >= 0.0)
ptimd[time2bin(tst,t[i])]++;
}
if (cos[i] >= 0.0)
posd[time2bin(tst,cos[i])]++;
if (cpw[i] >= 0.0)
ppwd[time2bin(tst,cpw[i])]++;
/* save the minimums for now */
if ((cos[i] > 0.0) && (cos[i] < cosmin))
cosmin = cos[i];
if ((cpw[i] > 0.0) && (cpw[i] < cpwmin))
cpwmin = cpw[i];
}
/* now bin the minimums for this communications pair */
if (cosmin > 0.0)
posmd[time2bin(tst,cosmin)]++;
if (cpwmin > 0.0)
ppwmd[time2bin(tst,cpwmin)]++;
}