/* */ /* CS 4331: Parallel Programming Fall, 2009 */ /* */ /* This MPI program computes does a "ping-pong" message passing */ /* performance measurement. */ /* */ #include #include "mpi.h" #define MAX_LEN 1 << 18 /* maximum vector length */ #define TRIALS 100 /* trials for each msg length */ #define PROC_0 0 /* processor 0 */ #define B0_TYPE 176 /* message "types" */ #define B1_TYPE 177 int main(argc,argv) int argc; char *argv[]; { int numprocs, p, /* number of processors, proc index */ myid, /* this processor's "rank" */ length, /* vector length */ i, t; double b0[MAX_LEN], b1[MAX_LEN]; /* vectors */ double start_time, end_time; /* "wallclock" times */ MPI_Status stat; /* MPI structure containing return */ /* codes for message passing operations */ MPI_Request send_handle, recv_handle; /* For nonblocking msgs */ MPI_Init(&argc,&argv); /* initialize MPI */ MPI_Comm_size(MPI_COMM_WORLD, &numprocs); /*how many processors? */ MPI_Comm_rank(MPI_COMM_WORLD, &myid); /*which one am I? */ if (myid == PROC_0) { srand48(0xFEEDFACE); /* generate processor 0's vector */ for (i=0; i