From 07483e97b12350d1d293f19689575f0fbdcf0246 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 8 Jan 2017 17:48:07 +0100 Subject: [PATCH] smx processes are now called actors, avoiding confusions in MC the process->actor renaming comes from S4U, but this is really welcome in the model checker, as Process is also the proxy of the MCed on the MCer side. --- src/mc/Client.cpp | 10 +- src/mc/CommunicationDeterminismChecker.cpp | 41 +++---- src/mc/LivenessChecker.cpp | 20 +-- src/mc/LivenessChecker.hpp | 2 +- src/mc/Process.cpp | 12 +- src/mc/Process.hpp | 40 +++--- src/mc/SafetyChecker.cpp | 12 +- src/mc/VisitedState.cpp | 7 +- src/mc/VisitedState.hpp | 2 +- src/mc/mc_base.cpp | 4 +- src/mc/mc_checkpoint.cpp | 2 +- src/mc/mc_forward.hpp | 2 +- src/mc/mc_private.h | 5 +- src/mc/mc_request.cpp | 134 ++++++++------------- src/mc/mc_request.h | 2 +- src/mc/mc_smx.cpp | 66 +++++----- src/mc/mc_smx.h | 4 +- src/mc/mc_state.cpp | 4 +- 18 files changed, 157 insertions(+), 212 deletions(-) diff --git a/src/mc/Client.cpp b/src/mc/Client.cpp index e712affd25..d28a00bafe 100644 --- a/src/mc/Client.cpp +++ b/src/mc/Client.cpp @@ -103,13 +103,13 @@ void Client::handleMessages() { // Check deadlock: bool deadlock = false; - smx_actor_t process; + smx_actor_t actor; if (xbt_swag_size(simix_global->process_list)) { deadlock = true; - xbt_swag_foreach(process, simix_global->process_list) - if (simgrid::mc::process_is_enabled(process)) { - deadlock = false; - break; + xbt_swag_foreach(actor, simix_global->process_list) if (simgrid::mc::actor_is_enabled(actor)) + { + deadlock = false; + break; } } diff --git a/src/mc/CommunicationDeterminismChecker.cpp b/src/mc/CommunicationDeterminismChecker.cpp index e15390d86e..503cbec392 100644 --- a/src/mc/CommunicationDeterminismChecker.cpp +++ b/src/mc/CommunicationDeterminismChecker.cpp @@ -103,14 +103,12 @@ static void update_comm_pattern( simgrid::kernel::activity::Comm* comm = static_cast(temp_comm.getBuffer()); - smx_actor_t src_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(comm->src_proc)); - smx_actor_t dst_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(comm->dst_proc)); + smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->src_proc)); + smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc)); comm_pattern->src_proc = src_proc->pid; comm_pattern->dst_proc = dst_proc->pid; - comm_pattern->src_host = MC_smx_process_get_host_name(src_proc); - comm_pattern->dst_host = MC_smx_process_get_host_name(dst_proc); + comm_pattern->src_host = MC_smx_actor_get_host_name(src_proc); + comm_pattern->dst_host = MC_smx_actor_get_host_name(dst_proc); if (comm_pattern->data.size() == 0 && comm->src_buff != nullptr) { size_t buff_size; mc_model_checker->process().read( @@ -204,9 +202,8 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim char* remote_name = mc_model_checker->process().read( (std::uint64_t)(synchro->mbox ? &synchro->mbox->name : &synchro->mbox_cpy->name)); pattern->rdv = mc_model_checker->process().read_string(remote_name); - pattern->src_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(synchro->src_proc))->pid; - pattern->src_host = MC_smx_process_get_host_name(issuer); + pattern->src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(synchro->src_proc))->pid; + pattern->src_host = MC_smx_actor_get_host_name(issuer); struct s_smpi_mpi_request mpi_request = mc_model_checker->process().read( @@ -253,9 +250,8 @@ void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_sim mc_model_checker->process().read(&remote_name, remote(comm->mbox ? &comm->mbox->name : &comm->mbox_cpy->name)); pattern->rdv = mc_model_checker->process().read_string(remote_name); - pattern->dst_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(comm->dst_proc))->pid; - pattern->dst_host = MC_smx_process_get_host_name(issuer); + pattern->dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc))->pid; + pattern->dst_host = MC_smx_actor_get_host_name(issuer); } else xbt_die("Unexpected call_type %i", (int) call_type); @@ -390,10 +386,10 @@ void CommunicationDeterminismChecker::prepare() XBT_DEBUG("********* Start communication determinism verification *********"); - /* Get an enabled process and insert it in the interleave set of the initial state */ - for (auto& p : mc_model_checker->process().simix_processes()) - if (simgrid::mc::process_is_enabled(p.copy.getBuffer())) - initial_state->interleave(p.copy.getBuffer()); + /* Get an enabled actor and insert it in the interleave set of the initial state */ + for (auto& actor : mc_model_checker->process().actors()) + if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) + initial_state->interleave(actor.copy.getBuffer()); stack_.push_back(std::move(initial_state)); } @@ -401,9 +397,8 @@ void CommunicationDeterminismChecker::prepare() static inline bool all_communications_are_finished() { - for (size_t current_process = 1; current_process < MC_smx_get_maxpid(); current_process++) { - xbt_dynar_t pattern = xbt_dynar_get_as( - incomplete_communications_pattern, current_process, xbt_dynar_t); + for (size_t current_actor = 1; current_actor < MC_smx_get_maxpid(); current_actor++) { + xbt_dynar_t pattern = xbt_dynar_get_as(incomplete_communications_pattern, current_actor, xbt_dynar_t); if (!xbt_dynar_is_empty(pattern)) { XBT_DEBUG("Some communications are not finished, cannot stop the exploration ! State not visited."); return false; @@ -529,10 +524,10 @@ int CommunicationDeterminismChecker::main(void) || (visited_state = visitedStates_.addVisitedState( expandedStatesCount_, next_state.get(), compare_snapshots)) == nullptr) { - /* Get enabled processes and insert them in the interleave set of the next state */ - for (auto& p : mc_model_checker->process().simix_processes()) - if (simgrid::mc::process_is_enabled(p.copy.getBuffer())) - next_state->interleave(p.copy.getBuffer()); + /* Get enabled actors and insert them in the interleave set of the next state */ + for (auto& actor : mc_model_checker->process().actors()) + if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) + next_state->interleave(actor.copy.getBuffer()); if (dot_output != nullptr) fprintf(dot_output, "\"%d\" -> \"%d\" [%s];\n", diff --git a/src/mc/LivenessChecker.cpp b/src/mc/LivenessChecker.cpp index d936c1a781..529e8ec603 100644 --- a/src/mc/LivenessChecker.cpp +++ b/src/mc/LivenessChecker.cpp @@ -55,7 +55,7 @@ VisitedPair::VisitedPair( process->get_heap()->heaplimit, process->get_malloc_info()); - this->nb_processes = mc_model_checker->process().simix_processes().size(); + this->actors_count = mc_model_checker->process().actors().size(); this->automaton_state = automaton_state; this->num = pair_num; @@ -125,8 +125,8 @@ std::shared_ptr LivenessChecker::insertAcceptancePair(simgrid::mc:: pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state); - auto res = boost::range::equal_range(acceptancePairs_, - new_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap()); + auto res = boost::range::equal_range(acceptancePairs_, new_pair.get(), + simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap()); if (pair->search_cycle) for (auto i = res.first; i != res.second; ++i) { std::shared_ptr const& pair_test = *i; @@ -246,8 +246,8 @@ int LivenessChecker::insertVisitedPair(std::shared_ptr visited_pair pair->num, pair->automaton_state, pair->atomic_propositions, pair->graph_state); - auto range = boost::range::equal_range(visitedPairs_, - visited_pair.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap()); + auto range = boost::range::equal_range(visitedPairs_, visited_pair.get(), + simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap()); for (auto i = range.first; i != range.second; ++i) { VisitedPair* pair_test = i->get(); @@ -443,12 +443,12 @@ std::shared_ptr LivenessChecker::newPair(Pair* current_pair, xbt_automaton next_pair->depth = current_pair->depth + 1; else next_pair->depth = 1; - /* Get enabled processes and insert them in the interleave set of the next graph_state */ - for (auto& p : mc_model_checker->process().simix_processes()) - if (simgrid::mc::process_is_enabled(p.copy.getBuffer())) - next_pair->graph_state->interleave(p.copy.getBuffer()); + /* Get enabled actors and insert them in the interleave set of the next graph_state */ + for (auto& actor : mc_model_checker->process().actors()) + if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) + next_pair->graph_state->interleave(actor.copy.getBuffer()); next_pair->requests = next_pair->graph_state->interleaveSize(); - /* FIXME : get search_cycle value for each acceptant state */ + /* FIXME : get search_cycle value for each accepting state */ if (next_pair->automaton_state->type == 1 || (current_pair && current_pair->search_cycle)) next_pair->search_cycle = true; diff --git a/src/mc/LivenessChecker.hpp b/src/mc/LivenessChecker.hpp index efac9ad815..751dacc70f 100644 --- a/src/mc/LivenessChecker.hpp +++ b/src/mc/LivenessChecker.hpp @@ -52,7 +52,7 @@ struct XBT_PRIVATE VisitedPair { xbt_automaton_state_t automaton_state = nullptr; std::shared_ptr> atomic_propositions; std::size_t heap_bytes_used = 0; - int nb_processes = 0; + int actors_count = 0; VisitedPair( int pair_num, xbt_automaton_state_t automaton_state, diff --git a/src/mc/Process.cpp b/src/mc/Process.cpp index 14f08904b1..30a45ff7c9 100644 --- a/src/mc/Process.cpp +++ b/src/mc/Process.cpp @@ -233,8 +233,8 @@ void Process::init() remote(std_heap_var->address), simgrid::mc::ProcessIndexDisabled); - this->smx_process_infos.clear(); - this->smx_old_process_infos.clear(); + this->smx_actors_infos.clear(); + this->smx_dead_actors_infos.clear(); this->unw_addr_space = simgrid::mc::UnwindContext::createUnwindAddressSpace(); this->unw_underlying_addr_space = simgrid::unw::create_addr_space(); this->unw_underlying_context = simgrid::unw::create_context( @@ -643,16 +643,16 @@ void Process::ignore_local_variable(const char *var_name, const char *frame_name info->remove_local_variable(var_name, frame_name); } -std::vector& Process::simix_processes() +std::vector& Process::actors() { this->refresh_simix(); - return smx_process_infos; + return smx_actors_infos; } -std::vector& Process::old_simix_processes() +std::vector& Process::dead_actors() { this->refresh_simix(); - return smx_old_process_infos; + return smx_dead_actors_infos; } void Process::dumpStack() diff --git a/src/mc/Process.hpp b/src/mc/Process.hpp index 97787020e0..2e93cf7dac 100644 --- a/src/mc/Process.hpp +++ b/src/mc/Process.hpp @@ -42,7 +42,7 @@ namespace simgrid { namespace mc { -class SimixProcessInformation { +class ActorInformation { public: /** MCed address of the process */ RemotePtr address = nullptr; @@ -219,33 +219,31 @@ public: void unignore_heap(void *address, size_t size); void ignore_local_variable(const char *var_name, const char *frame_name); - std::vector& simix_processes(); - std::vector& old_simix_processes(); + std::vector& actors(); + std::vector& dead_actors(); - /** Get a local description of a remote SIMIX process */ - simgrid::mc::SimixProcessInformation* resolveProcessInfo( - simgrid::mc::RemotePtr process) + /** Get a local description of a remote SIMIX actor */ + simgrid::mc::ActorInformation* resolveActorInfo(simgrid::mc::RemotePtr actor) { xbt_assert(mc_model_checker != nullptr); - if (!process) + if (!actor) return nullptr; this->refresh_simix(); - for (auto& process_info : this->smx_process_infos) - if (process_info.address == process) - return &process_info; - for (auto& process_info : this->smx_old_process_infos) - if (process_info.address == process) - return &process_info; + for (auto& actor_info : this->smx_actors_infos) + if (actor_info.address == actor) + return &actor_info; + for (auto& actor_info : this->smx_dead_actors_infos) + if (actor_info.address == actor) + return &actor_info; return nullptr; } - /** Get a local copy of the SIMIX process structure */ - simgrid::simix::ActorImpl* resolveProcess(simgrid::mc::RemotePtr process) + /** Get a local copy of the SIMIX actor structure */ + simgrid::simix::ActorImpl* resolveActor(simgrid::mc::RemotePtr process) { - simgrid::mc::SimixProcessInformation* process_info = - this->resolveProcessInfo(process); - if (process_info) - return process_info->copy.getBuffer(); + simgrid::mc::ActorInformation* actor_info = this->resolveActorInfo(process); + if (actor_info) + return actor_info->copy.getBuffer(); else return nullptr; } @@ -281,13 +279,13 @@ public: // Copies of MCed SMX data structures * * See mc_smx.c. */ - std::vector smx_process_infos; + std::vector smx_actors_infos; /** Copy of `simix_global->process_to_destroy` * * See mc_smx.c. */ - std::vector smx_old_process_infos; + std::vector smx_dead_actors_infos; private: /** State of the cache (which variables are up to date) */ diff --git a/src/mc/SafetyChecker.cpp b/src/mc/SafetyChecker.cpp index 195a53c641..47e2e70e4c 100644 --- a/src/mc/SafetyChecker.cpp +++ b/src/mc/SafetyChecker.cpp @@ -150,8 +150,8 @@ int SafetyChecker::run() || (visitedState_ = visitedStates_.addVisitedState(expandedStatesCount_, next_state.get(), true)) == nullptr) { /* Get an enabled process and insert it in the interleave set of the next state */ - for (auto& p : mc_model_checker->process().simix_processes()) - if (simgrid::mc::process_is_enabled(p.copy.getBuffer())) { + for (auto& p : mc_model_checker->process().actors()) + if (simgrid::mc::actor_is_enabled(p.copy.getBuffer())) { next_state->interleave(p.copy.getBuffer()); if (reductionMode_ != simgrid::mc::ReductionMode::none) break; @@ -323,10 +323,10 @@ SafetyChecker::SafetyChecker(Session& session) : Checker(session) XBT_DEBUG("**************************************************"); XBT_DEBUG("Initial state"); - /* Get an enabled process and insert it in the interleave set of the initial state */ - for (auto& p : mc_model_checker->process().simix_processes()) - if (simgrid::mc::process_is_enabled(p.copy.getBuffer())) { - initial_state->interleave(p.copy.getBuffer()); + /* Get an enabled actor and insert it in the interleave set of the initial state */ + for (auto& actor : mc_model_checker->process().actors()) + if (simgrid::mc::actor_is_enabled(actor.copy.getBuffer())) { + initial_state->interleave(actor.copy.getBuffer()); if (reductionMode_ != simgrid::mc::ReductionMode::none) break; } diff --git a/src/mc/VisitedState.cpp b/src/mc/VisitedState.cpp index 5d547bfd50..88bc0c2e44 100644 --- a/src/mc/VisitedState.cpp +++ b/src/mc/VisitedState.cpp @@ -47,8 +47,7 @@ VisitedState::VisitedState(unsigned long state_number) process->get_heap()->heaplimit, process->get_malloc_info()); - this->nb_processes = - mc_model_checker->process().simix_processes().size(); + this->actors_count = mc_model_checker->process().actors().size(); this->system_state = simgrid::mc::take_snapshot(state_number); this->num = state_number; @@ -86,8 +85,8 @@ std::unique_ptr VisitedStates::addVisitedState( XBT_DEBUG("Snapshot %p of visited state %d (exploration stack state %d)", new_state->system_state.get(), new_state->num, graph_state->num); - auto range = boost::range::equal_range(states_, - new_state.get(), simgrid::mc::DerefAndCompareByNbProcessesAndUsedHeap()); + auto range = + boost::range::equal_range(states_, new_state.get(), simgrid::mc::DerefAndCompareByActorsCountAndUsedHeap()); if (compare_snpashots) for (auto i = range.first; i != range.second; ++i) { diff --git a/src/mc/VisitedState.hpp b/src/mc/VisitedState.hpp index 13691af2e3..b9e85967ba 100644 --- a/src/mc/VisitedState.hpp +++ b/src/mc/VisitedState.hpp @@ -19,7 +19,7 @@ namespace mc { struct XBT_PRIVATE VisitedState { std::shared_ptr system_state = nullptr; std::size_t heap_bytes_used = 0; - int nb_processes = 0; + int actors_count = 0; int num = 0; int other_num = 0; // dot_output for diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 18447d090f..541e314256 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -189,8 +189,8 @@ bool request_is_enabled(smx_simcall_t req) else if (mc_model_checker != nullptr) { simgrid::mc::Process& modelchecked = mc_model_checker->process(); // TODO, *(mutex->owner) :/ - return modelchecked.resolveProcess(simgrid::mc::remote(mutex->owner))->pid - == modelchecked.resolveProcess(simgrid::mc::remote(req->issuer))->pid; + return modelchecked.resolveActor(simgrid::mc::remote(mutex->owner))->pid == + modelchecked.resolveActor(simgrid::mc::remote(req->issuer))->pid; } #endif else diff --git a/src/mc/mc_checkpoint.cpp b/src/mc/mc_checkpoint.cpp index 24a03ae2ad..6c193dce13 100644 --- a/src/mc/mc_checkpoint.cpp +++ b/src/mc/mc_checkpoint.cpp @@ -565,7 +565,7 @@ std::shared_ptr take_snapshot(int num_state) std::shared_ptr snapshot = std::make_shared(mc_process, num_state); - for (auto& p : mc_model_checker->process().simix_processes()) + for (auto& p : mc_model_checker->process().actors()) snapshot->enabled_processes.insert(p.copy.getBuffer()->pid); snapshot_handle_ignore(snapshot.get()); diff --git a/src/mc/mc_forward.hpp b/src/mc/mc_forward.hpp index e36347e0c7..8bc8105575 100644 --- a/src/mc/mc_forward.hpp +++ b/src/mc/mc_forward.hpp @@ -26,7 +26,7 @@ class Member; class Type; class Variable; class Frame; -class SimixProcessInformation; +class ActorInformation; class Session; class Checker; diff --git a/src/mc/mc_private.h b/src/mc/mc_private.h index 0ef9cfb2a8..4e8285c26c 100644 --- a/src/mc/mc_private.h +++ b/src/mc/mc_private.h @@ -33,12 +33,11 @@ namespace simgrid { namespace mc { -struct DerefAndCompareByNbProcessesAndUsedHeap { +struct DerefAndCompareByActorsCountAndUsedHeap { template bool operator()(X const& a, Y const& b) { - return std::make_pair(a->nb_processes, a->heap_bytes_used) < - std::make_pair(b->nb_processes, b->heap_bytes_used); + return std::make_pair(a->actors_count, a->heap_bytes_used) < std::make_pair(b->actors_count, b->heap_bytes_used); } }; diff --git a/src/mc/mc_request.cpp b/src/mc/mc_request.cpp index e2087298af..dfb4e9a3e1 100644 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@ -232,15 +232,10 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid char* p = pointer_to_string(simcall_comm_isend__get__src_buff(req)); char* bs = buff_size_to_string(simcall_comm_isend__get__src_buff_size(req)); if (issuer->host) - args = - bprintf("src=(%lu)%s (%s), buff=%s, size=%s", issuer->pid, - MC_smx_process_get_host_name(issuer), - MC_smx_process_get_name(issuer), - p, bs); + args = bprintf("src=(%lu)%s (%s), buff=%s, size=%s", issuer->pid, MC_smx_actor_get_host_name(issuer), + MC_smx_actor_get_name(issuer), p, bs); else - args = - bprintf("src=(%lu)%s, buff=%s, size=%s", issuer->pid, - MC_smx_process_get_name(issuer), p, bs); + args = bprintf("src=(%lu)%s, buff=%s, size=%s", issuer->pid, MC_smx_actor_get_name(issuer), p, bs); xbt_free(bs); xbt_free(p); break; @@ -259,16 +254,10 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid char* p = pointer_to_string(simcall_comm_irecv__get__dst_buff(req)); char* bs = buff_size_to_string(size); if (issuer->host) - args = - bprintf("dst=(%lu)%s (%s), buff=%s, size=%s", issuer->pid, - MC_smx_process_get_host_name(issuer), - MC_smx_process_get_name(issuer), - p, bs); + args = bprintf("dst=(%lu)%s (%s), buff=%s, size=%s", issuer->pid, MC_smx_actor_get_host_name(issuer), + MC_smx_actor_get_name(issuer), p, bs); else - args = - bprintf("dst=(%lu)%s, buff=%s, size=%s", issuer->pid, - MC_smx_process_get_name(issuer), - p, bs); + args = bprintf("dst=(%lu)%s, buff=%s, size=%s", issuer->pid, MC_smx_actor_get_name(issuer), p, bs); xbt_free(bs); xbt_free(p); break; @@ -295,17 +284,13 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid } else act = remote_act; - smx_actor_t src_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(act->src_proc)); - smx_actor_t dst_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(act->dst_proc)); - args = bprintf("comm=%s [(%lu)%s (%s)-> (%lu)%s (%s)]", p, - src_proc ? src_proc->pid : 0, - src_proc ? MC_smx_process_get_host_name(src_proc) : "", - src_proc ? MC_smx_process_get_name(src_proc) : "", - dst_proc ? dst_proc->pid : 0, - dst_proc ? MC_smx_process_get_host_name(dst_proc) : "", - dst_proc ? MC_smx_process_get_name(dst_proc) : ""); + smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->src_proc)); + smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->dst_proc)); + args = + bprintf("comm=%s [(%lu)%s (%s)-> (%lu)%s (%s)]", p, src_proc ? src_proc->pid : 0, + src_proc ? MC_smx_actor_get_host_name(src_proc) : "", src_proc ? MC_smx_actor_get_name(src_proc) : "", + dst_proc ? dst_proc->pid : 0, dst_proc ? MC_smx_actor_get_host_name(dst_proc) : "", + dst_proc ? MC_smx_actor_get_name(dst_proc) : ""); } xbt_free(p); break; @@ -332,17 +317,11 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid type = "Test TRUE"; p = pointer_to_string(remote_act); - smx_actor_t src_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(act->src_proc)); - smx_actor_t dst_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(act->dst_proc)); - args = bprintf("comm=%s [(%lu)%s (%s) -> (%lu)%s (%s)]", p, - src_proc->pid, - MC_smx_process_get_name(src_proc), - MC_smx_process_get_host_name(src_proc), - dst_proc->pid, - MC_smx_process_get_name(dst_proc), - MC_smx_process_get_host_name(dst_proc)); + smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->src_proc)); + smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(act->dst_proc)); + args = bprintf("comm=%s [(%lu)%s (%s) -> (%lu)%s (%s)]", p, src_proc->pid, MC_smx_actor_get_name(src_proc), + MC_smx_actor_get_host_name(src_proc), dst_proc->pid, MC_smx_actor_get_name(dst_proc), + MC_smx_actor_get_host_name(dst_proc)); } xbt_free(p); break; @@ -397,11 +376,12 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid mc_model_checker->process().read_bytes(&mutex_sleeping, sizeof(mutex_sleeping), remote(mutex.getBuffer()->sleeping)); - args = bprintf("locked = %d, owner = %d, sleeping = %d", - mutex.getBuffer()->locked, - mutex.getBuffer()->owner != nullptr ? (int) mc_model_checker->process().resolveProcess( - simgrid::mc::remote(mutex.getBuffer()->owner))->pid : -1, - mutex_sleeping.count); + args = + bprintf("locked = %d, owner = %d, sleeping = %d", mutex.getBuffer()->locked, + mutex.getBuffer()->owner != nullptr + ? (int)mc_model_checker->process().resolveActor(simgrid::mc::remote(mutex.getBuffer()->owner))->pid + : -1, + mutex_sleeping.count); break; } @@ -416,15 +396,11 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid std::string str; if (args != nullptr) - str = simgrid::xbt::string_printf("[(%lu)%s (%s)] %s(%s)", issuer->pid, - MC_smx_process_get_host_name(issuer), - MC_smx_process_get_name(issuer), - type, args); + str = simgrid::xbt::string_printf("[(%lu)%s (%s)] %s(%s)", issuer->pid, MC_smx_actor_get_host_name(issuer), + MC_smx_actor_get_name(issuer), type, args); else - str = simgrid::xbt::string_printf("[(%lu)%s (%s)] %s ", issuer->pid, - MC_smx_process_get_host_name(issuer), - MC_smx_process_get_name(issuer), - type); + str = simgrid::xbt::string_printf("[(%lu)%s (%s)] %s ", issuer->pid, MC_smx_actor_get_host_name(issuer), + MC_smx_actor_get_name(issuer), type); xbt_free(args); return str; } @@ -466,9 +442,9 @@ bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx) return comm->src_proc && comm->dst_proc; } -bool process_is_enabled(smx_actor_t process) +bool actor_is_enabled(smx_actor_t actor) { - return simgrid::mc::request_is_enabled(&process->simcall); + return simgrid::mc::request_is_enabled(&actor->simcall); } static const char* colors[] = { @@ -501,16 +477,14 @@ std::string request_get_dot_output(smx_simcall_t req, int value) switch (req->call) { case SIMCALL_COMM_ISEND: if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] iSend", issuer->pid, - MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] iSend", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = bprintf("[(%lu)] iSend", issuer->pid); break; case SIMCALL_COMM_IRECV: if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] iRecv", issuer->pid, - MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] iRecv", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = simgrid::xbt::string_printf("[(%lu)] iRecv", issuer->pid); break; @@ -518,8 +492,7 @@ std::string request_get_dot_output(smx_simcall_t req, int value) case SIMCALL_COMM_WAIT: { if (value == -1) { if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] WaitTimeout", issuer->pid, - MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] WaitTimeout", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = simgrid::xbt::string_printf("[(%lu)] WaitTimeout", issuer->pid); } else { @@ -529,16 +502,12 @@ std::string request_get_dot_output(smx_simcall_t req, int value) static_cast(remote_act))); simgrid::kernel::activity::Comm* comm = temp_comm.getBuffer(); - smx_actor_t src_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(comm->src_proc)); - smx_actor_t dst_proc = mc_model_checker->process().resolveProcess( - simgrid::mc::remote(comm->dst_proc)); + smx_actor_t src_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->src_proc)); + smx_actor_t dst_proc = mc_model_checker->process().resolveActor(simgrid::mc::remote(comm->dst_proc)); if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] Wait [(%lu)->(%lu)]", - issuer->pid, - MC_smx_process_get_host_name(issuer), - src_proc ? src_proc->pid : 0, - dst_proc ? dst_proc->pid : 0); + label = simgrid::xbt::string_printf("[(%lu)%s] Wait [(%lu)->(%lu)]", issuer->pid, + MC_smx_actor_get_host_name(issuer), src_proc ? src_proc->pid : 0, + dst_proc ? dst_proc->pid : 0); else label = simgrid::xbt::string_printf("[(%lu)] Wait [(%lu)->(%lu)]", issuer->pid, @@ -556,15 +525,12 @@ std::string request_get_dot_output(smx_simcall_t req, int value) simgrid::kernel::activity::Comm* comm = temp_comm.getBuffer(); if (comm->src_proc == nullptr || comm->dst_proc == nullptr) { if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] Test FALSE", - issuer->pid, - MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] Test FALSE", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = bprintf("[(%lu)] Test FALSE", issuer->pid); } else { if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] Test TRUE", issuer->pid, - MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] Test TRUE", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = simgrid::xbt::string_printf("[(%lu)] Test TRUE", issuer->pid); } @@ -575,10 +541,8 @@ std::string request_get_dot_output(smx_simcall_t req, int value) unsigned long comms_size = read_length( mc_model_checker->process(), remote(simcall_comm_waitany__get__comms(req))); if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] WaitAny [%d of %lu]", - issuer->pid, - MC_smx_process_get_host_name(issuer), value + 1, - comms_size); + label = simgrid::xbt::string_printf("[(%lu)%s] WaitAny [%d of %lu]", issuer->pid, + MC_smx_actor_get_host_name(issuer), value + 1, comms_size); else label = simgrid::xbt::string_printf("[(%lu)] WaitAny [%d of %lu]", issuer->pid, value + 1, comms_size); @@ -588,16 +552,14 @@ std::string request_get_dot_output(smx_simcall_t req, int value) case SIMCALL_COMM_TESTANY: if (value == -1) { if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] TestAny FALSE", - issuer->pid, MC_smx_process_get_host_name(issuer)); + label = simgrid::xbt::string_printf("[(%lu)%s] TestAny FALSE", issuer->pid, MC_smx_actor_get_host_name(issuer)); else label = simgrid::xbt::string_printf("[(%lu)] TestAny FALSE", issuer->pid); } else { if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] TestAny TRUE [%d of %lu]", - issuer->pid, - MC_smx_process_get_host_name(issuer), value + 1, - simcall_comm_testany__get__count(req)); + label = simgrid::xbt::string_printf("[(%lu)%s] TestAny TRUE [%d of %lu]", issuer->pid, + MC_smx_actor_get_host_name(issuer), value + 1, + simcall_comm_testany__get__count(req)); else label = simgrid::xbt::string_printf("[(%lu)] TestAny TRUE [%d of %lu]", issuer->pid, @@ -616,8 +578,8 @@ std::string request_get_dot_output(smx_simcall_t req, int value) case SIMCALL_MC_RANDOM: if (issuer->host) - label = simgrid::xbt::string_printf("[(%lu)%s] MC_RANDOM (%d)", - issuer->pid, MC_smx_process_get_host_name(issuer), value); + label = simgrid::xbt::string_printf("[(%lu)%s] MC_RANDOM (%d)", issuer->pid, MC_smx_actor_get_host_name(issuer), + value); else label = simgrid::xbt::string_printf("[(%lu)] MC_RANDOM (%d)", issuer->pid, value); break; diff --git a/src/mc/mc_request.h b/src/mc/mc_request.h index 674b763e90..476cf9e0fe 100644 --- a/src/mc/mc_request.h +++ b/src/mc/mc_request.h @@ -32,7 +32,7 @@ XBT_PRIVATE bool request_is_enabled_by_idx(smx_simcall_t req, unsigned int idx); * * This is true if the request associated with the process is ready. */ -XBT_PRIVATE bool process_is_enabled(smx_actor_t process); +XBT_PRIVATE bool actor_is_enabled(smx_actor_t process); XBT_PRIVATE std::string request_get_dot_output(smx_simcall_t req, int value); diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index e4c41faff7..86303fc333 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -1,5 +1,4 @@ -/* Copyright (c) 2015. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2015-2017. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -25,20 +24,18 @@ using simgrid::mc::remote; -/** HACK, Statically "upcast" a s_smx_actor_t into a SimixProcessInformation +/** HACK, Statically "upcast" a s_smx_actor_t into a ActorInformation * - * This gets 'processInfo' from '&processInfo->copy'. It upcasts in the - * sense that we could achieve the same thing by having SimixProcessInformation + * This gets 'actorInfo' from '&actorInfo->copy'. It upcasts in the + * sense that we could achieve the same thing by having ActorInformation * inherit from s_smx_actor_t but we don't really want to do that. */ -static inline -simgrid::mc::SimixProcessInformation* process_info_cast(smx_actor_t p) +static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) { - simgrid::mc::SimixProcessInformation temp; + simgrid::mc::ActorInformation temp; std::size_t offset = (char*) temp.copy.getBuffer() - (char*)&temp; - simgrid::mc::SimixProcessInformation* process_info = - (simgrid::mc::SimixProcessInformation*) ((char*) p - offset); + simgrid::mc::ActorInformation* process_info = (simgrid::mc::ActorInformation*)((char*)actor - offset); return process_info; } @@ -48,10 +45,9 @@ simgrid::mc::SimixProcessInformation* process_info_cast(smx_actor_t p) * @param target Local vector (to be filled with copies of `s_smx_actor_t`) * @param remote_swag Address of the process SWAG in the remote list */ -static void MC_process_refresh_simix_process_list( - simgrid::mc::Process* process, - std::vector& target, - simgrid::mc::RemotePtr remote_swag) +static void MC_process_refresh_simix_process_list(simgrid::mc::Process* process, + std::vector& target, + simgrid::mc::RemotePtr remote_swag) { target.clear(); @@ -63,7 +59,7 @@ static void MC_process_refresh_simix_process_list( int i = 0; for (smx_actor_t p = (smx_actor_t) swag.head; p; ++i) { - simgrid::mc::SimixProcessInformation info; + simgrid::mc::ActorInformation info; info.address = p; info.hostname = nullptr; process->read_bytes(&info.copy, sizeof(info.copy), remote(p)); @@ -100,12 +96,9 @@ void Process::refresh_simix() Remote simix_global = this->read(simix_global_p); - MC_process_refresh_simix_process_list( - this, this->smx_process_infos, - remote(simix_global.getBuffer()->process_list)); - MC_process_refresh_simix_process_list( - this, this->smx_old_process_infos, - remote(simix_global.getBuffer()->process_to_destroy)); + MC_process_refresh_simix_process_list(this, this->smx_actors_infos, remote(simix_global.getBuffer()->process_list)); + MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos, + remote(simix_global.getBuffer()->process_to_destroy)); this->cache_flags_ |= Process::cache_simix_processes; } @@ -116,7 +109,7 @@ void Process::refresh_simix() /** Get the issuer of a simcall (`req->issuer`) * * In split-process mode, it does the black magic necessary to get an address - * of a (shallow) copy of the data structure the issuer SIMIX process in the local + * of a (shallow) copy of the data structure the issuer SIMIX actor in the local * address space. * * @param process the MCed process @@ -130,20 +123,20 @@ smx_actor_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req) auto address = simgrid::mc::remote(req->issuer); // Lookup by address: - for (auto& p : mc_model_checker->process().simix_processes()) - if (p.address == address) - return p.copy.getBuffer(); - for (auto& p : mc_model_checker->process().old_simix_processes()) - if (p.address == address) - return p.copy.getBuffer(); + for (auto& actor : mc_model_checker->process().actors()) + if (actor.address == address) + return actor.copy.getBuffer(); + for (auto& actor : mc_model_checker->process().dead_actors()) + if (actor.address == address) + return actor.copy.getBuffer(); xbt_die("Issuer not found"); } -const char* MC_smx_process_get_host_name(smx_actor_t p) +const char* MC_smx_actor_get_host_name(smx_actor_t actor) { if (mc_model_checker == nullptr) - return p->host->cname(); + return actor->host->cname(); simgrid::mc::Process* process = &mc_model_checker->process(); @@ -166,9 +159,8 @@ const char* MC_smx_process_get_host_name(smx_actor_t p) const size_t offset = (char*) &foo.host.name() - (char*) &foo.host; // Read the simgrid::xbt::string in the MCed process: - simgrid::mc::SimixProcessInformation* info = process_info_cast(p); - auto remote_string_address = remote( - (simgrid::xbt::string_data*) ((char*) p->host + offset)); + simgrid::mc::ActorInformation* info = actor_info_cast(actor); + auto remote_string_address = remote((simgrid::xbt::string_data*)((char*)actor->host + offset)); simgrid::xbt::string_data remote_string = process->read(remote_string_address); char hostname[remote_string.len]; process->read_bytes(hostname, remote_string.len + 1, remote(remote_string.data)); @@ -176,15 +168,15 @@ const char* MC_smx_process_get_host_name(smx_actor_t p) return info->hostname; } -const char* MC_smx_process_get_name(smx_actor_t p) +const char* MC_smx_actor_get_name(smx_actor_t actor) { simgrid::mc::Process* process = &mc_model_checker->process(); if (mc_model_checker == nullptr) - return p->name.c_str(); + return actor->name.c_str(); - simgrid::mc::SimixProcessInformation* info = process_info_cast(p); + simgrid::mc::ActorInformation* info = actor_info_cast(actor); if (info->name.empty()) { - simgrid::xbt::string_data string_data = (simgrid::xbt::string_data&)p->name; + simgrid::xbt::string_data string_data = (simgrid::xbt::string_data&)actor->name; info->name = process->read_string(remote(string_data.data), string_data.len); } return info->name.c_str(); diff --git a/src/mc/mc_smx.h b/src/mc/mc_smx.h index cf61c67eba..194cf88fc3 100644 --- a/src/mc/mc_smx.h +++ b/src/mc/mc_smx.h @@ -52,8 +52,8 @@ SG_BEGIN_DECL() */ XBT_PRIVATE smx_actor_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req); -XBT_PRIVATE const char* MC_smx_process_get_name(smx_actor_t p); -XBT_PRIVATE const char* MC_smx_process_get_host_name(smx_actor_t p); +XBT_PRIVATE const char* MC_smx_actor_get_name(smx_actor_t p); +XBT_PRIVATE const char* MC_smx_actor_get_host_name(smx_actor_t p); XBT_PRIVATE int MC_smpi_process_count(void); diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index 2946897035..3e211de54e 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -67,7 +67,7 @@ static inline smx_simcall_t MC_state_get_request_for_process( if (!procstate->isToInterleave()) return nullptr; - if (!simgrid::mc::process_is_enabled(process)) + if (!simgrid::mc::actor_is_enabled(process)) return nullptr; smx_simcall_t req = nullptr; @@ -215,7 +215,7 @@ static inline smx_simcall_t MC_state_get_request_for_process( smx_simcall_t MC_state_get_request(simgrid::mc::State* state) { - for (auto& p : mc_model_checker->process().simix_processes()) { + for (auto& p : mc_model_checker->process().actors()) { smx_simcall_t res = MC_state_get_request_for_process(state, p.copy.getBuffer()); if (res) return res; -- 2.20.1