#ifndef SIMGRID_MC_SAFETY_CHECKER_HPP
#define SIMGRID_MC_SAFETY_CHECKER_HPP
-#include "src/mc/VisitedState.hpp"
+#include "src/mc/api/ClockVector.hpp"
+#include "src/mc/api/State.hpp"
#include "src/mc/explo/Exploration.hpp"
+#include "src/mc/explo/odpor/Execution.hpp"
+#include "src/mc/mc_config.hpp"
+#include <deque>
#include <list>
#include <memory>
+#include <set>
#include <string>
+#include <unordered_map>
#include <vector>
namespace simgrid::mc {
-class XBT_PRIVATE DFSExplorer : public Exploration {
- XBT_DECLARE_ENUM_CLASS(ReductionMode, none, dpor);
+using stack_t = std::deque<std::shared_ptr<State>>;
+class XBT_PRIVATE DFSExplorer : public Exploration {
+private:
ReductionMode reduction_mode_;
- long backtrack_count_ = 0;
+ unsigned long backtrack_count_ = 0; // for statistics
+ unsigned long visited_states_count_ = 0; // for statistics
static xbt::signal<void(RemoteApp&)> on_exploration_start_signal;
static xbt::signal<void(RemoteApp&)> on_backtracking_signal;
static xbt::signal<void(RemoteApp&)> on_log_state_signal;
public:
- explicit DFSExplorer(const std::vector<char*>& args, bool with_dpor);
+ explicit DFSExplorer(const std::vector<char*>& args, ReductionMode mode);
void run() override;
RecordTrace get_record_trace() override;
- std::vector<std::string> get_textual_trace() override;
void log_state() override;
/** Called once when the exploration starts */
static void on_log_state(std::function<void(RemoteApp&)> const& f) { on_log_state_signal.connect(f); }
private:
- void check_non_termination(const State* current_state);
void backtrack();
- bool sleep_set_reduction_ = true;
/** Stack representing the position in the exploration graph */
- std::list<std::unique_ptr<State>> stack_;
- VisitedStates visited_states_;
- std::unique_ptr<VisitedState> visited_state_;
+ stack_t stack_;
+
+ /**
+ * Provides additional metadata about the position in the exploration graph
+ * which is used by SDPOR and ODPOR
+ */
+ odpor::Execution execution_seq_;
+
+ /** Per-actor clock vectors used to compute the "happens-before" relation */
+ std::unordered_map<aid_t, ClockVector> per_actor_clocks_;
+
+ /** Opened states are states that still contains todo actors.
+ * When backtracking, we pick a state from it*/
+ std::vector<std::shared_ptr<State>> opened_states_;
+ std::shared_ptr<State> best_opened_state();
+
+ /** If we're running ODPOR, picks the corresponding state in the stack
+ * (opened_states_ are ignored)
+ */
+ std::shared_ptr<State> next_odpor_state();
+
+ /** Change current stack_ value to correspond to the one we would have
+ * had if we executed transition to get to state. This is required when
+ * backtracking, and achieved thanks to the fact states save their parent.*/
+ void restore_stack(std::shared_ptr<State> state);
+
+ RecordTrace get_record_trace_of_stack(stack_t stack);
};
} // namespace simgrid::mc