- /* Touch the buffers to make sure they are allocated */
- for (i = 0; i < SIZE; i++) sbuf[i] = '0';
- for (i = 0; i < SIZE * size; i++) rbuf[i] = '0';
+ /* Time when rank 0 gathers the data */
+ MPI_Barrier(MPI_COMM_WORLD);
+ t1 = MPI_Wtime();
+ for (i = 0; i < ITER; i++) {
+ MPI_Gather(sbuf, SIZE, MPI_BYTE, rbuf, SIZE, MPI_BYTE, 0, MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+ t2 = MPI_Wtime();
+ t = (t2 - t1) / ITER;