1 /* Copyright (c) 2008-2020. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/mc/mc_state.hpp"
7 #include "src/mc/mc_config.hpp"
8 #include "src/mc/mc_api.hpp"
10 #include <boost/range/algorithm.hpp>
12 using simgrid::mc::remote;
13 using mcapi = simgrid::mc::mc_api;
18 State::State(unsigned long state_number) : num_(state_number)
20 this->internal_comm_.clear();
21 auto maxpid = mcapi::get().get_maxpid();
22 actor_states_.resize(maxpid);
23 /* Stateful model checking */
24 if ((_sg_mc_checkpoint > 0 && (state_number % _sg_mc_checkpoint == 0)) || _sg_mc_termination) {
25 auto snapshot_ptr = mcapi::get().take_snapshot(num_);
26 system_state_ = std::shared_ptr<simgrid::mc::Snapshot>(snapshot_ptr);
27 if (_sg_mc_comms_determinism || _sg_mc_send_determinism) {
28 mcapi::get().copy_incomplete_comm_pattern(this);
29 mcapi::get().copy_index_comm_pattern(this);
34 std::size_t State::interleave_size() const
36 return boost::range::count_if(this->actor_states_, [](simgrid::mc::ActorState const& a) { return a.is_todo(); });
39 Transition State::get_transition() const
41 return this->transition_;