#include "mpi.h" #include "stdlib.h" #define N 100000 /* N is the number of rounds */ #define B 250 /* B is the buffer size (1K) */ #define P 16 /* P is the number of players */ #define C 50 /* C indicates the amount of computation */ #define M 50 /* M is the number of messages */ /* This is a random topology program. */ /* It sends a message around N times among P entities. */ main(int argc, char *argv[]) { int my_id, enemy_id, comp, bombs, target; int timer = 0; int bombarray[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 */ /* Start the action -- send message to first process */ bombarray[0]=0; if (my_id==0) for (bombs=0; bombs= 0) { MPI_Recv(bombarray,B,MPI_INT,MPI_ANY_SOURCE,0,MPI_COMM_WORLD,&stat); timer = bombarray[0] + 1; bombarray[0] = timer; /* Put random values into the array between 0-300 */ for (comp=1; comp