Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplify the parameter passing while initializing the MC on the app side
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 9 Mar 2022 10:33:38 +0000 (11:33 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 9 Mar 2022 14:15:19 +0000 (15:15 +0100)
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp
src/mc/remote/AppSide.cpp
src/mc/remote/AppSide.hpp

index 3a942d4..686871d 100644 (file)
@@ -44,15 +44,6 @@ config::Flag<double> cfg_breakpoint{"debug/breakpoint",
                                     "When non-negative, raise a SIGTRAP after given (simulated) time", -1.0};
 config::Flag<bool> 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
-}
-
 constexpr std::initializer_list<std::pair<const char*, context::ContextFactoryInitializer>> context_factories = {
 #if HAVE_RAW_CONTEXTS
     {"raw", &context::raw_factory},
@@ -211,7 +202,7 @@ void EngineImpl::initialize(int* argc, char** argv)
   // The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
   // layers. But instance_ needs to be created, as we send the address of some of its fields to the MC that wants to
   // read them directly.
-  simgrid::mc::AppSide::initialize();
+  simgrid::mc::AppSide::initialize(actors_vector_);
 #endif
 
   if (xbt_initialized == 0) {
index e2a082c..d9e9197 100644 (file)
@@ -31,8 +31,6 @@
 
 namespace simgrid {
 namespace kernel {
-// In MC mode, the application sends these pointers to the MC
-xbt_dynar_t get_actors_addr();
 
 class EngineImpl {
   std::map<std::string, s4u::Host*, std::less<>> hosts_;
@@ -153,7 +151,6 @@ public:
   void add_split_duplex_link(const std::string& name, std::unique_ptr<resource::SplitDuplexLinkImpl> link);
 
 #if SIMGRID_HAVE_MC
-  xbt_dynar_t get_actors_vector() const { return actors_vector_; }
   void reset_actor_dynar() { xbt_dynar_reset(actors_vector_); }
   void add_actor_to_dynar(actor::ActorImpl* actor) { xbt_dynar_push_as(actors_vector_, actor::ActorImpl*, actor); }
 #endif
index b61d3fa..f477165 100644 (file)
@@ -35,7 +35,7 @@ namespace mc {
 
 std::unique_ptr<AppSide> AppSide::instance_;
 
-AppSide* AppSide::initialize()
+AppSide* AppSide::initialize(xbt_dynar_t actors_addr)
 {
   if (not std::getenv(MC_ENV_SOCKET_FD)) // We are not in MC mode: don't initialize the MC world
     return nullptr;
@@ -75,7 +75,7 @@ AppSide* AppSide::initialize()
              strerror(errno));
 
   s_mc_message_initial_addresses_t message{MessageType::INITIAL_ADDRESSES, mmalloc_preinit(),
-                                           kernel::actor::get_maxpid_addr(), kernel::get_actors_addr()};
+                                           kernel::actor::get_maxpid_addr(), actors_addr};
   xbt_assert(instance_->channel_.send(message) == 0, "Could not send the initial message with addresses.");
 
   instance_->handle_messages();
index 10088ea..beeb920 100644 (file)
@@ -50,7 +50,7 @@ public:
 
   // Singleton :/
   // TODO, remove the singleton antipattern.
-  static AppSide* initialize();
+  static AppSide* initialize(xbt_dynar_t actors_addr);
   static AppSide* get() { return instance_.get(); }
 };
 } // namespace mc