Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
get sg_instr_new_router through a signal
[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, size, rank;
10   MPI_Status status;
11
12   MPI_Init(&argc, &argv);
13
14   MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
15   MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
16
17   MC_ignore(&(status.count), sizeof(status.count));
18
19   if (rank == 0) {
20     while (1) {
21       MPI_Recv(&recv_buff, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
22     }
23   } else {
24     while (1) {
25       int old_x = x;
26       x = -y;
27       y = old_x;
28       printf("x = %d, y = %d\n", x, y);
29       MPI_Send(&rank, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
30     }
31   }
32
33   MPI_Finalize();
34
35   return 0;
36 }