Logo AND Algorithmique Numérique Distribuée

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