Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authormlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 27 Mar 2023 08:24:38 +0000 (10:24 +0200)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 27 Mar 2023 08:24:38 +0000 (10:24 +0200)
1  2 
src/mc/api/State.cpp
src/mc/api/guide/BasicGuide.hpp
src/mc/explo/DFSExplorer.cpp
src/mc/explo/DFSExplorer.hpp
src/mc/remote/AppSide.cpp
src/smpi/mpi/smpi_request.cpp

@@@ -65,14 -42,12 +65,12 @@@ State::State(RemoteApp& remote_app, con
       * And if we kept it and the actor is enabled in this state, mark the actor as already done, so that
       * it is not explored*/
      for (auto& [aid, transition] : parent_state_->get_sleep_set()) {
        if (not parent_state_->get_transition()->depends(&transition)) {
          sleep_set_.try_emplace(aid, transition);
 -        if (guide->actors_to_run_.count(aid) != 0) {
 +        if (guide_->actors_to_run_.count(aid) != 0) {
            XBT_DEBUG("Actor %ld will not be explored, for it is in the sleep set", aid);
  
 -          guide->actors_to_run_.at(aid).mark_done();
 +          guide_->actors_to_run_.at(aid).mark_done();
          }
        } else
          XBT_DEBUG("Transition >>%s<< removed from the sleep set because it was dependent with >>%s<<",
@@@ -93,11 -68,10 +91,10 @@@ Transition* State::get_transition() con
  
  aid_t State::next_transition() const
  {
 -  XBT_DEBUG("Search for an actor to run. %zu actors to consider", guide->actors_to_run_.size());
 -  for (auto const& [aid, actor] : guide->actors_to_run_) {
 +  XBT_DEBUG("Search for an actor to run. %zu actors to consider", guide_->actors_to_run_.size());
 +  for (auto const& [aid, actor] : guide_->actors_to_run_) {
      /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
      if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) {
        if (not actor.is_todo())
          XBT_DEBUG("Can't run actor %ld because it is not todo", aid);
  
@@@ -9,13 -9,11 +9,12 @@@
  namespace simgrid::mc {
  
  /** Basic MC guiding class which corresponds to no guide at all (random choice) */
 -// Not Yet fully implemented
  class BasicGuide : public GuidedState {
  public:
 +  void operator=(const GuidedState&) { return; }
 +
    std::pair<aid_t, double> next_transition() const override
    {
      for (auto const& [aid, actor] : actors_to_run_) {
        /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
        if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) {
@@@ -265,56 -252,53 +265,54 @@@ void DFSExplorer::backtrack(
    if (stack_.back()->get_transition()->aid_ == 0)
      stack_.pop_back();
  
 -  /* Traverse the stack backwards until a state with a non empty interleave set is found, deleting all the states that
 -   *  have it empty in the way. */
 -  bool found_backtracking_point = false;
 -  while (not stack_.empty() && not found_backtracking_point) {
 -    std::unique_ptr<State> state = std::move(stack_.back());
 -
 -    stack_.pop_back();
 +  stack_t backtrack;
 +  double min_dist = std::numeric_limits<double>::infinity();
 +  aid_t min_aid   = -1;
 +  for (auto& stack : opened_states) {
 +    auto [aid, dist] = stack.back()->next_transition_guided();
 +    if (aid == -1)
 +      continue;
 +    if (dist < min_dist) {
 +      min_dist  = dist;
 +      min_aid   = aid;
 +      backtrack = stack;
 +    }
 +  }
  
 +  if (min_aid == -1) {
 +    stack_ = std::list<std::shared_ptr<State>>();
 +    return;
 +  }
  
 -    if (state->count_todo() == 0) { // Empty interleaving set: exploration at this level is over
 -      XBT_DEBUG("Delete state %ld at depth %zu", state->get_num(), stack_.size() + 1);
 +  if (backtrack.back()->count_todo() <= 1)
 +    opened_states.pop_back();
  
 -    } else {
 -      XBT_DEBUG("Back-tracking to state %ld at depth %zu: %lu transitions left to be explored", state->get_num(),
 -                stack_.size() + 1, state->count_todo());
 -      stack_.push_back(
 -          std::move(state)); // Put it back on the stack so we can explore the next transition of the interleave
 -      found_backtracking_point = true;
 -    }
 +  /* If asked to rollback on a state that has a snapshot, restore it */
 +  State* last_state = backtrack.back().get();
 +  if (const auto* system_state = last_state->get_system_state()) {
 +    system_state->restore(*get_remote_app().get_remote_process_memory());
 +    on_restore_system_state_signal(last_state, get_remote_app());
 +    stack_ = backtrack;
 +    return;
    }
  
 -  if (found_backtracking_point) {
 -    /* If asked to rollback on a state that has a snapshot, restore it */
 -    State* last_state = stack_.back().get();
 -    if (const auto* system_state = last_state->get_system_state()) {
 -      system_state->restore(*get_remote_app().get_remote_process_memory());
 -      on_restore_system_state_signal(last_state, get_remote_app());
 -      return;
 -    }
 -
 -    /* if no snapshot, we need to restore the initial state and replay the transitions */
 -    get_remote_app().restore_initial_state();
 -    on_restore_initial_state_signal(get_remote_app());
 -
 -    /* Traverse the stack from the state at position start and re-execute the transitions */
 -    for (std::unique_ptr<State> const& state : stack_) {
 -      if (state == stack_.back()) /* If we are arrived on the target state, don't replay the outgoing transition */
 -        break;
 -      state->get_transition()->replay(get_remote_app());
 -      on_transition_replay_signal(state->get_transition(), get_remote_app());
 -      visited_states_count_++;
 -    }
 -  } // If no backtracing point, then the stack is empty and the exploration is over
 +  /* if no snapshot, we need to restore the initial state and replay the transitions */
 +  get_remote_app().restore_initial_state();
 +  on_restore_initial_state_signal(get_remote_app());
 +  /* Traverse the stack from the state at position start and re-execute the transitions */
 +  for (std::shared_ptr<State> const& state : backtrack) {
 +    if (state == backtrack.back()) /* If we are arrived on the target state, don't replay the outgoing transition */
 +      break;
 +    state->get_transition()->replay(get_remote_app());
 +    on_transition_replay_signal(state->get_transition(), get_remote_app());
 +    visited_states_count_++;
 +  }
 +  stack_ = backtrack;
 +  XBT_DEBUG(">> Backtracked to %s", get_record_trace().to_string().c_str());
  }
  
- // DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor) : Exploration(args, _sg_mc_termination) //
- // UNCOMMENT TO ACTIVATE REFORKS
- DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor)
-     : Exploration(args, true) // This version does not use reforks as it breaks
+ DFSExplorer::DFSExplorer(const std::vector<char*>& args, bool with_dpor, bool need_memory_info)
+     : Exploration(args, need_memory_info || _sg_mc_termination)
  {
    if (with_dpor)
      reduction_mode_ = ReductionMode::dpor;
Simple merge
@@@ -175,9 -212,8 +212,8 @@@ void AppSide::handle_actors_status() co
    }
  
    struct s_mc_message_actors_status_answer_t answer = {};
-   answer.type             = MessageType::ACTORS_STATUS_REPLY;
-   answer.count            = num_actors;
-   answer.transition_count = total_transitions;
+   answer.type                                       = MessageType::ACTORS_STATUS_REPLY_COUNT;
 -  answer.count            = static_cast<int>(status.size());
++  answer.count                                      = static_cast<int>(status.size());
  
    xbt_assert(channel_.send(answer) == 0, "Could not send ACTORS_STATUS_REPLY msg");
    if (answer.count > 0) {
@@@ -528,10 -528,9 +528,8 @@@ void Request::start(
      comm_->increment_sent_messages_count(comm_->group()->rank(src_), comm_->group()->rank(dst_), tag_);
  
      void* buf = buf_;
--    if ((flags_ & MPI_REQ_SSEND) == 0 &&
--        ((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
--         static_cast<int>(size_) < smpi_cfg_detached_send_thresh())) {
-       void *oldbuf = nullptr;
++    if ((flags_ & MPI_REQ_SSEND) == 0 && ((flags_ & MPI_REQ_RMA) != 0 || (flags_ & MPI_REQ_BSEND) != 0 ||
++                                          static_cast<int>(size_) < smpi_cfg_detached_send_thresh())) {
        detached_    = true;
        XBT_DEBUG("Send request %p is detached", this);
        this->ref();