/* ----------------------------------------------------------------------- * Code: nbrecv.c * Lab: MPI Point-to-Point Communication * Solution program demonstrating that replacing a blocking receive * with a non-blocking receive earlier in the program can decrease * the synchronization time on the corresponding send. * Usage: nbrecv * Run on two nodes * Author: Roslyn Leibensperger Last revised: 8/30/95 RYL * ------------------------------------------------------------------------ */ #include #include #include "mpi.h" #define MSGLEN 2048 #define TAG 100 void print_time ( struct timeval tbegin, struct timeval tend ); main( argc, argv ) int argc; char **argv; { float message [MSGLEN]; /* message buffer */ int rank, /* rank of task in communicator */ i; MPI_Status status; /* status of communication */ MPI_Request request; /* handle for pending communication */ struct timeval tbegin, /* used to measure elapsed time */ tend; MPI_Init( &argc, &argv ); MPI_Comm_rank( MPI_COMM_WORLD, &rank ); printf ( " Process %d initialized\n", rank ); /* ----------------------------------------------------------------- * task 0 will report the elapsed time for a blocking send * ----------------------------------------------------------------- */ if ( rank == 0 ) { for (i=0; i