Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Objectif the disk model
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 15 Feb 2023 22:41:33 +0000 (23:41 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Wed, 15 Feb 2023 22:41:33 +0000 (23:41 +0100)
src/kernel/routing/NetZoneImpl.cpp
src/simgrid/module.cpp
src/simgrid/module.hpp
src/simgrid/sg_config.cpp
src/surf/disk_s19.cpp
src/surf/host_clm03.cpp
src/surf/ptask_L07.cpp
src/surf/surf_interface.hpp

index 01eb926..b255d1f 100644 (file)
@@ -42,7 +42,7 @@ static void surf_config_models_setup()
   XBT_DEBUG("host model: %s", host_model_name.c_str());
   if (host_model_name == "compound") {
     simgrid_cpu_models().by_name(cpu_model_name).init();
-    surf_disk_model_description.by_name(disk_model_name).init();
+    simgrid_disk_models().by_name(disk_model_name).init();
     simgrid_network_models().by_name(network_model_name).init();
   }
 
index bcad707..70b857f 100644 (file)
@@ -77,12 +77,9 @@ std::string ModuleGroup::existing_values() const
 
 /* -------------------------------------------------------------------------------------------------------------- */
 simgrid::ModuleGroup surf_optimization_mode_description("optimization mode");
-simgrid::ModuleGroup surf_disk_model_description("disk model");
 
 void simgrid_create_models()
 {
-  surf_disk_model_description.add("S19", "Simplistic disk model.", &surf_disk_model_init_S19);
-
   surf_optimization_mode_description
       .add("Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr)
       .add("TI",
index 3bd18c0..148daf1 100644 (file)
@@ -77,6 +77,18 @@ inline auto& simgrid_cpu_models() // Function to avoid static initialization ord
   return models;
 }
 
+#define SIMGRID_REGISTER_DISK_MODEL(id, desc, init)                                                                    \
+  static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _disk_model_register)()                           \
+  {                                                                                                                    \
+    simgrid_disk_models().add(_XBT_STRINGIFY(id), (desc), (init));                                                     \
+  }
+/** @brief The list of all available disk models (pick one with --cfg=disk/model) */
+inline auto& simgrid_disk_models() // Function to avoid static initialization order fiasco
+{
+  static simgrid::ModuleGroup models("disk model");
+  return models;
+}
+
 #define SIMGRID_REGISTER_HOST_MODEL(id, desc, init)                                                                    \
   static void XBT_ATTRIB_CONSTRUCTOR(800) _XBT_CONCAT3(simgrid_, id, _host_model_register)()                           \
   {                                                                                                                    \
@@ -89,4 +101,4 @@ inline auto& simgrid_host_models() // Function to avoid static initialization or
   return models;
 }
 
-#endif
\ No newline at end of file
+#endif
index 026fe6e..7c7c4ee 100644 (file)
@@ -133,18 +133,6 @@ static void _sg_cfg_cb__optimization_mode(const std::string& value)
   surf_optimization_mode_description.by_name(value);
 }
 
-static void _sg_cfg_cb__disk_model(const std::string& value)
-{
-  xbt_assert(_sg_cfg_init_status < 2, "Cannot change the model after the initialization");
-
-  if (value == "help") {
-    surf_disk_model_description.help();
-    exit(0);
-  }
-
-  surf_disk_model_description.by_name(value);
-}
-
 static void _sg_cfg_cb_contexts_parallel_mode(std::string_view mode_name)
 {
   if (mode_name == "posix") {
@@ -184,11 +172,9 @@ void sg_config_init(int *argc, char **argv)
   simgrid_cpu_models().create_flag("cpu/model", "The model to use for the CPU", "Cas01", false);
   simgrid_network_models().create_flag("network/model", "The model to use for the network", "LV08", false);
   simgrid_host_models().create_flag("host/model", "The model to use for the host", "default", false);
+  simgrid_disk_models().create_flag("disk/model", "The model to use for the disk", "S19", false);
   simgrid_create_models(); // KILL ME
 
-  declare_model_flag("disk/model", "S19", &_sg_cfg_cb__disk_model, surf_disk_model_description,
-                     "The model to use for the disk");
-
   declare_model_flag("network/optim", "Lazy", &_sg_cfg_cb__optimization_mode, surf_optimization_mode_description,
                      "The optimization modes to use for the network");
 
index 8fb36e6..35ad4fd 100644 (file)
@@ -26,13 +26,12 @@ static simgrid::config::Flag<std::string> cfg_disk_solver("disk/solver",
  * Model *
  *********/
 
-void surf_disk_model_init_S19()
-{
+SIMGRID_REGISTER_DISK_MODEL(S19, "Simplistic disk model.", []() {
   auto disk_model = std::make_shared<simgrid::kernel::resource::DiskS19Model>("Disk");
   auto* engine    = simgrid::kernel::EngineImpl::get_instance();
   engine->add_model(disk_model);
   engine->get_netzone_root()->set_disk_model(disk_model);
-}
+});
 
 namespace simgrid::kernel::resource {
 /*********
index 3328414..70ac155 100644 (file)
@@ -22,7 +22,7 @@ SIMGRID_REGISTER_HOST_MODEL(
       engine->add_model(host_model);
       engine->get_netzone_root()->set_host_model(host_model);
       simgrid_cpu_models().by_name("Cas01").init();
-      surf_disk_model_init_S19();
+      simgrid_disk_models().by_name("S19").init();
       simgrid_network_models().by_name("LV08").init();
     });
 
index b26e393..1b14d78 100644 (file)
@@ -58,7 +58,7 @@ HostL07Model::HostL07Model(const std::string& name, lmm::System* sys) : HostMode
   engine->add_model(cpu_model);
   engine->get_netzone_root()->set_cpu_pm_model(cpu_model);
 
-  surf_disk_model_init_S19();
+  simgrid_disk_models().by_name("S19").init();
 }
 
 CpuL07Model::CpuL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys)
index 391c10a..fc3a307 100644 (file)
@@ -63,8 +63,6 @@ static inline int double_equals(double value1, double value2, double precision)
   return (fabs(value1 - value2) < precision);
 }
 
-XBT_PUBLIC void surf_disk_model_init_S19();
-
 /** @ingroup SURF_models
  *  @brief Initializes the VM model used in the platform
  *
@@ -81,8 +79,6 @@ XBT_PUBLIC void surf_vm_model_init_HL13(simgrid::kernel::resource::CpuModel* cpu
 /** @brief The list of all available optimization modes (both for cpu and networks).
  *  These optimization modes can be set using --cfg=cpu/optim:... and --cfg=network/optim:... */
 XBT_PUBLIC_DATA simgrid::ModuleGroup surf_optimization_mode_description;
-/** @brief The list of all disk models (pick one with --cfg=disk/model) */
-XBT_PUBLIC_DATA simgrid::ModuleGroup surf_disk_model_description;
 
 void simgrid_create_models();