Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Kill dead code.
[simgrid.git] / src / mc / api.hpp
1 /* Copyright (c) 2020-2022. 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 #ifndef SIMGRID_MC_API_HPP
7 #define SIMGRID_MC_API_HPP
8
9 #include <memory>
10 #include <vector>
11
12 #include "simgrid/forward.h"
13 #include "src/mc/api/State.hpp"
14 #include "src/mc/mc_forward.hpp"
15 #include "src/mc/mc_record.hpp"
16 #include "xbt/automaton.hpp"
17 #include "xbt/base.h"
18
19 namespace simgrid {
20 namespace mc {
21
22 XBT_DECLARE_ENUM_CLASS(CheckerAlgorithm, Safety, UDPOR, Liveness, CommDeterminism);
23
24 /*
25 ** This class aimes to implement FACADE APIs for simgrid. The FACADE layer sits between the CheckerSide
26 ** (Unfolding_Checker, DPOR, ...) layer and the
27 ** AppSide layer. The goal is to drill down into the entagled details in the CheckerSide layer and break down the
28 ** detailes in a way that the CheckerSide eventually
29 ** be capable to acquire the required information through the FACADE layer rather than the direct access to the AppSide.
30 */
31
32 class Api {
33 private:
34   Api() = default;
35
36   struct DerefAndCompareByActorsCountAndUsedHeap {
37     template <class X, class Y> bool operator()(X const& a, Y const& b) const
38     {
39       return std::make_pair(a->actors_count, a->heap_bytes_used) < std::make_pair(b->actors_count, b->heap_bytes_used);
40     }
41   };
42
43 public:
44   // No copy:
45   Api(Api const&) = delete;
46   void operator=(Api const&) = delete;
47
48   static Api& get()
49   {
50     static Api api;
51     return api;
52   }
53
54   simgrid::mc::Exploration* initialize(char** argv, simgrid::mc::CheckerAlgorithm algo) const;
55
56   // ACTOR APIs
57   std::vector<simgrid::mc::ActorInformation>& get_actors() const;
58   unsigned long get_maxpid() const;
59
60   // REMOTE APIs
61   std::size_t get_remote_heap_bytes() const;
62
63   // MODEL CHECKER APIs
64   void mc_inc_visited_states() const;
65   unsigned long mc_get_visited_states() const;
66   XBT_ATTRIB_NORETURN void mc_exit(int status) const;
67
68   // STATE APIs
69   void restore_state(std::shared_ptr<simgrid::mc::Snapshot> system_state) const;
70
71   // SNAPSHOT APIs
72   bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) const;
73   simgrid::mc::Snapshot* take_snapshot(long num_state) const;
74
75   // SESSION APIs
76   void s_close() const;
77
78 // AUTOMATION APIs
79   void automaton_load(const char* file) const;
80   std::vector<int> automaton_propositional_symbol_evaluate() const;
81   std::vector<xbt_automaton_state_t> get_automaton_state() const;
82   int compare_automaton_exp_label(const xbt_automaton_exp_label* l) const;
83   void set_property_automaton(xbt_automaton_state_t const& automaton_state) const;
84   inline DerefAndCompareByActorsCountAndUsedHeap compare_pair() const
85   {
86     return DerefAndCompareByActorsCountAndUsedHeap();
87   }
88   xbt_automaton_exp_label_t get_automaton_transition_label(xbt_dynar_t const& dynar, int index) const;
89   xbt_automaton_state_t get_automaton_transition_dst(xbt_dynar_t const& dynar, int index) const;
90 };
91
92 } // namespace mc
93 } // namespace simgrid
94
95 #endif