Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
small comments improvements around a complex code
[simgrid.git] / src / mc / checker / CommunicationDeterminismChecker.hpp
1 /* Copyright (c) 2016-2019. 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 "src/mc/VisitedState.hpp"
7 #include "src/mc/checker/Checker.hpp"
8 #include "src/mc/mc_comm_pattern.hpp"
9
10 #include <string>
11 #include <vector>
12
13 #ifndef SIMGRID_MC_COMMUNICATION_DETERMINISM_CHECKER_HPP
14 #define SIMGRID_MC_COMMUNICATION_DETERMINISM_CHECKER_HPP
15
16 namespace simgrid {
17 namespace mc {
18
19 class XBT_PRIVATE CommunicationDeterminismChecker : public Checker {
20 public:
21   explicit CommunicationDeterminismChecker(Session& session);
22   ~CommunicationDeterminismChecker();
23   void run() override;
24   RecordTrace get_record_trace() override;
25   std::vector<std::string> get_textual_trace() override;
26
27 private:
28   void prepare();
29   void real_run();
30   void log_state() override;
31   void deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm, int backtracking);
32   void restoreState();
33 public:
34   // These are used by functions which should be moved in CommunicationDeterminismChecker:
35   void get_comm_pattern(smx_simcall_t request, e_mc_call_type_t call_type, int backtracking);
36   void complete_comm_pattern(simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr, unsigned int issuer,
37                              int backtracking);
38
39 private:
40   /** Stack representing the position in the exploration graph */
41   std::list<std::unique_ptr<simgrid::mc::State>> stack_;
42   simgrid::mc::VisitedStates visited_states_;
43   unsigned long expanded_states_count_ = 0;
44
45   bool initial_communications_pattern_done = false;
46   bool recv_deterministic                  = true;
47   bool send_deterministic                  = true;
48   char *send_diff = nullptr;
49   char *recv_diff = nullptr;
50 };
51
52 #endif
53
54 }
55 }