From 1c9d1059a9299bcfe07778802cf1d9da64016838 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 5 Dec 2017 14:42:16 +0100 Subject: [PATCH] MC: maintain a copy of simix_global->process_to_destroy in a dynar. --- src/mc/mc_smx.cpp | 38 ++++++-------------------------------- src/simix/ActorImpl.cpp | 10 +++++++++- src/simix/smx_global.cpp | 1 + src/simix/smx_private.hpp | 8 +++++--- 4 files changed, 21 insertions(+), 36 deletions(-) diff --git a/src/mc/mc_smx.cpp b/src/mc/mc_smx.cpp index 8be69df80c..bcdec8bd9b 100644 --- a/src/mc/mc_smx.cpp +++ b/src/mc/mc_smx.cpp @@ -25,38 +25,12 @@ static inline simgrid::mc::ActorInformation* actor_info_cast(smx_actor_t actor) return process_info; } -/** Load the remote swag of processes into a vector +/** Load the remote list of processes into a vector * - * @param process MCed process - * @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 + * @param process MCed process + * @param target Local vector (to be filled with copies of `s_smx_actor_t`) + * @param remote_dynar Address of the process dynar in the remote list */ -static void MC_process_refresh_simix_process_list(simgrid::mc::RemoteClient* process, - std::vector& target, - simgrid::mc::RemotePtr remote_swag) -{ - target.clear(); - - // swag = REMOTE(*simix_global->process_list) - s_xbt_swag_t swag; - process->read_bytes(&swag, sizeof(swag), remote_swag); - - // Load each element of the vector from the MCed process: - int i = 0; - for (smx_actor_t p = (smx_actor_t) swag.head; p; ++i) { - - simgrid::mc::ActorInformation info; - info.address = p; - info.hostname = nullptr; - process->read_bytes(&info.copy, sizeof(info.copy), remote(p)); - target.push_back(std::move(info)); - - // Lookup next process address: - p = (smx_actor_t) xbt_swag_getNext(&info.copy, swag.offset); - } - assert(i == swag.count); -} - static void MC_process_refresh_simix_actor_dynar(simgrid::mc::RemoteClient* process, std::vector& target, simgrid::mc::RemotePtr remote_dynar) @@ -105,8 +79,8 @@ void RemoteClient::refresh_simix() this->read(simix_global_p); MC_process_refresh_simix_actor_dynar(this, this->smx_actors_infos, remote(simix_global.getBuffer()->actors_vector)); - MC_process_refresh_simix_process_list(this, this->smx_dead_actors_infos, - remote(simix_global.getBuffer()->process_to_destroy)); + MC_process_refresh_simix_actor_dynar(this, this->smx_dead_actors_infos, + remote(simix_global.getBuffer()->dead_actors_vector)); this->cache_flags_ |= RemoteClient::cache_simix_processes; } diff --git a/src/simix/ActorImpl.cpp b/src/simix/ActorImpl.cpp index 2295dd34d2..1491a9e4c6 100644 --- a/src/simix/ActorImpl.cpp +++ b/src/simix/ActorImpl.cpp @@ -115,7 +115,12 @@ void SIMIX_process_cleanup(smx_actor_t process) simix_global->process_list.erase(process->pid); if (process->host && process->host_process_list_hook.is_linked()) simgrid::xbt::intrusive_erase(process->host->extension()->process_list, *process); - xbt_swag_insert(process, simix_global->process_to_destroy); + if (not xbt_swag_belongs(process, simix_global->process_to_destroy)) { +#if SIMGRID_HAVE_MC + xbt_dynar_push_as(simix_global->dead_actors_vector, smx_actor_t, process); +#endif + xbt_swag_insert(process, simix_global->process_to_destroy); + } process->context->iwannadie = 0; xbt_os_mutex_release(simix_global->mutex); @@ -135,6 +140,9 @@ void SIMIX_process_empty_trash() intrusive_ptr_release(process); process = static_cast(xbt_swag_extract(simix_global->process_to_destroy)); } +#if SIMGRID_HAVE_MC + xbt_dynar_reset(simix_global->dead_actors_vector); +#endif } namespace simgrid { diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index ad2d351fa1..8ba76bd5dc 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -308,6 +308,7 @@ void SIMIX_clean() simix_global->mutex = nullptr; #if SIMGRID_HAVE_MC xbt_dynar_free(&simix_global->actors_vector); + xbt_dynar_free(&simix_global->dead_actors_vector); #endif /* Let's free maestro now */ diff --git a/src/simix/smx_private.hpp b/src/simix/smx_private.hpp index 1a2ba34e78..55664e28cf 100644 --- a/src/simix/smx_private.hpp +++ b/src/simix/smx_private.hpp @@ -26,17 +26,19 @@ public: std::vector process_to_run; std::vector process_that_ran; std::map process_list; + xbt_swag_t process_to_destroy = nullptr; #if SIMGRID_HAVE_MC - /* MCer cannot read the std::map above in the remote process, so we copy the info it needs in a dynar. + /* MCer cannot read members process_list and process_to_destroy above in the remote process, so we copy the info it + * needs in a dynar. * FIXME: This is supposed to be a temporary hack. * A better solution would be to change the split between MCer and MCed, where the responsibility * to compute the list of the enabled transitions goes to the MCed. * That way, the MCer would not need to have the list of actors on its side. * These info could be published by the MCed to the MCer in a way inspired of vd.so */ - xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr); + xbt_dynar_t actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr); + xbt_dynar_t dead_actors_vector = xbt_dynar_new(sizeof(smx_actor_t), nullptr); #endif - xbt_swag_t process_to_destroy = nullptr; smx_actor_t maestro_process = nullptr; // Maps function names to actor code: -- 2.20.1