req = &actor->simcall_;
break;
- case Simcall::COMM_TESTANY: {
+ case Simcall::COMM_TESTANY:
state->transition_.times_considered_ = -1;
while (procstate->times_considered < simcall_comm_testany__get__count(&actor->simcall_)) {
if (simgrid::mc::request_is_enabled_by_idx(&actor->simcall_, procstate->times_considered)) {
if (state->transition_.times_considered_ != -1)
req = &actor->simcall_;
break;
- }
case Simcall::COMM_WAIT: {
simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> remote_act =
case Simcall::COMM_WAIT:
chosen_comm = simcall_comm_wait__getraw__comm(req);
mc_model_checker->get_remote_simulation().read(state->internal_comm_, remote(chosen_comm));
- simcall_comm_wait__set__comm(&state->executed_req_, state->internal_comm_.get_buffer());
simcall_comm_wait__set__comm(&state->internal_req_, state->internal_comm_.get_buffer());
break;
case Simcall::COMM_TEST:
chosen_comm = simcall_comm_test__getraw__comm(req);
mc_model_checker->get_remote_simulation().read(remote_comm, remote(chosen_comm));
- simcall_comm_test__set__comm(&state->executed_req_, remote_comm.get_buffer());
simcall_comm_test__set__comm(&state->internal_req_, remote_comm.get_buffer());
break;
unsigned long Api::get_maxpid() const
{
+ static const char* name = nullptr;
+ if (not name) {
+ name = "simgrid::kernel::actor::maxpid";
+ if (mc_model_checker->get_remote_simulation().find_variable(name) == nullptr)
+ name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
+ }
unsigned long maxpid;
- const char* name = "simgrid::kernel::actor::maxpid";
- if (mc_model_checker->get_remote_simulation().find_variable(name) == nullptr)
- name = "maxpid"; // We seem to miss the namespaces when compiling with GCC
mc_model_checker->get_remote_simulation().read_variable(name, &maxpid, sizeof(maxpid));
return maxpid;
}
}
}
-std::string Api::request_to_string(smx_simcall_t req, int value, RequestType request_type) const
+std::string Api::request_to_string(smx_simcall_t req, int value) const
{
xbt_assert(mc_model_checker != nullptr, "Must be called from MCer");
- bool use_remote_comm = true;
- switch (request_type) {
- case simgrid::mc::RequestType::simix:
- use_remote_comm = true;
- break;
- case simgrid::mc::RequestType::executed:
- case simgrid::mc::RequestType::internal:
- use_remote_comm = false;
- break;
- default:
- THROW_IMPOSSIBLE;
- }
-
std::string type;
std::string args;
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
const simgrid::kernel::activity::CommImpl* act;
- if (use_remote_comm) {
- mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
- act = temp_synchro.get_buffer();
- } else
- act = remote_act;
+ mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
+ act = temp_synchro.get_buffer();
smx_actor_t src_proc =
mc_model_checker->get_remote_simulation().resolve_actor(simgrid::mc::remote(act->src_actor_.get()));
simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_test__getraw__comm(req);
simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
const simgrid::kernel::activity::CommImpl* act;
- if (use_remote_comm) {
- mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
- act = temp_synchro.get_buffer();
- } else
- act = remote_act;
+ mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
+ act = temp_synchro.get_buffer();
if (act->src_actor_.get() == nullptr || act->dst_actor_.get() == nullptr) {
type = "Test FALSE";
}
break;
- case Simcall::MUTEX_TRYLOCK:
case Simcall::MUTEX_LOCK: {
- if (req->call_ == Simcall::MUTEX_LOCK)
- type = "Mutex LOCK";
- else
- type = "Mutex TRYLOCK";
-
+ type = "Mutex LOCK";
simgrid::mc::Remote<simgrid::kernel::activity::MutexImpl> mutex;
mc_model_checker->get_remote_simulation().read_bytes(mutex.get_buffer(), sizeof(mutex),
- remote(req->call_ == Simcall::MUTEX_LOCK
- ? simcall_mutex_lock__get__mutex(req)
- : simcall_mutex_trylock__get__mutex(req)));
+ remote(simcall_mutex_lock__get__mutex(req)));
args = "locked = " + std::to_string(mutex.get_buffer()->is_locked()) + ", owner = ";
if (mutex.get_buffer()->get_owner() != nullptr)
args += std::to_string(mc_model_checker->get_remote_simulation()
}
break;
- case Simcall::MUTEX_TRYLOCK:
- label = "[" + get_actor_dot_label(issuer) + "] Mutex TRYLOCK";
- break;
-
case Simcall::MUTEX_LOCK:
label = "[" + get_actor_dot_label(issuer) + "] Mutex LOCK";
break;
void Api::execute(Transition& transition, smx_simcall_t simcall) const
{
/* FIXME: once all simcalls have observers, kill the simcall parameter and use mc_model_checker->simcall_to_string() */
- transition.textual = request_to_string(simcall, transition.times_considered_, RequestType::executed);
+ transition.textual = request_to_string(simcall, transition.times_considered_);
session->execute(transition);
}
for (size_t i = 0; i < initial_communications_pattern.size(); i++)
initial_communications_pattern[i].index_comm = state->communication_indices_[i];
- for (unsigned long i = 0; i < api::get().get_maxpid(); i++)
+ const unsigned long maxpid = api::get().get_maxpid();
+ for (unsigned long i = 0; i < maxpid; i++)
patterns_copy(incomplete_communications_pattern[i], state->incomplete_comm_pattern_[i]);
}
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));
+ trace.push_back(api::get().request_to_string(req, state->transition_.times_considered_));
}
return trace;
}
void CommunicationDeterminismChecker::prepare()
{
- const auto maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = api::get().get_maxpid();
initial_communications_pattern.resize(maxpid);
incomplete_communications_pattern.resize(maxpid);
static inline bool all_communications_are_finished()
{
- auto maxpid = api::get().get_maxpid();
+ const unsigned long maxpid = api::get().get_maxpid();
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.");
/* Restore the initial state */
api::get().restore_initial_state();
- 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++) {
incomplete_communications_pattern[j].clear();
initial_communications_pattern[j].index_comm = 0;
}
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());
+ XBT_DEBUG("Execute: %s", api::get().request_to_string(req, req_num).c_str());
std::string req_str;
if (dot_output != nullptr)
// If there are processes to interleave and the maximum depth has not been
// reached then perform one step of the exploration algorithm.
- XBT_DEBUG("Execute: %s",
- api::get().request_to_string(req, state->transition_.times_considered_, RequestType::simix).c_str());
+ XBT_DEBUG("Execute: %s", api::get().request_to_string(req, state->transition_.times_considered_).c_str());
std::string req_str;
if (dot_output != nullptr)
std::unique_ptr<State> state = std::move(stack_.back());
stack_.pop_back();
if (reductionMode_ == ReductionMode::dpor) {
- smx_simcall_t req = &state->internal_req_;
- // FIXME: need something less ugly than this substring search
- if (req->call_ == simix::Simcall::MUTEX_LOCK ||
- (req->observer_ &&
- api::get().request_to_string(req, 0, RequestType::internal).find("Mutex") != std::string::npos))
+ auto call = state->executed_req_.call_;
+ const kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(&state->executed_req_);
- if (call == simix::Simcall::MUTEX_LOCK || call == simix::Simcall::MUTEX_TRYLOCK)
++ if (call == simix::Simcall::MUTEX_LOCK)
xbt_die("Mutex is currently not supported with DPOR, use --cfg=model-check/reduction:none");
- const kernel::actor::ActorImpl* issuer = api::get().simcall_get_issuer(req);
for (auto i = stack_.rbegin(); i != stack_.rend(); ++i) {
State* prev_state = i->get();
- if (api::get().simcall_check_dependency(req, &prev_state->internal_req_)) {
+ if (state->executed_req_.issuer_ == prev_state->executed_req_.issuer_) {
+ XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(call),
+ SIMIX_simcall_name(prev_state->executed_req_.call_));
+ break;
+ } else if (api::get().simcall_check_dependency(&state->internal_req_, &prev_state->internal_req_)) {
if (XBT_LOG_ISENABLED(mc_safety, xbt_log_priority_debug)) {
XBT_DEBUG("Dependent Transitions:");
int value = prev_state->transition_.times_considered_;
smx_simcall_t prev_req = &prev_state->executed_req_;
- XBT_DEBUG("%s (state=%d)", api::get().request_to_string(prev_req, value, RequestType::internal).c_str(),
- prev_state->num_);
+ XBT_DEBUG("%s (state=%d)", api::get().request_to_string(prev_req, value).c_str(), prev_state->num_);
value = state->transition_.times_considered_;
prev_req = &state->executed_req_;
- XBT_DEBUG("%s (state=%d)", api::get().request_to_string(prev_req, value, RequestType::executed).c_str(),
- state->num_);
+ XBT_DEBUG("%s (state=%d)", api::get().request_to_string(prev_req, value).c_str(), state->num_);
}
if (not prev_state->actor_states_[issuer->get_pid()].is_done())
prev_state->mark_todo(issuer);
else
- XBT_DEBUG("Process %p is in done set", req->issuer_);
- break;
- } else if (req->issuer_ == prev_state->internal_req_.issuer_) {
- XBT_DEBUG("Simcall %s and %s with same issuer", SIMIX_simcall_name(req->call_),
- SIMIX_simcall_name(prev_state->internal_req_.call_));
+ XBT_DEBUG("Actor %s %ld is in done set", issuer->get_cname(), issuer->get_pid());
break;
} else {
- const kernel::actor::ActorImpl* previous_issuer = api::get().simcall_get_issuer(&prev_state->internal_req_);
+ const kernel::actor::ActorImpl* previous_issuer = api::get().simcall_get_issuer(&prev_state->executed_req_);
XBT_DEBUG("Simcall %s, process %ld (state %d) and simcall %s, process %ld (state %d) are independent",
- SIMIX_simcall_name(req->call_), issuer->get_pid(), state->num_,
- SIMIX_simcall_name(prev_state->internal_req_.call_), previous_issuer->get_pid(), prev_state->num_);
+ SIMIX_simcall_name(call), issuer->get_pid(), state->num_,
+ SIMIX_simcall_name(prev_state->executed_req_.call_), previous_issuer->get_pid(), prev_state->num_);
}
}
}