/* scat.c check scatter and gather */ #include "mpi.h" #include int main(int argc, char *argv[]) { int proc, myid, numprocs; int count = 1; int master = 0; double esec = 0.0; int bufout[1000]; /* built by master for distribution */ int bufin[1000]; /* slaves and master receive here */ int gath[1000]; /* only master receives here from Gather */ int i; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); if(myid == 0) { printf("scat.c numprocs=%d \n", numprocs); printf("Scatter is blocking and must be executed by all.\n"); printf("Scatter automatically indexes through bufout.\n"); printf("all, including master, receive from scatter.\n"); printf("Gather is blocking and must be executed by all.\n"); printf("Gather automatically indexes through gath.\n"); printf("only master receives from Gather.\n"); printf("no order guaranteed for printf output.\n"); for(i=0; i