@@ -128,13 +128,16 @@ void run_alltoallw(int ntimes,
128
128
int * recvBuf )
129
129
{
130
130
int * sendPtr ;
131
- int i , j , err , nprocs , rank , num_recvers ;
131
+ int i , j , err , nprocs , rank , num_recvers , bucket_len ;
132
132
int * sendCounts , * recvCounts , * sendDisps , * recvDisps ;
133
133
MPI_Datatype * sendTypes , * recvTypes ;
134
- double timing , maxt ;
134
+ double start_t , end_t , timing [10 ], maxt [10 ];
135
+
136
+ bucket_len = ntimes / 10 ;
137
+ if (ntimes % 10 ) bucket_len ++ ;
135
138
136
139
MPI_Barrier (MPI_COMM_WORLD );
137
- timing = MPI_Wtime ();
140
+ timing [ 0 ] = MPI_Wtime ();
138
141
139
142
MPI_Comm_size (MPI_COMM_WORLD , & nprocs );
140
143
MPI_Comm_rank (MPI_COMM_WORLD , & rank );
@@ -176,6 +179,7 @@ void run_alltoallw(int ntimes,
176
179
printf ("%2d send to %2d of %d\n" ,rank ,i ,sendCounts [i ]);
177
180
}
178
181
182
+ start_t = MPI_Wtime ();
179
183
sendPtr = sendBuf ;
180
184
for (i = 0 ; i < ntimes ; i ++ ) {
181
185
if (debug && is_receiver )
@@ -188,17 +192,28 @@ void run_alltoallw(int ntimes,
188
192
189
193
if (debug && is_receiver )
190
194
check_recv_buf ("alltoallw" , len , gap , recvBuf );
195
+
196
+ if (i > 0 && i % bucket_len == 0 ) {
197
+ end_t = MPI_Wtime ();
198
+ timing [i / bucket_len ] = end_t - start_t ;
199
+ start_t = end_t ;
200
+ }
191
201
}
202
+ end_t = MPI_Wtime ();
203
+ timing [9 ] = end_t - start_t ;
204
+ timing [0 ] = end_t - timing [0 ]; /* end-to-end time */
192
205
193
206
err_out :
194
207
free (sendTypes );
195
208
free (sendCounts );
196
209
free (sendDisps );
197
210
198
- timing = MPI_Wtime () - timing ;
199
- MPI_Reduce (& timing , & maxt , 1 , MPI_DOUBLE , MPI_MAX , 0 , MPI_COMM_WORLD );
200
- if (rank == 0 )
201
- printf ("Time for using MPI_alltoallw = %.2f sec\n" , maxt );
211
+ MPI_Reduce (& timing , & maxt , 10 , MPI_DOUBLE , MPI_MAX , 0 , MPI_COMM_WORLD );
212
+ if (rank == 0 ) {
213
+ printf ("Time for using MPI_alltoallw = %.2f sec\n" , maxt [0 ]);
214
+ for (i = 1 ; i < 10 ; i ++ )
215
+ printf ("\tTime bucket[%d] = %.2f sec\n" , i , maxt [i ]);
216
+ }
202
217
}
203
218
204
219
/* all-to-many personalized communication by calling MPI_Issend/Irecv() */
@@ -211,13 +226,16 @@ void run_async_send_recv(int ntimes,
211
226
int * recvBuf )
212
227
{
213
228
int * sendPtr , * recvPtr ;
214
- int i , j , err , nprocs , rank , nreqs , num_recvers ;
229
+ int i , j , err , nprocs , rank , nreqs , num_recvers , bucket_len ;
215
230
MPI_Request * reqs ;
216
231
MPI_Status * st ;
217
- double timing , maxt ;
232
+ double start_t , end_t , timing [10 ], maxt [10 ];
233
+
234
+ bucket_len = ntimes / 10 ;
235
+ if (ntimes % 10 ) bucket_len ++ ;
218
236
219
237
MPI_Barrier (MPI_COMM_WORLD );
220
- timing = MPI_Wtime ();
238
+ timing [ 0 ] = MPI_Wtime ();
221
239
222
240
MPI_Comm_size (MPI_COMM_WORLD , & nprocs );
223
241
MPI_Comm_rank (MPI_COMM_WORLD , & rank );
@@ -227,6 +245,7 @@ void run_async_send_recv(int ntimes,
227
245
reqs = (MPI_Request * ) malloc (sizeof (MPI_Request ) * (nprocs + num_recvers ));
228
246
st = (MPI_Status * ) malloc (sizeof (MPI_Status ) * (nprocs + num_recvers ));
229
247
248
+ start_t = MPI_Wtime ();
230
249
sendPtr = sendBuf ;
231
250
for (i = 0 ; i < ntimes ; i ++ ) {
232
251
if (debug && is_receiver )
@@ -262,16 +281,27 @@ void run_async_send_recv(int ntimes,
262
281
263
282
if (debug && is_receiver )
264
283
check_recv_buf ("issend /irecv ", len , gap , recvBuf );
284
+
285
+ if (i > 0 && i % bucket_len == 0 ) {
286
+ end_t = MPI_Wtime ();
287
+ timing [i / bucket_len ] = end_t - start_t ;
288
+ start_t = end_t ;
289
+ }
265
290
}
291
+ end_t = MPI_Wtime ();
292
+ timing [9 ] = end_t - start_t ;
293
+ timing [0 ] = end_t - timing [0 ]; /* end-to-end time */
266
294
267
295
err_out :
268
296
free (st );
269
297
free (reqs );
270
298
271
- timing = MPI_Wtime () - timing ;
272
- MPI_Reduce (& timing , & maxt , 1 , MPI_DOUBLE , MPI_MAX , 0 , MPI_COMM_WORLD );
273
- if (rank == 0 )
274
- printf ("Time for using MPI_Issend/Irecv = %.2f sec\n" , maxt );
299
+ MPI_Reduce (& timing , & maxt , 10 , MPI_DOUBLE , MPI_MAX , 0 , MPI_COMM_WORLD );
300
+ if (rank == 0 ) {
301
+ printf ("Time for using MPI_Issend/Irecv = %.2f sec\n" , maxt [0 ]);
302
+ for (i = 1 ; i < 10 ; i ++ )
303
+ printf ("\tTime bucket[%d] = %.2f sec\n" , i , maxt [i ]);
304
+ }
275
305
}
276
306
277
307
/*----< usage() >------------------------------------------------------------*/
@@ -386,3 +416,4 @@ int main(int argc, char **argv) {
386
416
return 0 ;
387
417
}
388
418
419
+
0 commit comments