/* Inital Demonstration mpi program for cs455. */ #include #include #include #include #include #define true 1 #define false 0 #define MAXIBUF 100 #define PLAYS 3 #define MSGS 5 #define MAX 20 /* Initial HitBall program in c. To Compile: mpicc -g HitBall.c -o HitBall To Execute: mpirun -np 4 HitBall */ /* Start of Main Program */ int main(int argc, char *argv[]) { char more = true; int myRank, size, msg, player, i; char *done = "Done"; char *msgs[MSGS] = {"Grounder", "Fly", "Line drive", "Pop up", "Bunt"}; char *play[PLAYS] = {"caught", "dropped", "bobbled"}; char ibuf[MAXIBUF]; MPI_Status status; srand( (unsigned)time( NULL ) ); MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &myRank); MPI_Comm_size(MPI_COMM_WORLD, &size); if (size<2) MPI_Abort(MPI_COMM_WORLD, 1); /* Instructions executed by the master processor. */ if (myRank==0) { /* Hit the balls to the slaves */ for (i=0; i