Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics : indent
[simgrid.git] / teshsuite / smpi / mpich-test / pt2pt / isndrcv2.c
1 #include <stdio.h>
2 #include "mpi.h"
3
4 int main( int argc, char **argv )
5 {
6   int rank, size;
7   MPI_Request r1, r2;
8   MPI_Status  s;
9   int         buf[10000], buf2[10000], count, tag1, tag2;
10
11   count = 10000;
12   tag1  = 100;
13   tag2  = 1000;
14
15   MPI_Init( &argc, &argv );
16   MPI_Comm_rank( MPI_COMM_WORLD, &rank );
17   MPI_Comm_size( MPI_COMM_WORLD, &size );
18
19   if (rank == 0) {
20     MPI_Isend( buf, count, MPI_INT, 1, tag1, MPI_COMM_WORLD, &r1 );
21     MPI_Isend( buf2, count, MPI_INT, 1, tag2, MPI_COMM_WORLD, &r2 );
22     MPI_Wait( &r1, &s );
23     MPI_Wait( &r2, &s );
24   }
25   else if (rank == 1) {
26     MPI_Irecv( buf2, count, MPI_INT, 0, tag2, MPI_COMM_WORLD, &r2 );
27     MPI_Irecv( buf,  count, MPI_INT, 0, tag1, MPI_COMM_WORLD, &r1 );
28     MPI_Wait( &r2, &s );
29     if (s.MPI_TAG != tag2) {
30             printf( "Error in receive order\n" );
31     }
32     MPI_Wait( &r1, &s );
33   }
34
35   MPI_Barrier( MPI_COMM_WORLD );
36   if (rank == 0) {
37     printf( "Test completed\n" );
38   }
39   MPI_Finalize( );
40   return 0;
41 }