#include "mpi.h" #define N 50000 /* N is the number of rounds */ #define B 5000 /* B is the buffer size for the message, in bytes */ /* This is a ping-pong program. */ /* It sends a message back and forth "N" times between two processes. */ main(int argc, char *argv[]) { int myid, opponent, trips; char ball[B]; MPI_Status stat; if (MPI_Init(&argc, &argv)!=MPI_SUCCESS) { printf("Error, you bonehead!\n"); exit(1); } MPI_Comm_rank(MPI_COMM_WORLD, &myid); /* Get rank */ opponent = (myid+1)%2; /* First player starts the game */ if (myid==1) MPI_Send(ball, B, MPI_CHAR, opponent, 0, MPI_COMM_WORLD); /* Wait for the message then send it back to opponent */ for (trips=0; trips