auto dst_proc = api::get().get_dst_actor(comm_addr);
comm_pattern->src_proc = src_proc->get_pid();
comm_pattern->dst_proc = dst_proc->get_pid();
- comm_pattern->src_host = &api::get().get_actor_host_name(src_proc);
- comm_pattern->dst_host = &api::get().get_actor_host_name(dst_proc);
if (comm_pattern->data.empty()) {
comm_pattern->data = api::get().get_pattern_comm_data(comm_addr);
namespace mc {
void CommunicationDeterminismChecker::deterministic_comm_pattern(aid_t process, const PatternCommunication* comm,
- int backtracking)
+ bool backtracking)
{
if (not backtracking) {
PatternCommunicationList& list = initial_communications_pattern[process];
/********** Non Static functions ***********/
-void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, CallType call_type, int backtracking)
+void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, CallType call_type, bool backtracking)
{
const smx_actor_t issuer = api::get().simcall_get_issuer(request);
const mc::PatternCommunicationList& initial_pattern = initial_communications_pattern[issuer->get_pid()];
pattern->comm_addr = api::get().get_comm_isend_raw_addr(request);
pattern->rdv = api::get().get_pattern_comm_rdv(pattern->comm_addr);
pattern->src_proc = api::get().get_pattern_comm_src_proc(pattern->comm_addr);
- pattern->src_host = &api::get().get_actor_host_name(issuer);
#if HAVE_SMPI
pattern->tag = api::get().get_smpi_request_tag(request, simgrid::simix::Simcall::COMM_ISEND);
#endif
pattern->rdv = api::get().get_pattern_comm_rdv(pattern->comm_addr);
pattern->dst_proc = api::get().get_pattern_comm_dst_proc(pattern->comm_addr);
- pattern->dst_host = &api::get().get_actor_host_name(issuer);
} else
xbt_die("Unexpected call_type %i", (int)call_type);
incomplete_communications_pattern[issuer->get_pid()].push_back(pattern.release());
}
-void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> const& comm_addr, aid_t issuer,
- int backtracking)
+void CommunicationDeterminismChecker::complete_comm_pattern(RemotePtr<kernel::activity::CommImpl> const& comm_addr,
+ aid_t issuer, bool backtracking)
{
/* Complete comm pattern */
std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
std::vector<std::string> CommunicationDeterminismChecker::get_textual_trace() // override
{
std::vector<std::string> trace;
- for (auto const& state : stack_) {
- smx_simcall_t req = &state->executed_req_;
- trace.push_back(api::get().request_to_string(req, state->transition_.times_considered_));
- }
+ for (auto const& state : stack_)
+ trace.push_back(state->get_transition()->to_string());
return trace;
}
XBT_INFO("%s", this->send_diff);
}
}
- XBT_INFO("Expanded states = %lu", expanded_states_count_);
+ XBT_INFO("Expanded states = %ld", State::get_expanded_states());
XBT_INFO("Visited states = %lu", api::get().mc_get_visited_states());
- XBT_INFO("Executed transitions = %lu", api::get().mc_get_executed_trans());
+ XBT_INFO("Executed transitions = %lu", Transition::get_executed_transitions());
XBT_INFO("Send-deterministic : %s", this->send_deterministic ? "Yes" : "No");
if (_sg_mc_comms_determinism)
XBT_INFO("Recv-deterministic : %s", this->recv_deterministic ? "Yes" : "No");
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
- ++expanded_states_count_;
- auto initial_state = std::make_unique<State>(expanded_states_count_);
+ auto initial_state = std::make_unique<State>();
XBT_DEBUG("********* Start communication determinism verification *********");
for (auto& act : api::get().get_actors()) {
auto actor = act.copy.get_buffer();
if (get_session().actor_is_enabled(actor->get_pid()))
- initial_state->mark_todo(actor);
+ initial_state->mark_todo(actor->get_pid());
}
stack_.push_back(std::move(initial_state));
if (state == stack_.back())
break;
- int req_num = state->transition_.times_considered_;
+ int req_num = state->get_transition()->times_considered_;
const s_smx_simcall* saved_req = &state->executed_req_;
xbt_assert(saved_req);
/* TODO : handle test and testany simcalls */
CallType call = MC_get_call_type(req);
- api::get().handle_simcall(state->transition_);
+ state->get_transition()->replay();
handle_comm_pattern(call, req, req_num, 1);
- api::get().mc_wait_for_requests();
/* Update statistics */
api::get().mc_inc_visited_states();
- api::get().mc_inc_executed_trans();
}
}
-void CommunicationDeterminismChecker::handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value, int backtracking)
+void CommunicationDeterminismChecker::handle_comm_pattern(simgrid::mc::CallType call_type, smx_simcall_t req, int value,
+ bool backtracking)
{
using simgrid::mc::CallType;
switch(call_type) {
void CommunicationDeterminismChecker::real_run()
{
std::unique_ptr<VisitedState> visited_state = nullptr;
- smx_simcall_t req = nullptr;
while (not stack_.empty()) {
/* Get current state */
State* cur_state = stack_.back().get();
XBT_DEBUG("**************************************************");
- XBT_DEBUG("Exploration depth = %zu (state = %d, interleaved processes = %zu)", stack_.size(), cur_state->num_,
+ XBT_DEBUG("Exploration depth = %zu (state = %ld, interleaved processes = %zu)", stack_.size(), cur_state->num_,
cur_state->count_todo());
/* Update statistics */
api::get().mc_inc_visited_states();
+ int next_transition = -1;
if (stack_.size() <= (std::size_t)_sg_mc_max_depth)
- req = api::get().mc_state_choose_request(cur_state);
- else
- req = nullptr;
+ next_transition = cur_state->next_transition();
+
+ if (next_transition >= 0 && visited_state == nullptr) {
+ cur_state->execute_next(next_transition);
- if (req != nullptr && visited_state == nullptr) {
- int req_num = cur_state->transition_.times_considered_;
+ aid_t aid = cur_state->get_transition()->aid_;
+ int req_num = cur_state->get_transition()->times_considered_;
+ smx_simcall_t req = &cur_state->executed_req_;
- XBT_DEBUG("Execute: %s", api::get().request_to_string(req, req_num).c_str());
+ XBT_DEBUG("Execute: %s", cur_state->get_transition()->to_cstring());
std::string req_str;
if (dot_output != nullptr)
- req_str = api::get().request_get_dot_output(req, req_num);
-
- api::get().mc_inc_executed_trans();
+ req_str = api::get().request_get_dot_output(aid, req_num);
/* TODO : handle test and testany simcalls */
CallType call = CallType::NONE;
if (_sg_mc_comms_determinism || _sg_mc_send_determinism)
call = MC_get_call_type(req);
- /* Answer the request */
- api::get().handle_simcall(cur_state->transition_);
- /* After this call req is no longer useful */
-
handle_comm_pattern(call, req, req_num, 0);
- /* Wait for requests (schedules processes) */
- api::get().mc_wait_for_requests();
-
/* Create the new expanded state */
- ++expanded_states_count_;
- auto next_state = std::make_unique<State>(expanded_states_count_);
+ auto next_state = std::make_unique<State>();
/* If comm determinism verification, we cannot stop the exploration if some communications are not finished (at
* least, data are transferred). These communications are incomplete and they cannot be analyzed and compared
bool compare_snapshots = this->initial_communications_pattern_done && all_communications_are_finished();
if (_sg_mc_max_visited_states != 0)
- visited_state = visited_states_.addVisitedState(expanded_states_count_, next_state.get(), compare_snapshots);
+ visited_state = visited_states_.addVisitedState(next_state->num_, next_state.get(), compare_snapshots);
else
visited_state = nullptr;
for (auto& act : api::get().get_actors()) {
auto actor = act.copy.get_buffer();
if (get_session().actor_is_enabled(actor->get_pid()))
- next_state->mark_todo(actor);
+ next_state->mark_todo(actor->get_pid());
}
if (dot_output != nullptr)
- fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", cur_state->num_, next_state->num_, req_str.c_str());
+ fprintf(dot_output, "\"%ld\" -> \"%ld\" [%s];\n", cur_state->num_, next_state->num_, req_str.c_str());
} else if (dot_output != nullptr)
- fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", cur_state->num_,
+ fprintf(dot_output, "\"%ld\" -> \"%ld\" [%s];\n", cur_state->num_,
visited_state->original_num == -1 ? visited_state->num : visited_state->original_num, req_str.c_str());
stack_.push_back(std::move(next_state));
if (stack_.size() > (std::size_t)_sg_mc_max_depth)
XBT_WARN("/!\\ Max depth reached! /!\\ ");
else if (visited_state != nullptr)
- XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.",
+ XBT_DEBUG("State already visited (equal to state %ld), exploration stopped on this path.",
visited_state->original_num == -1 ? visited_state->num : visited_state->original_num);
else
XBT_DEBUG("There are no more processes to interleave. (depth %zu)", stack_.size());
this->initial_communications_pattern_done = true;
/* Trash the current state, no longer needed */
- XBT_DEBUG("Delete state %d at depth %zu", cur_state->num_, stack_.size());
+ XBT_DEBUG("Delete state %ld at depth %zu", cur_state->num_, stack_.size());
stack_.pop_back();
visited_state = nullptr;
stack_.pop_back();
if (state->count_todo() && stack_.size() < (std::size_t)_sg_mc_max_depth) {
/* We found a back-tracking point, let's loop */
- XBT_DEBUG("Back-tracking to state %d at depth %zu", state->num_, stack_.size() + 1);
+ XBT_DEBUG("Back-tracking to state %ld at depth %zu", state->num_, stack_.size() + 1);
stack_.push_back(std::move(state));
this->restoreState();
- XBT_DEBUG("Back-tracking to state %d at depth %zu done", stack_.back()->num_, stack_.size());
+ XBT_DEBUG("Back-tracking to state %ld at depth %zu done", stack_.back()->num_, stack_.size());
break;
} else {
- XBT_DEBUG("Delete state %d at depth %zu", state->num_, stack_.size() + 1);
+ XBT_DEBUG("Delete state %ld at depth %zu", state->num_, stack_.size() + 1);
}
}
}