Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Say goodbye to last global: surf_host_model
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 4 Mar 2021 16:49:25 +0000 (17:49 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 9 Mar 2021 14:17:12 +0000 (15:17 +0100)
- By now, add the host_model in netZone too
- Probably need some check when running parallel_execute in a list of
hosts (all belongs to same model/netzone?)

doc/doxygen/module-surf.doc
include/simgrid/kernel/routing/NetZoneImpl.hpp
src/include/surf/surf.hpp
src/kernel/activity/ExecImpl.cpp
src/kernel/routing/NetZoneImpl.cpp
src/simdag/sd_task.cpp
src/surf/HostImpl.cpp
src/surf/HostImpl.hpp
src/surf/host_clm03.cpp
src/surf/ptask_L07.cpp

index 9dc285e..fdb4e47 100644 (file)
@@ -43,6 +43,7 @@
        - the CPU resource,
        - the timer resource.
 
+    FIXME[donassolo]: fix doc
     The implementation of these resources depends on the platform
     models you choose.  You can select your model by calling
     #surf_host_model_init_current_default() (which will give you a
index eed458f..ffbf67b 100644 (file)
@@ -74,6 +74,7 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
   resource::CpuModel* cpu_model_vm_;
   resource::CpuModel* cpu_model_pm_;
   resource::DiskModel* disk_model_;
+  simgrid::surf::HostModel* host_model_;
 
 protected:
   explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
@@ -113,6 +114,9 @@ public:
   resource::CpuModel* get_cpu_pm_model() const { return cpu_model_pm_; }
   /** @brief Retrieves the disk model associated to this NetZone */
   resource::DiskModel* get_disk_model() const { return disk_model_; }
+  /** @brief Retrieves the host model associated to this NetZone */
+  // FIXME[donassolo]: why HostModel isn't in resource namespace?
+  simgrid::surf::HostModel* get_host_model() const { return host_model_; }
 
   const s4u::NetZone* get_iface() const { return &piface_; }
   s4u::NetZone* get_iface() { return &piface_; }
index 9f55cd8..d5d1645 100644 (file)
@@ -8,15 +8,6 @@
 
 #include "simgrid/forward.h"
 
-/** @ingroup SURF_models
- *  @brief The host model
- *
- *  Note that when you create an API on top of SURF, the host model should be the only one you use
- *  because depending on the platform model, the network model and the CPU model may not exist.
- */
-XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
-
-
 /*** SURF Globals **************************/
 
 /** @ingroup SURF_simulation
index f306e90..40b9f95 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "src/kernel/activity/ExecImpl.hpp"
 #include "simgrid/Exception.hpp"
+#include "simgrid/kernel/routing/NetPoint.hpp"
 #include "simgrid/modelchecker.h"
 #include "simgrid/s4u/Exec.hpp"
 #include "src/mc/mc_replay.hpp"
@@ -120,7 +121,9 @@ ExecImpl* ExecImpl::start()
         surf_action_->set_user_bound(bound_);
       }
     } else {
-      surf_action_ = surf_host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1);
+      // FIXME[donassolo]: verify if all hosts belongs to the same netZone?
+      auto host_model = hosts_.front()->get_netpoint()->get_englobing_zone()->get_host_model();
+      surf_action_    = host_model->execute_parallel(hosts_, flops_amounts_.data(), bytes_amounts_.data(), -1);
     }
     surf_action_->set_activity(this);
   }
index b9046be..11f4c0d 100644 (file)
@@ -8,6 +8,7 @@
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/kernel/resource/DiskImpl.hpp"
+#include "src/surf/HostImpl.hpp"
 #include "src/surf/cpu_interface.hpp"
 #include "src/surf/network_interface.hpp"
 #include "src/surf/xml/platf_private.hpp"
@@ -34,6 +35,9 @@ NetZoneImpl::NetZoneImpl(NetZoneImpl* father, const std::string& name, resource:
       models_by_type[simgrid::kernel::resource::Model::Type::CPU_PM][0]);
   disk_model_ = static_cast<simgrid::kernel::resource::DiskModel*>(
       models_by_type[simgrid::kernel::resource::Model::Type::DISK][0]);
+  // FIXME[donassolo]: we probably need some validation of the coherence among
+  // the different models in each netZone
+  host_model_ = static_cast<simgrid::surf::HostModel*>(models_by_type[simgrid::kernel::resource::Model::Type::HOST][0]);
   XBT_DEBUG("NetZone '%s' created with the id '%u'", get_cname(), netpoint_->id());
 }
 
index 89b78db..1c78fa2 100644 (file)
@@ -5,6 +5,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "simdag_private.hpp"
+#include "simgrid/kernel/routing/NetPoint.hpp"
 #include "src/surf/HostImpl.hpp"
 #include "src/surf/surf_interface.hpp"
 #include <algorithm>
@@ -801,8 +802,10 @@ void SD_task_run(SD_task_t task)
   XBT_VERB("Executing task '%s'", task->name);
 
   /* Beware! The scheduling data are now used by the surf action directly! no copy was done */
+  // FIXME[donassolo]: verify if all hosts belongs to the same netZone?
+  auto host_model = (*task->allocation).front()->get_netpoint()->get_englobing_zone()->get_host_model();
   task->surf_action =
-      surf_host_model->execute_parallel(*task->allocation, task->flops_amount, task->bytes_amount, task->rate);
+      host_model->execute_parallel(*task->allocation, task->flops_amount, task->bytes_amount, task->rate);
 
   task->surf_action->set_data(task);
 
index fc80431..d6547d5 100644 (file)
@@ -10,8 +10,6 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(res_host, ker_resource, "Host resources agregate CPU, networking and I/O features");
 
-simgrid::surf::HostModel *surf_host_model = nullptr;
-
 /*************
  * Callbacks *t
  *************/
index dfe6045..b7e70d6 100644 (file)
@@ -81,6 +81,4 @@ public:
 }
 }
 
-XBT_PUBLIC_DATA simgrid::surf::HostModel* surf_host_model;
-
 #endif /* SURF_HOST_INTERFACE_HPP */
index e22365b..db3a995 100644 (file)
@@ -12,7 +12,10 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_host);
 
 void surf_host_model_init_current_default()
 {
-  surf_host_model = new simgrid::surf::HostCLM03Model();
+  /* FIXME[donassolo]: this smells bad, but works
+   * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+   * We need a manager for these models */
+  new simgrid::surf::HostCLM03Model();
   simgrid::config::set_default<bool>("network/crosstraffic", true);
   surf_cpu_model_init_Cas01();
   surf_network_model_init_LegrandVelho();
index 6961a27..570e3aa 100644 (file)
@@ -20,9 +20,9 @@ void surf_host_model_init_ptask_L07()
 {
   XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks.");
 
-  surf_host_model = new simgrid::surf::HostL07Model();
-  all_existing_models.push_back(surf_host_model);
-  models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(surf_host_model);
+  auto host_model = new simgrid::surf::HostL07Model();
+  all_existing_models.push_back(host_model);
+  models_by_type[simgrid::kernel::resource::Model::Type::HOST].push_back(host_model);
 }
 
 namespace simgrid {