From: Gabriel Corona Date: Fri, 8 Apr 2016 12:08:38 +0000 (+0200) Subject: [mc] Move resolve_process...() as methods of Process X-Git-Tag: v3_13~116 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/4172b209dead18c578e5c1b2e93d27e6af8ac3b4 [mc] Move resolve_process...() as methods of Process --- diff --git a/src/mc/CommunicationDeterminismChecker.cpp b/src/mc/CommunicationDeterminismChecker.cpp index a5ddbc2cc0..7104f80a12 100644 --- a/src/mc/CommunicationDeterminismChecker.cpp +++ b/src/mc/CommunicationDeterminismChecker.cpp @@ -96,8 +96,10 @@ static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern, s_smx_synchro_t comm; mc_model_checker->process().read(&comm, remote(comm_addr)); - smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(comm.comm.src_proc)); - smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(comm.comm.dst_proc)); + smx_process_t src_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(comm.comm.src_proc)); + smx_process_t dst_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(comm.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); @@ -189,7 +191,8 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type char* remote_name = mc_model_checker->process().read( (std::uint64_t)(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name)); pattern->rdv = mc_model_checker->process().read_string(remote_name); - pattern->src_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.src_proc))->pid; + pattern->src_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(synchro.comm.src_proc))->pid; pattern->src_host = MC_smx_process_get_host_name(issuer); struct s_smpi_mpi_request mpi_request = @@ -235,7 +238,8 @@ void MC_get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type mc_model_checker->process().read(&remote_name, remote(synchro.comm.rdv ? &synchro.comm.rdv->name : &synchro.comm.rdv_cpy->name)); pattern->rdv = mc_model_checker->process().read_string(remote_name); - pattern->dst_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.dst_proc))->pid; + pattern->dst_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(synchro.comm.dst_proc))->pid; pattern->dst_host = MC_smx_process_get_host_name(issuer); } else xbt_die("Unexpected call_type %i", (int) call_type); diff --git a/src/mc/Process.hpp b/src/mc/Process.hpp index 000da2b483..7f4127e5c1 100644 --- a/src/mc/Process.hpp +++ b/src/mc/Process.hpp @@ -76,8 +76,8 @@ struct IgnoredHeapRegion { /** Representation of a process * - * This class is mixing a lot of differents responsabilities and is tied - * to SIMIX. It should probably split into different classes. + * This class is mixing a lot of different responsabilities and is tied + * to SIMIX. It should probably be split into different classes. * * Responsabilities: * @@ -218,6 +218,34 @@ public: std::vector& simix_processes(); std::vector& old_simix_processes(); + /** Get a local description of a remote SIMIX process */ + simgrid::mc::SimixProcessInformation* resolveProcessInfo( + simgrid::mc::RemotePtr process) + { + xbt_assert(mc_mode == MC_MODE_SERVER); + if (!process) + 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; + return nullptr; + } + + /** Get a local copy of the SIMIX process structure */ + smx_process_t resolveProcess(simgrid::mc::RemotePtr process) + { + simgrid::mc::SimixProcessInformation* process_info = + this->resolveProcessInfo(process); + if (process_info) + return &process_info->copy; + else + return nullptr; + } + void dumpStack(); private: diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index 4dcc139da8..42906fe22b 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -157,10 +157,12 @@ bool request_is_enabled(smx_simcall_t req) if(mutex->owner == nullptr) return true; #if HAVE_MC - else if (mc_mode == MC_MODE_SERVER) + else if (mc_mode == MC_MODE_SERVER) { + simgrid::mc::Process& modelchecked = mc_model_checker->process(); // TODO, *(mutex->owner) :/ - return MC_smx_resolve_process(simgrid::mc::remote(mutex->owner))->pid == - MC_smx_resolve_process(simgrid::mc::remote(req->issuer))->pid; + return modelchecked.resolveProcess(simgrid::mc::remote(mutex->owner))->pid + == modelchecked.resolveProcess(simgrid::mc::remote(req->issuer))->pid; + } #endif else return mutex->owner->pid == req->issuer->pid; diff --git a/src/mc/mc_request.cpp b/src/mc/mc_request.cpp index 5d6656fd91..fe69f83243 100644 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@ -292,8 +292,10 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid } else act = remote_act; - smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.src_proc)); - smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.dst_proc)); + smx_process_t src_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(act->comm.src_proc)); + smx_process_t dst_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(act->comm.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) : "", @@ -326,8 +328,10 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid type = "Test TRUE"; p = pointer_to_string(remote_act); - smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.src_proc)); - smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(act->comm.dst_proc)); + smx_process_t src_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(act->comm.src_proc)); + smx_process_t dst_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(act->comm.dst_proc)); args = bprintf("comm=%s [(%lu)%s (%s) -> (%lu)%s (%s)]", p, src_proc->pid, MC_smx_process_get_name(src_proc), @@ -392,7 +396,8 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid args = bprintf("locked = %d, owner = %d, sleeping = %d", mutex.locked, - mutex.owner != nullptr ? (int) MC_smx_resolve_process(simgrid::mc::remote(mutex.owner))->pid : -1, + mutex.owner != nullptr ? (int) mc_model_checker->process().resolveProcess( + simgrid::mc::remote(mutex.owner))->pid : -1, mutex_sleeping.count); break; } @@ -522,8 +527,10 @@ std::string request_get_dot_output(smx_simcall_t req, int value) mc_model_checker->process().read_bytes(&synchro, sizeof(synchro), remote(remote_act)); - smx_process_t src_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.src_proc)); - smx_process_t dst_proc = MC_smx_resolve_process(simgrid::mc::remote(synchro.comm.dst_proc)); + smx_process_t src_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(synchro.comm.src_proc)); + smx_process_t dst_proc = mc_model_checker->process().resolveProcess( + simgrid::mc::remote(synchro.comm.dst_proc)); if (issuer->host) label = simgrid::xbt::string_printf("[(%lu)%s] Wait [(%lu)->(%lu)]", issuer->pid, diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 9487799fe1..604cdc36e9 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -129,36 +129,6 @@ smx_process_t MC_smx_simcall_get_issuer(s_smx_simcall_t const* req) xbt_die("Issuer not found"); } -smx_process_t MC_smx_resolve_process( - simgrid::mc::RemotePtr process_remote_address) -{ - xbt_assert(mc_mode == MC_MODE_SERVER); - - if (!process_remote_address) - return nullptr; - - simgrid::mc::SimixProcessInformation* process_info = - MC_smx_resolve_process_info(process_remote_address); - if (process_info) - return &process_info->copy; - else - return nullptr; -} - -simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info( - simgrid::mc::RemotePtr process_remote_address) -{ - xbt_assert(mc_mode == MC_MODE_SERVER); - - for (auto& process_info : mc_model_checker->process().smx_process_infos) - if (process_info.address == process_remote_address) - return &process_info; - for (auto& process_info : mc_model_checker->process().smx_old_process_infos) - if (process_info.address == process_remote_address) - return &process_info; - xbt_die("Process info not found"); -} - const char* MC_smx_process_get_host_name(smx_process_t p) { if (mc_mode == MC_MODE_CLIENT) diff --git a/src/mc/mc_smx.h b/src/mc/mc_smx.h index 4582e850ad..70f9968bea 100644 --- a/src/mc/mc_smx.h +++ b/src/mc/mc_smx.h @@ -57,17 +57,6 @@ XBT_PRIVATE const char* MC_smx_process_get_host_name(smx_process_t p); XBT_PRIVATE int MC_smpi_process_count(void); - -/* ***** Resolve (local/MCer structure from remote/MCed addresses) ***** */ - -/** Get a local copy of the process from the process remote address */ -XBT_PRIVATE smx_process_t MC_smx_resolve_process( - simgrid::mc::RemotePtr process_remote_address); - -/** Get the process info structure from the process remote address */ -XBT_PRIVATE simgrid::mc::SimixProcessInformation* MC_smx_resolve_process_info( - simgrid::mc::RemotePtr process_remote_address); - XBT_PRIVATE unsigned long MC_smx_get_maxpid(void); SG_END_DECL()