Logo AND Algorithmique Numérique Distribuée

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