Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' into mc-process
[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
10   int recv_x, recv_y, size, rank;
11   MPI_Status status;
12   
13   MPI_Init(&argc, &argv);
14
15   MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
16   MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
17
18   MC_ignore(&(status.count), sizeof(status.count));
19
20   if (rank == 0) {
21     while (x<5) {
22       MPI_Recv(&recv_x, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
23       MPI_Recv(&recv_y, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
24     }
25   } else {
26     while (x<5) {
27       int old_x = x;
28       x = old_x - y;
29       MPI_Send(&x, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
30       y = old_x + y;
31       MPI_Send(&y, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
32     }
33   }
34
35   MPI_Finalize();
36
37   return 0;
38 }