Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
examples to demonstrate bugs in sendrecv
[simgrid.git] / examples / smpi / sendrecv.c
1 #include "mpi.h"
2 #include <stdio.h>
3  
4 int main(int argc, char *argv[])
5 {
6 #define TAG_RCV 998
7 #define TAG_SND 999
8     int myid, numprocs, left, right;
9     int buffer[10], buffer2[10];
10     MPI_Request request;
11     MPI_Status status;
12  
13     MPI_Init(&argc,&argv);
14     MPI_Comm_size(MPI_COMM_WORLD, &numprocs);
15     MPI_Comm_rank(MPI_COMM_WORLD, &myid);
16  
17     right = (myid + 1) % numprocs;
18     left = myid - 1;
19     if (left < 0)
20         left = numprocs - 1;
21  
22     MPI_Sendrecv(buffer, 10, MPI_INT, left, TAG_SND, buffer2, 10, MPI_INT, right, TAG_RCV, MPI_COMM_WORLD, &status);
23  
24     MPI_Finalize();
25     return 0;
26 }