X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3c6adda1bed5343613505208a8307e79d0ca4d27..ab6013dda2f80b21aff83d529738b048e508828f:/examples/smpi/sendrecv.c diff --git a/examples/smpi/sendrecv.c b/examples/smpi/sendrecv.c new file mode 100644 index 0000000000..7b11ce0bac --- /dev/null +++ b/examples/smpi/sendrecv.c @@ -0,0 +1,26 @@ +#include "mpi.h" +#include + +int main(int argc, char *argv[]) +{ +#define TAG_RCV 998 +#define TAG_SND 999 + int myid, numprocs, left, right; + int buffer[10], buffer2[10]; + MPI_Request request; + MPI_Status status; + + MPI_Init(&argc,&argv); + MPI_Comm_size(MPI_COMM_WORLD, &numprocs); + MPI_Comm_rank(MPI_COMM_WORLD, &myid); + + right = (myid + 1) % numprocs; + left = myid - 1; + if (left < 0) + left = numprocs - 1; + + MPI_Sendrecv(buffer, 10, MPI_INT, left, TAG_SND, buffer2, 10, MPI_INT, right, TAG_RCV, MPI_COMM_WORLD, &status); + + MPI_Finalize(); + return 0; +}