Created
September 16, 2014 01:56
-
-
Save congqiao/ad2eabcb299f1c9809e4 to your computer and use it in GitHub Desktop.
Timing MPI routines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <mpi.h> | |
#include <stdio.h> | |
int main(int argc, char *argv[]) | |
{ | |
int num = 7; | |
int i; | |
int rank; | |
double begin, end; | |
MPI_Init(&argc, &argv); | |
MPI_Comm_rank(MPI_COMM_WORLD, &rank); | |
MPI_Barrier(MPI_COMM_WORLD); | |
begin = MPI_Wtime(); | |
for (i = 0; i != 1000000; ++i) { | |
MPI_Bcast(&num, 1, MPI_INT, 0, MPI_COMM_WORLD); | |
} | |
MPI_Barrier(MPI_COMM_WORLD); | |
end = MPI_Wtime(); | |
MPI_Finalize(); | |
if (rank == 0) { | |
printf("Run time: %f\n", end-begin); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment