From 699832c68841db0dcf4e615e22cfdea90d4ccb1b Mon Sep 17 00:00:00 2001 From: SUTER Frederic Date: Tue, 21 Sep 2021 13:13:17 +0200 Subject: [PATCH] move MC stuff from simix_global to EngineImpl --- include/simgrid/simix.hpp | 7 +------ src/kernel/EngineImpl.cpp | 19 +++++++++++++++++++ src/kernel/EngineImpl.hpp | 3 +++ src/mc/remote/AppSide.cpp | 4 ++-- src/simix/smx_global.cpp | 24 ------------------------ 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/include/simgrid/simix.hpp b/include/simgrid/simix.hpp index 1acd620f51..49e2d4a94e 100644 --- a/include/simgrid/simix.hpp +++ b/include/simgrid/simix.hpp @@ -93,16 +93,11 @@ auto simcall_blocking(F&& code, Observer* observer) -> decltype(observer->get_re } } // namespace actor } // namespace kernel -} // namespace simgrid -namespace simgrid { + namespace simix { XBT_PUBLIC void unblock(smx_actor_t process); -// In MC mode, the application sends these pointers to the MC -xbt_dynar_t simix_global_get_actors_addr(); -xbt_dynar_t simix_global_get_dead_actors_addr(); - } // namespace simix } // namespace simgrid diff --git a/src/kernel/EngineImpl.cpp b/src/kernel/EngineImpl.cpp index 3b08ef3d17..79c89e07c1 100644 --- a/src/kernel/EngineImpl.cpp +++ b/src/kernel/EngineImpl.cpp @@ -38,6 +38,25 @@ EngineImpl* EngineImpl::instance_ = nullptr; /* That singleton is awful too. */ config::Flag cfg_breakpoint{"debug/breakpoint", "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0}; config::Flag cfg_verbose_exit{"debug/verbose-exit", "Display the actor status at exit", true}; + +xbt_dynar_t get_actors_addr() +{ +#if SIMGRID_HAVE_MC + return EngineImpl::get_instance()->get_actors_vector(); +#else + xbt_die("This function is intended to be used when compiling with MC"); +#endif +} + +xbt_dynar_t get_dead_actors_addr() +{ +#if SIMGRID_HAVE_MC + return EngineImpl::get_instance()->get_dead_actors_vector(); +#else + xbt_die("This function is intended to be used when compiling with MC"); +#endif +} + } // namespace kernel } // namespace simgrid diff --git a/src/kernel/EngineImpl.hpp b/src/kernel/EngineImpl.hpp index 63d2c444b9..fc9b8c1ab5 100644 --- a/src/kernel/EngineImpl.hpp +++ b/src/kernel/EngineImpl.hpp @@ -31,6 +31,9 @@ namespace simgrid { namespace kernel { +// In MC mode, the application sends these pointers to the MC +xbt_dynar_t get_actors_addr(); +xbt_dynar_t get_dead_actors_addr(); class EngineImpl { std::map> hosts_; diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index 2938475731..00f64531de 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -74,8 +74,8 @@ AppSide* AppSide::initialize() strerror(errno)); s_mc_message_initial_addresses_t message{MessageType::INITIAL_ADDRESSES, mmalloc_preinit(), - kernel::actor::get_maxpid_addr(), simix::simix_global_get_actors_addr(), - simix::simix_global_get_dead_actors_addr()}; + kernel::actor::get_maxpid_addr(), kernel::get_actors_addr(), + kernel::get_dead_actors_addr()}; xbt_assert(instance_->channel_.send(message) == 0, "Could not send the initial message with addresses."); instance_->handle_messages(); diff --git a/src/simix/smx_global.cpp b/src/simix/smx_global.cpp index ab5a52f15f..2c158ce440 100644 --- a/src/simix/smx_global.cpp +++ b/src/simix/smx_global.cpp @@ -3,36 +3,12 @@ /* 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 "mc/mc.h" #include "simgrid/s4u/Engine.hpp" #include "src/kernel/EngineImpl.hpp" XBT_LOG_NEW_CATEGORY(simix, "All SIMIX categories"); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_kernel, simix, "Logging specific to SIMIX (kernel)"); -namespace simgrid { -namespace simix { - -xbt_dynar_t simix_global_get_actors_addr() -{ -#if SIMGRID_HAVE_MC - return kernel::EngineImpl::get_instance()->get_actors_vector(); -#else - xbt_die("This function is intended to be used when compiling with MC"); -#endif -} -xbt_dynar_t simix_global_get_dead_actors_addr() -{ -#if SIMGRID_HAVE_MC - return kernel::EngineImpl::get_instance()->get_dead_actors_vector(); -#else - xbt_die("This function is intended to be used when compiling with MC"); -#endif -} - -} // namespace simix -} // namespace simgrid - /** * @ingroup SIMIX_API * @brief A clock (in second). -- 2.20.1