Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use std::list instead of xbt_fifo for the stack in LivenessChecker
[simgrid.git] / src / mc / LivenessChecker.hpp
1 /* Copyright (c) 2007-2015. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #ifndef SIMGRID_MC_LIVENESS_CHECKER_HPP
8 #define SIMGRID_MC_LIVENESS_CHECKER_HPP
9
10 #include <cstddef>
11
12 #include <string>
13 #include <list>
14
15 #include <simgrid_config.h>
16 #include <xbt/base.h>
17 #include <xbt/dynar.h>
18 #include <xbt/automaton.h>
19 #include <xbt/memory.hpp>
20 #include "src/mc/mc_state.h"
21 #include "src/mc/Checker.hpp"
22
23 SG_BEGIN_DECL()
24
25 SG_END_DECL()
26
27 namespace simgrid {
28 namespace mc {
29
30 extern XBT_PRIVATE xbt_automaton_t property_automaton;
31
32 struct XBT_PRIVATE Pair {
33   int num = 0;
34   int search_cycle = 0;
35   simgrid::mc::State* graph_state = nullptr; /* System state included */
36   xbt_automaton_state_t automaton_state = nullptr;
37   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
38   int requests = 0;
39   int depth = 0;
40   int exploration_started = 0;
41   int visited_pair_removed = 0;
42
43   Pair();
44   ~Pair();
45
46   Pair(Pair const&) = delete;
47   Pair& operator=(Pair const&) = delete;
48 };
49
50 struct XBT_PRIVATE VisitedPair {
51   int num = 0;
52   int other_num = 0; /* Dot output for */
53   int acceptance_pair = 0;
54   simgrid::mc::State* graph_state = nullptr; /* System state included */
55   xbt_automaton_state_t automaton_state = nullptr;
56   simgrid::xbt::unique_ptr<s_xbt_dynar_t> atomic_propositions;
57   std::size_t heap_bytes_used = 0;
58   int nb_processes = 0;
59   int acceptance_removed = 0;
60   int visited_removed = 0;
61
62   VisitedPair(int pair_num, xbt_automaton_state_t automaton_state, xbt_dynar_t atomic_propositions, simgrid::mc::State* graph_state);
63   ~VisitedPair();
64 };
65
66 class LivenessChecker : public Checker {
67 public:
68   LivenessChecker(Session& session);
69   ~LivenessChecker();
70   int run() override;
71   RecordTrace getRecordTrace() override;
72   std::vector<std::string> getTextualTrace() override;
73 private:
74   int main();
75   void prepare();
76   int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
77   simgrid::xbt::unique_ptr<s_xbt_dynar_t> getPropositionValues();
78   simgrid::mc::VisitedPair* insertAcceptancePair(simgrid::mc::Pair* pair);
79   int insertVisitedPair(simgrid::mc::VisitedPair* visited_pair, simgrid::mc::Pair* pair);
80   void showAcceptanceCycle(std::size_t depth);
81   void replay();
82   void removeAcceptancePair(int pair_num);
83 public: // (non-static wannabe) fields
84   static xbt_dynar_t acceptance_pairs;
85   static std::list<Pair*> liveness_stack;
86 };
87
88 }
89 }
90
91 #endif