Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge remote-tracking branch 'github/master'
[simgrid.git] / src / mc / mc_api.hpp
1 #ifndef SIMGRID_MC_API_HPP
2 #define SIMGRID_MC_API_HPP
3
4 #include <memory>
5 #include <vector>
6
7 #include "simgrid/forward.h"
8 #include "src/mc/mc_forward.hpp"
9 #include "src/mc/mc_request.hpp"
10 #include "src/mc/mc_state.hpp"
11 #include "xbt/base.h"
12
13 namespace simgrid {
14 namespace mc {
15
16 /*
17 ** This class aimes to implement FACADE APIs for simgrid. The FACADE layer sits between the CheckerSide
18 ** (Unfolding_Checker, DPOR, ...) layer and the
19 ** AppSide layer. The goal is to drill down into the entagled details in the CheckerSide layer and break down the
20 ** detailes in a way that the CheckerSide eventually
21 ** be capable to acquire the required information through the FACADE layer rather than the direct access to the AppSide.
22 */
23
24 class mc_api {
25 private:
26   mc_api() = default;
27
28 public:
29   // No copy:
30   mc_api(mc_api const&) = delete;
31   void operator=(mc_api const&) = delete;
32
33   static mc_api& get()
34   {
35     static mc_api mcapi;
36     return mcapi;
37   }
38
39   void initialize(char** argv);
40
41   // ACTOR APIs  
42   std::vector<simgrid::mc::ActorInformation>& get_actors() const;
43   bool actor_is_enabled(aid_t pid) const;
44   unsigned long get_maxpid() const;
45   int get_actors_size() const;
46
47   // COMMUNICATION APIs
48   bool comm_addr_equal(const kernel::activity::CommImpl* comm_addr1, const kernel::activity::CommImpl* comm_addr2) const;
49   kernel::activity::CommImpl* get_comm_isend_raw_addr(smx_simcall_t request) const;
50   kernel::activity::CommImpl* get_comm_wait_raw_addr(smx_simcall_t request) const;
51   kernel::activity::CommImpl* get_comm_waitany_raw_addr(smx_simcall_t request, int value) const;
52   std::string get_pattern_comm_rdv(void* addr) const;
53   unsigned long get_pattern_comm_src_proc(void* addr) const;
54   unsigned long get_pattern_comm_dst_proc(void* addr) const;
55   std::vector<char> get_pattern_comm_data(void* addr) const;
56   std::vector<char> get_pattern_comm_data(const kernel::activity::CommImpl* comm_addr) const;
57   const char* get_actor_host_name(smx_actor_t actor) const;
58   bool check_send_request_detached(smx_simcall_t const& simcall) const;
59   smx_actor_t get_src_actor(const kernel::activity::CommImpl* comm_addr) const;
60   smx_actor_t get_dst_actor(const kernel::activity::CommImpl* comm_addr) const;
61
62   // REMOTE APIs
63   std::size_t get_remote_heap_bytes() const;
64
65   // MODEL CHECKER APIs
66   ModelChecker* get_model_checker() const;
67   void mc_inc_visited_states() const;
68   void mc_inc_executed_trans() const;
69   unsigned long mc_get_visited_states() const;
70   unsigned long mc_get_executed_trans() const;
71   bool mc_check_deadlock() const;
72   void mc_show_deadlock() const;
73   bool mc_is_null() const;
74   Checker* mc_get_checker() const;
75   RemoteSimulation& mc_get_remote_simulation() const;
76   void handle_simcall(Transition const& transition) const;
77   void mc_wait_for_requests() const;
78   void mc_exit(int status) const;
79   std::string const& mc_get_host_name(std::string const& hostname) const;
80   void dump_record_path() const;
81   smx_simcall_t mc_state_choose_request(simgrid::mc::State* state) const;
82
83   // SIMCALL APIs
84   bool request_depend(smx_simcall_t req1, smx_simcall_t req2) const;
85   std::string request_to_string(smx_simcall_t req, int value, RequestType request_type) const;
86   std::string request_get_dot_output(smx_simcall_t req, int value) const;
87   const char *simcall_get_name(simgrid::simix::Simcall kind) const;
88   smx_actor_t simcall_get_issuer(s_smx_simcall const* req) const;
89   #if HAVE_SMPI
90   int get_smpi_request_tag(smx_simcall_t const& simcall, simgrid::simix::Simcall type) const;
91   #endif
92
93   // STATE APIs
94   void restore_state(std::shared_ptr<simgrid::mc::Snapshot> system_state) const;
95   void log_state() const;
96   void restore_initial_state() const;
97
98   // SNAPSHOT APIs
99   bool snapshot_equal(const Snapshot* s1, const Snapshot* s2) const;
100   simgrid::mc::Snapshot* take_snapshot(int num_state) const;
101
102   // SESSION APIs
103   void s_initialize() const;
104   void s_close() const;
105   void execute(Transition const& transition);
106 };
107
108 } // namespace mc
109 } // namespace simgrid
110
111 #endif