Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Change include order for smpi tests/examples to avoid conflicts
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / isendselfprobe.c
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  *  (C) 2001 by Argonne National Laboratory.
4  *      See COPYRIGHT in top-level directory.
5  */
6 #include <stdio.h>
7 #include "mpi.h"
8 #include "mpitest.h"
9
10 int main( int argc, char * argv[] )
11 {
12     int rank;
13     int sendMsg = 123;
14     int recvMsg = 0;
15     int flag = 0;
16     int count;
17     MPI_Status status;
18     MPI_Request request;
19     int errs = 0;
20
21     MTest_Init( &argc, &argv );
22
23     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
24
25     if(rank == 0)
26     {
27         MPI_Isend( &sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request );
28         while(!flag)
29         {
30             MPI_Iprobe( 0, 0, MPI_COMM_WORLD, &flag, &status );
31         }
32         MPI_Get_count( &status, MPI_INT, &count );
33         if(count != 1)
34         {
35             errs++;
36         }
37         MPI_Recv( &recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status );
38         if(recvMsg != 123)
39         {
40             errs++;
41         }
42         MPI_Wait( &request, &status );
43     }
44     MTest_Finalize( errs );
45     MPI_Finalize();
46     return 0;
47 }