#include "mpi.h" #include "stdlib.h" #define N 50000 /* N is the number of rounds */ #define B 250 /* B is the buffer size (1K) */ #define P 8 /* P is the number of players */ #define C 1 /* C indicates the amount of computation */ /* This is a ring program. */ /* It sends a message around N times among P entities. */ main(int argc, char *argv[]) { int my_id, my_neighbor, prev_neighbor, rounds, values, comp; int ballarray[B]; MPI_Status stat; if (MPI_Init(&argc, &argv)!=MPI_SUCCESS) { printf("Sorry, that's an error.\n"); exit(1); } MPI_Comm_rank(MPI_COMM_WORLD, &my_id); /* Get rank */ my_neighbor = (my_id+1)%P; prev_neighbor = (my_id+P-1)%P; /* First player starts the game */ if (my_id==0) MPI_Send(ballarray, B, MPI_INT, my_neighbor, 0, MPI_COMM_WORLD); /* Wait for the message then send it to next neighbor */ for (rounds=0; rounds