Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[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         MPI_Isend(&sendMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &request);
27         while (!flag) {
28             MPI_Iprobe(0, 0, MPI_COMM_WORLD, &flag, &status);
29         }
30         MPI_Get_count(&status, MPI_INT, &count);
31         if (count != 1) {
32             errs++;
33         }
34         MPI_Recv(&recvMsg, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
35         if (recvMsg != 123) {
36             errs++;
37         }
38         MPI_Wait(&request, &status);
39     }
40     MTest_Finalize(errs);
41     MPI_Finalize();
42     return 0;
43 }