/****************************************************************************** * FILE: mpi_bug6.c * DESCRIPTION: * * AUTHOER: Blaise Barney * LAST REVISED: 04/13/05 ******************************************************************************/ #include "mpi.h" #include #include #define COMM MPI_COMM_WORLD #define REPS 1000 #define DISP 100 int main (int argc, char *argv[]) { int numtasks, rank, buf, tag1=1, i, rc, dest, src, offset, nreqs; double T1, T2; MPI_Request reqs[REPS*2]; MPI_Status stats[REPS*2]; MPI_Init(&argc,&argv); MPI_Comm_size(COMM, &numtasks); MPI_Comm_rank(COMM, &rank); /* Require 4 tasks */ if (rank == 0 ) { if (numtasks != 4) { printf("ERROR: Number of tasks must be 4. Quitting.\n"); MPI_Abort(COMM, rc); } printf("Starting isend/irecv send/irecv test...\n"); } /* Use barriers for clean output */ MPI_Barrier(COMM); printf("Task %d starting...\n", rank); MPI_Barrier(COMM); T1 = MPI_Wtime(); /* start the clock */ /* Tasks 0 and 1 do the isend/irecv test. * Determine who to send/receive with. nreqs specifies how many non-blocking * operation request handles to capture. offset is where the task should * store each request as it is captured in the reqs() array. */ if (rank < 2) { nreqs = REPS*2; if (rank == 0) { src = 1; offset = 0; } if (rank == 1) { src = 0; offset = REPS; } dest = src; /* Do the non-blocking send and receive operations */ for (i=0; i 1) { nreqs = REPS; /* Task 2 does the blocking send operation */ if (rank == 2) { dest = 3; for (i=0; i