/* *This is a benchmarking program for mpi. This program is very similar * to bench2.c except that a barrier is used when a message traveles around * the ring to make sure that the messages are syncronized. */ #include /* for input/output */ #include /* for mpi routines */ #define BUFSIZE 64 /* The size of the messege being passed */ #define LOOPS 1000 /* The number of times around the loop */ main( int argc, char** argv) { double start, finish; int my_rank; /* the rank of this process */ int n_processes; /* the total number of processes */ int buf[BUFSIZE]; /* a buffer for the messege */ int count,i; /* index variables */ int tag=0; /* not important here */ double aveTime; /* fot timing information */ MPI_Status status; /* not important here */ MPI_Init(&argc, &argv); /* Initializing mpi */ MPI_Comm_size(MPI_COMM_WORLD, &n_processes); /* Getting # of processes */ MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); /* Getting my rank */ /* * Each process sends to the next node, then recieves from the previous * node. A barrier is used at the end to make sure that no process * finishes before other processes. */ start=MPI_Wtime(); for(count=0;count < LOOPS; count++) { for(i=0;i