Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
only ask one version of the standard for pybind11
[simgrid.git] / examples / smpi / mc / non_termination3.c
1 #include <stdio.h>
2 #include <mpi.h>
3 #include <simgrid/modelchecker.h>
4
5 int x = 0;
6 int y = 0;
7
8 int main(int argc, char **argv) {
9   int recv_x;
10   int recv_y;
11   int size;
12   int rank;
13   MPI_Status status;
14
15   MPI_Init(&argc, &argv);
16
17   MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
18   MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
19
20   MC_ignore(&(status.count), sizeof(status.count));
21
22   if (rank == 0) {
23     while (x<5) {
24       MPI_Recv(&recv_x, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
25       MPI_Recv(&recv_y, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
26     }
27   } else {
28     while (x<5) {
29       int old_x = x;
30       x = old_x - y;
31       MPI_Send(&x, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
32       y = old_x + y;
33       MPI_Send(&y, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
34     }
35   }
36
37   MPI_Finalize();
38
39   return 0;
40 }