Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix a few test with dpor
[simgrid.git] / examples / smpi / mc / non_termination3.c
1 /* Copyright (c) 2015-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #include <stdio.h>
7 #include <mpi.h>
8 #include <simgrid/modelchecker.h>
9
10 int x = 0;
11 int y = 0;
12
13 int main(int argc, char **argv) {
14   int recv_x;
15   int recv_y;
16   int size;
17   int rank;
18   MPI_Status status;
19
20   MPI_Init(&argc, &argv);
21
22   MPI_Comm_size(MPI_COMM_WORLD, &size);   /* Get nr of tasks */
23   MPI_Comm_rank(MPI_COMM_WORLD, &rank);   /* Get id of this process */
24
25   MC_ignore(&status.count, sizeof status.count);
26
27   if (rank == 0) {
28     while (x<5) {
29       MPI_Recv(&recv_x, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
30       MPI_Recv(&recv_y, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
31     }
32   } else {
33     while (x<5) {
34       int old_x = x;
35       x = old_x - y;
36       MPI_Send(&x, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
37       y = old_x + y;
38       MPI_Send(&y, 1, MPI_INT, 0, 42, MPI_COMM_WORLD);
39     }
40   }
41
42   MPI_Finalize();
43
44   return 0;
45 }