/* 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/checker/CommunicationDeterminismChecker.hpp"
#include "src/kernel/activity/MailboxImpl.hpp"
/* 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/checker/CommunicationDeterminismChecker.hpp"
#include "src/kernel/activity/MailboxImpl.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
#include "src/mc/mc_private.hpp"
#include "src/mc/mc_config.hpp"
#include "src/mc/mc_exit.hpp"
#include "src/mc/mc_private.hpp"
for (size_t i = 0; i < initial_communications_pattern.size(); i++)
initial_communications_pattern[i].index_comm = state->communication_indices_[i];
for (size_t i = 0; i < initial_communications_pattern.size(); i++)
initial_communications_pattern[i].index_comm = state->communication_indices_[i];
namespace mc {
void CommunicationDeterminismChecker::deterministic_comm_pattern(aid_t process, const PatternCommunication* comm,
namespace mc {
void CommunicationDeterminismChecker::deterministic_comm_pattern(aid_t process, const PatternCommunication* comm,
-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()];
{
const smx_actor_t issuer = api::get().simcall_get_issuer(request);
const mc::PatternCommunicationList& initial_pattern = initial_communications_pattern[issuer->get_pid()];
-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];
auto current_comm_pattern =
std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
[&comm_addr](const PatternCommunication* comm) { return (comm->comm_addr == comm_addr); });
{
/* Complete comm pattern */
std::vector<PatternCommunication*>& incomplete_pattern = incomplete_communications_pattern[issuer];
auto current_comm_pattern =
std::find_if(begin(incomplete_pattern), end(incomplete_pattern),
[&comm_addr](const PatternCommunication* comm) { return (comm->comm_addr == comm_addr); });
update_comm_pattern(*current_comm_pattern, comm_addr);
std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
update_comm_pattern(*current_comm_pattern, comm_addr);
std::unique_ptr<PatternCommunication> comm_pattern(*current_comm_pattern);
std::vector<std::string> CommunicationDeterminismChecker::get_textual_trace() // override
{
std::vector<std::string> trace;
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_, RequestType::executed));
- }
+ for (auto const& state : stack_)
+ trace.push_back(state->transition_.to_string());
}
XBT_INFO("Expanded states = %lu", expanded_states_count_);
XBT_INFO("Visited states = %lu", api::get().mc_get_visited_states());
}
XBT_INFO("Expanded states = %lu", expanded_states_count_);
XBT_INFO("Visited states = %lu", api::get().mc_get_visited_states());
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");
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");
- /* Get an enabled actor and insert it in the interleave set of the initial state */
- auto actors = api::get().get_actors();
- for (auto& actor : actors)
- if (api::get().actor_is_enabled(actor.copy.get_buffer()->get_pid()))
- initial_state->mark_todo(actor.copy.get_buffer());
+ /* Add all enabled actors to the interleave set of the initial state */
+ 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->get_pid());
+ }
for (size_t current_actor = 1; current_actor < maxpid; current_actor++) {
if (not incomplete_communications_pattern[current_actor].empty()) {
XBT_DEBUG("Some communications are not finished, cannot stop the exploration! State not visited.");
for (size_t current_actor = 1; current_actor < maxpid; current_actor++) {
if (not incomplete_communications_pattern[current_actor].empty()) {
XBT_DEBUG("Some communications are not finished, cannot stop the exploration! State not visited.");
- unsigned long n = api::get().get_maxpid();
- assert(n == incomplete_communications_pattern.size());
- assert(n == initial_communications_pattern.size());
- for (unsigned long j = 0; j < n; j++) {
+ const unsigned long maxpid = api::get().get_maxpid();
+ assert(maxpid == incomplete_communications_pattern.size());
+ assert(maxpid == initial_communications_pattern.size());
+ for (unsigned long j = 0; j < maxpid; j++) {
handle_comm_pattern(call, req, req_num, 1);
handle_comm_pattern(call, req, req_num, 1);
-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)
case CallType::WAITANY: {
RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr;
if (call_type == CallType::WAIT)
case CallType::WAITANY: {
RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr;
if (call_type == CallType::WAIT)
else
comm_addr = api::get().get_comm_waitany_raw_addr(req, value);
auto simcall_issuer = api::get().simcall_get_issuer(req);
else
comm_addr = api::get().get_comm_waitany_raw_addr(req, value);
auto simcall_issuer = api::get().simcall_get_issuer(req);
void CommunicationDeterminismChecker::real_run()
{
std::unique_ptr<VisitedState> visited_state = nullptr;
void CommunicationDeterminismChecker::real_run()
{
std::unique_ptr<VisitedState> visited_state = nullptr;
/* After this call req is no longer useful */
handle_comm_pattern(call, req, req_num, 0);
/* After this call req is no longer useful */
handle_comm_pattern(call, req, req_num, 0);
/* Create the new expanded state */
++expanded_states_count_;
auto next_state = std::make_unique<State>(expanded_states_count_);
/* Create the new expanded state */
++expanded_states_count_;
auto next_state = std::make_unique<State>(expanded_states_count_);
- /* 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());
+ /* Add all enabled actors to the interleave set of the next state */
+ 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->get_pid());
+ }
if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", cur_state->num_, next_state->num_, req_str.c_str());
if (dot_output != nullptr)
fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", cur_state->num_, next_state->num_, req_str.c_str());