-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_,
- cur_state->count_todo());
-
- /* Update statistics */
- api::get().mc_inc_visited_states();
-
- if (stack_.size() <= (std::size_t)_sg_mc_max_depth)
- req = api::get().mc_state_choose_request(cur_state);
- else
- req = nullptr;
-
- if (req != nullptr && visited_state == nullptr) {
- int req_num = cur_state->transition_.times_considered_;
-
- XBT_DEBUG("Execute: %s", api::get().request_to_string(req, req_num, RequestType::simix).c_str());
-
- 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();
-
- /* 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_);
-
- /* 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
- * with the initial pattern. */
- 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);
- else
- visited_state = nullptr;
-
- if (visited_state == nullptr) {
- /* Get enabled actors and insert them in the interleave set of the next state */
- auto actors = api::get().get_actors();
- for (auto& actor : actors)
- if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid()))
- next_state->mark_todo(actor.copy.get_buffer());
-
- if (dot_output != nullptr)
- fprintf(dot_output, "\"%d\" -> \"%d\" [%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_,
- visited_state->original_num == -1 ? visited_state->num : visited_state->original_num, req_str.c_str());
-
- stack_.push_back(std::move(next_state));
- } else {
- 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.",
- 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());
- stack_.pop_back();
-
- visited_state = nullptr;
-
- api::get().mc_check_deadlock();
-
- while (not stack_.empty()) {
- std::unique_ptr<State> state(std::move(stack_.back()));
- 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);
- stack_.push_back(std::move(state));
-
- this->restoreState();
-
- XBT_DEBUG("Back-tracking to state %d at depth %zu done", stack_.back()->num_, stack_.size());
-
- break;
- } else {
- XBT_DEBUG("Delete state %d at depth %zu", state->num_, stack_.size() + 1);