Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Use std::vector for liveness {Pair,VisitedPair}::atomic_propositions
[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 #include <memory>
15 #include <vector>
16
17 #include <simgrid_config.h>
18 #include <xbt/base.h>
19 #include <xbt/dynar.h>
20 #include <xbt/automaton.h>
21 #include <xbt/memory.hpp>
22 #include "src/mc/mc_state.h"
23 #include "src/mc/Checker.hpp"
24
25 SG_BEGIN_DECL()
26
27 SG_END_DECL()
28
29 namespace simgrid {
30 namespace mc {
31
32 extern XBT_PRIVATE xbt_automaton_t property_automaton;
33
34 struct XBT_PRIVATE Pair {
35   int num = 0;
36   int search_cycle = 0;
37   std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
38   xbt_automaton_state_t automaton_state = nullptr;
39   std::vector<int> atomic_propositions;
40   int requests = 0;
41   int depth = 0;
42   int exploration_started = 0;
43
44   Pair();
45   ~Pair();
46
47   Pair(Pair const&) = delete;
48   Pair& operator=(Pair const&) = delete;
49 };
50
51 struct XBT_PRIVATE VisitedPair {
52   int num = 0;
53   int other_num = 0; /* Dot output for */
54   int acceptance_pair = 0;
55   std::shared_ptr<simgrid::mc::State> graph_state = nullptr; /* System state included */
56   xbt_automaton_state_t automaton_state = nullptr;
57   std::vector<int> atomic_propositions;
58   std::size_t heap_bytes_used = 0;
59   int nb_processes = 0;
60
61   VisitedPair(
62     int pair_num, xbt_automaton_state_t automaton_state,
63     std::vector<int> const& atomic_propositions,
64     std::shared_ptr<simgrid::mc::State> graph_state);
65   ~VisitedPair();
66 };
67
68 class XBT_PRIVATE LivenessChecker : public Checker {
69 public:
70   LivenessChecker(Session& session);
71   ~LivenessChecker();
72   int run() override;
73   RecordTrace getRecordTrace() override;
74   std::vector<std::string> getTextualTrace() override;
75 private:
76   int main();
77   void prepare();
78   int compare(simgrid::mc::VisitedPair* state1, simgrid::mc::VisitedPair* state2);
79   std::vector<int> getPropositionValues();
80   std::shared_ptr<VisitedPair> insertAcceptancePair(simgrid::mc::Pair* pair);
81   int insertVisitedPair(std::shared_ptr<VisitedPair> visited_pair, simgrid::mc::Pair* pair);
82   void showAcceptanceCycle(std::size_t depth);
83   void replay();
84   void removeAcceptancePair(int pair_num);
85 public:
86   std::list<std::shared_ptr<VisitedPair>> acceptancePairs_;
87   std::list<Pair*> livenessStack_;
88   std::list<std::shared_ptr<VisitedPair>> visitedPairs_;
89 };
90
91 }
92 }
93
94 #endif