X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e5a9bd57b70358598fd4392291fd8f5aefb582c5..25c2fc2c97dacf157c9608e4291d744f28f200ca:/src/mc/mc_state.cpp diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index c078742b53..dff1bee2d8 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -1,37 +1,36 @@ -/* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2008-2022. 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. */ #include "src/mc/mc_state.hpp" #include "src/mc/mc_config.hpp" -#include "src/mc/mc_api.hpp" +#include "src/mc/api.hpp" #include using simgrid::mc::remote; -using mcapi = simgrid::mc::mc_api; +using api = simgrid::mc::Api; namespace simgrid { namespace mc { State::State(unsigned long state_number) : num_(state_number) { - this->internal_comm_.clear(); - auto maxpid = mcapi::get().get_maxpid(); + const unsigned long maxpid = api::get().get_maxpid(); actor_states_.resize(maxpid); /* Stateful model checking */ if ((_sg_mc_checkpoint > 0 && (state_number % _sg_mc_checkpoint == 0)) || _sg_mc_termination) { - auto snapshot_ptr = mcapi::get().take_snapshot(num_); + auto snapshot_ptr = api::get().take_snapshot(num_); system_state_ = std::shared_ptr(snapshot_ptr); if (_sg_mc_comms_determinism || _sg_mc_send_determinism) { - mcapi::get().copy_incomplete_comm_pattern(this); - mcapi::get().copy_index_comm_pattern(this); + copy_incomplete_comm_pattern(); + copy_index_comm_pattern(); } } } -std::size_t State::interleave_size() const +std::size_t State::count_todo() const { return boost::range::count_if(this->actor_states_, [](simgrid::mc::ActorState const& a) { return a.is_todo(); }); } @@ -41,5 +40,24 @@ Transition State::get_transition() const return this->transition_; } +void State::copy_incomplete_comm_pattern() +{ + incomplete_comm_pattern_.clear(); + const unsigned long maxpid = api::get().get_maxpid(); + for (unsigned long i = 0; i < maxpid; i++) { + std::vector res; + for (auto const& comm : incomplete_communications_pattern[i]) + res.push_back(comm->dup()); + incomplete_comm_pattern_.push_back(std::move(res)); + } +} + +void State::copy_index_comm_pattern() +{ + communication_indices_.clear(); + for (auto const& list_process_comm : initial_communications_pattern) + this->communication_indices_.push_back(list_process_comm.index_comm); +} + } }