X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/fe6a4a0cfb04cbe8c0bbd93c7bf6c29ec017ddec..7e625e5e848a284b522d69ec28cb111f1f88515b:/src/mc/explo/DFSExplorer.hpp diff --git a/src/mc/explo/DFSExplorer.hpp b/src/mc/explo/DFSExplorer.hpp index 0eaac540a5..bb80b08f98 100644 --- a/src/mc/explo/DFSExplorer.hpp +++ b/src/mc/explo/DFSExplorer.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2008-2023. The SimGrid Team. All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -6,76 +6,118 @@ #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/mc_safety.hpp" +#include "src/mc/explo/odpor/Execution.hpp" +#include "src/mc/mc_config.hpp" +#include #include #include +#include #include +#include #include namespace simgrid::mc { +using stack_t = std::deque>; + class XBT_PRIVATE DFSExplorer : public Exploration { - ReductionMode reductionMode_ = ReductionMode::unset; - long backtrack_count_ = 0; +private: + ReductionMode reduction_mode_; + unsigned long backtrack_count_ = 0; // for statistics + unsigned long visited_states_count_ = 0; // for statistics - static xbt::signal on_exploration_start_signal; - static xbt::signal on_backtracking_signal; + static xbt::signal on_exploration_start_signal; + static xbt::signal on_backtracking_signal; - static xbt::signal on_state_creation_signal; + static xbt::signal on_state_creation_signal; - static xbt::signal on_restore_system_state_signal; - static xbt::signal on_restore_initial_state_signal; - static xbt::signal on_transition_replay_signal; - static xbt::signal on_transition_execute_signal; + static xbt::signal on_restore_system_state_signal; + static xbt::signal on_restore_initial_state_signal; + static xbt::signal on_transition_replay_signal; + static xbt::signal on_transition_execute_signal; - static xbt::signal on_log_state_signal; + static xbt::signal on_log_state_signal; public: - explicit DFSExplorer(RemoteApp& remote_app); + explicit DFSExplorer(const std::vector& args, ReductionMode mode); void run() override; RecordTrace get_record_trace() override; - std::vector get_textual_trace() override; void log_state() override; /** Called once when the exploration starts */ - static void on_exploration_start(std::function const& f) { on_exploration_start_signal.connect(f); } + static void on_exploration_start(std::function const& f) + { + on_exploration_start_signal.connect(f); + } /** Called each time that the exploration backtracks from a exploration end */ - static void on_backtracking(std::function const& f) { on_backtracking_signal.connect(f); } + static void on_backtracking(std::function const& f) + { + on_backtracking_signal.connect(f); + } /** Called each time that a new state is create */ - static void on_state_creation(std::function const& f) { on_state_creation_signal.connect(f); } + static void on_state_creation(std::function const& f) + { + on_state_creation_signal.connect(f); + } /** Called when rollbacking directly onto a previously checkpointed state */ - static void on_restore_system_state(std::function const& f) + static void on_restore_system_state(std::function const& f) { on_restore_system_state_signal.connect(f); } /** Called when the state to which we backtrack was not checkpointed state, forcing us to restore the initial state * before replaying some transitions */ - static void on_restore_initial_state(std::function const& f) { on_restore_initial_state_signal.connect(f); } + static void on_restore_initial_state(std::function const& f) + { + on_restore_initial_state_signal.connect(f); + } /** Called when replaying a transition that was previously executed, to reach a backtracked state */ - static void on_transition_replay(std::function const& f) + static void on_transition_replay(std::function const& f) { on_transition_replay_signal.connect(f); } /** Called when executing a new transition */ - static void on_transition_execute(std::function const& f) + static void on_transition_execute(std::function const& f) { on_transition_execute_signal.connect(f); } /** Called when displaying the statistics at the end of the exploration */ - static void on_log_state(std::function const& f) { on_log_state_signal.connect(f); } + static void on_log_state(std::function const& f) { on_log_state_signal.connect(f); } private: - void check_non_termination(const State* current_state); void backtrack(); - void restore_state(); /** Stack representing the position in the exploration graph */ - std::list> stack_; - VisitedStates visited_states_; - std::unique_ptr 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 per_actor_clocks_; + + /** Opened states are states that still contains todo actors. + * When backtracking, we pick a state from it*/ + std::vector> opened_states_; + std::shared_ptr best_opened_state(); + + /** If we're running ODPOR, picks the corresponding state in the stack + * (opened_states_ are ignored) + */ + std::shared_ptr 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); + + RecordTrace get_record_trace_of_stack(stack_t stack); }; } // namespace simgrid::mc