/* ----------------------------------------------------------------------- * Code: blocksends.c * Lab: MPI Point-to-Point Communication * Time message sends that use the four blocking communication modes: * synchronous, ready, buffered, standard * Usage: blocksends * Run on two nodes. * Author: Roslyn Leibensperger Last revised: 8/29/95 RYL * ------------------------------------------------------------------------ */ #include #include #include #include "mpi.h" #define NMSG 4 #define SYNC 0 #define READY 1 #define BUF 2 #define STANDARD 3 #define BUF_ALLOC 4 #define GO 10 void print_time ( int event, struct timeval tbegin, struct timeval tend ); main( argc, argv ) int argc; char **argv; { float *message [NMSG]; /* pointers to messages */ float *buffer; /* buffer required by buffered send */ int rank, /* rank of task in communicator */ count, /* number of elements in message */ dest, source, /* rank in communicator of destination */ /* and source tasks */ tag[NMSG], etag, /* message tags */ mlen, /* message length specified by user */ bsize, /* buffer size for buffered send, bytes */ i, j; struct timeval tbegin [NMSG+1], /* used to measure elapsed time */ tend [NMSG+1]; MPI_Comm comm; /* communicator */ MPI_Datatype datatype; /* type of data in message */ MPI_Request request[NMSG]; /* handle for pending communication */ MPI_Status status[NMSG]; /* status of communication */ MPI_Init( &argc, &argv ); if (argc != 2) { printf ( " argc = %d\n", argc); printf ( " Usage: blocksends \n" ); return -1; } /* ------------------------------------------------------------------- * do initial housekeeping: allocate memory for messages, * initialize program with MPI, define message tags * ------------------------------------------------------------------ */ mlen = atoi (argv[1]); for (i=0; i