Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / teshsuite / smpi / mpich3-test / pt2pt / pssend.c
1 /*
2  * Copyright (C) by Argonne National Laboratory
3  *     See COPYRIGHT in top-level directory
4  */
5
6 /*
7  * This program checks the semantics of persistent synchronous send
8  */
9 #include "mpi.h"
10 #include "mpitest.h"
11
12 int main(int argc, char *argv[])
13 {
14     int errs = 0;
15     int size, rank;
16     MPI_Request req;
17     int flag;
18
19     MTest_Init(&argc, &argv);
20
21     MPI_Comm_rank(MPI_COMM_WORLD, &rank);
22     MPI_Comm_size(MPI_COMM_WORLD, &size);
23
24     if (size < 2) {
25         fprintf(stderr, "Launch with two processes\n");
26         MPI_Abort(MPI_COMM_WORLD, 1);
27     }
28
29     if (rank == 0) {
30         MPI_Ssend_init(NULL, 0, MPI_INT, 1, 0, MPI_COMM_WORLD, &req);
31         MPI_Start(&req);
32
33         /* ssend cannot be complete at this point */
34         MPI_Test(&req, &flag, MPI_STATUS_IGNORE);
35         if (flag != 0) {
36             errs++;
37             fprintf(stderr, "ERROR: synchronous send completed before matching recv was posted\n");
38         }
39     }
40
41     MPI_Barrier(MPI_COMM_WORLD);
42
43     if (rank == 0) {
44         MPI_Wait(&req, MPI_STATUS_IGNORE);
45         MPI_Request_free(&req);
46     } else if (rank == 1) {
47         MPI_Recv(NULL, 0, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);
48     }
49
50     MTest_Finalize(errs);
51
52     return 0;
53 }