Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
more chaining for CPUs too
authorSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 25 Mar 2021 09:48:51 +0000 (10:48 +0100)
committerSUTER Frederic <frederic.suter@cc.in2p3.fr>
Thu, 25 Mar 2021 10:16:46 +0000 (11:16 +0100)
include/simgrid/s4u/Host.hpp
src/s4u/s4u_Host.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/sg_platf.cpp
teshsuite/s4u/storage_client_server/storage_client_server.tesh

index 9d658f6..f4a1174 100644 (file)
@@ -104,8 +104,8 @@ public:
   const std::unordered_map<std::string, std::string>* get_properties() const;
   Host* set_properties(const std::unordered_map<std::string, std::string>& properties);
 
-  void set_state_profile(kernel::profile::Profile* p);
-  void set_speed_profile(kernel::profile::Profile* p);
+  Host* set_state_profile(kernel::profile::Profile* p);
+  Host* set_speed_profile(kernel::profile::Profile* p);
 
   /** @brief Get the peak computing speed in flops/s at the current pstate, NOT taking the external load into account.
    *
@@ -140,10 +140,10 @@ public:
    */
   double get_load() const;
 
-  double get_pstate_speed(int pstate_index) const;
   int get_pstate_count() const;
-  void set_pstate(int pstate_index);
   int get_pstate() const;
+  double get_pstate_speed(int pstate_index) const;
+  Host* set_pstate(int pstate_index);
 
   std::vector<Disk*> get_disks() const;
   Disk* create_disk(const std::string& name, double read_bandwidth, double write_bandwidth);
index 47feede..ab974c3 100644 (file)
@@ -217,9 +217,10 @@ Host* Host::set_properties(const std::unordered_map<std::string, std::string>& p
 
 /** Specify a profile turning the host on and off according to an exhaustive list or a stochastic law.
  * The profile must contain boolean values. */
-void Host::set_state_profile(kernel::profile::Profile* p)
+Host* Host::set_state_profile(kernel::profile::Profile* p)
 {
-  return kernel::actor::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+  kernel::actor::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+  return this;
 }
 /** Specify a profile modeling the external load according to an exhaustive list or a stochastic law.
  *
@@ -227,9 +228,10 @@ void Host::set_state_profile(kernel::profile::Profile* p)
  * of the initial value. This means that the actual value is obtained by multiplying the initial value (the peek speed
  * at this pstate level) by the rate coming from the profile.
  */
-void Host::set_speed_profile(kernel::profile::Profile* p)
+Host* Host::set_speed_profile(kernel::profile::Profile* p)
 {
-  return kernel::actor::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+  kernel::actor::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+  return this;
 }
 
 /** @brief Get the peak processor speed (in flops/s), at the specified pstate  */
@@ -258,15 +260,17 @@ int Host::get_core_count() const
 
 Host* Host::set_core_count(int core_count)
 {
-  this->pimpl_cpu->set_core_count(core_count);
+  kernel::actor::simcall([this, core_count] { this->pimpl_cpu->set_core_count(core_count); });
   return this;
 }
 
 /** @brief Set the pstate at which the host should run */
-void Host::set_pstate(int pstate_index)
+Host* Host::set_pstate(int pstate_index)
 {
   kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu->set_pstate(pstate_index); });
+  return this;
 }
+
 /** @brief Retrieve the pstate at which the host is currently running */
 int Host::get_pstate() const
 {
@@ -275,7 +279,7 @@ int Host::get_pstate() const
 
 std::vector<Disk*> Host::get_disks() const
 {
-  return kernel::actor::simcall([this] { return this->pimpl_->get_disks(); });
+  return this->pimpl_->get_disks();
 }
 
 Disk* Host::create_disk(const std::string& name, double read_bandwidth, double write_bandwidth)
index b07f84f..33d23eb 100644 (file)
@@ -65,7 +65,7 @@ void Cpu::reset_vcpu(Cpu* that)
   this->speed_per_pstate_.assign(that->speed_per_pstate_.begin(), that->speed_per_pstate_.end());
 }
 
-void Cpu::set_pstate(int pstate_index)
+Cpu* Cpu::set_pstate(int pstate_index)
 {
   xbt_assert(pstate_index <= static_cast<int>(speed_per_pstate_.size()),
              "Invalid parameters for CPU %s (pstate %d > length of pstates %d). Please fix your platform file, or your "
@@ -77,6 +77,7 @@ void Cpu::set_pstate(int pstate_index)
   speed_.peak = new_peak_speed;
 
   on_speed_change();
+  return this;
 }
 
 double Cpu::get_pstate_peak_speed(int pstate_index) const
@@ -108,11 +109,13 @@ int Cpu::get_core_count()
   return core_count_;
 }
 
-void Cpu::set_speed_profile(kernel::profile::Profile* profile)
+Cpu* Cpu::set_speed_profile(kernel::profile::Profile* profile)
 {
-  xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", piface_->get_cname());
-
-  speed_.event = profile->schedule(&profile::future_evt_set, this);
+  if (profile) {
+    xbt_assert(speed_.event == nullptr, "Cannot set a second speed trace to Host %s", piface_->get_cname());
+    speed_.event = profile->schedule(&profile::future_evt_set, this);
+  }
+  return this;
 }
 
 void Cpu::seal()
index f96a75d..5ff2d29 100644 (file)
@@ -97,13 +97,13 @@ public:
 
   virtual int get_pstate_count() const { return speed_per_pstate_.size(); }
 
-  virtual void set_pstate(int pstate_index);
   virtual int get_pstate() const { return pstate_; }
+  virtual Cpu* set_pstate(int pstate_index);
 
-  /*< @brief Setup the trace file with availability events (peak speed changes due to external load).
-   * Trace must contain relative values (ratio between 0 and 1)
+  /*< @brief Setup the profile file with availability events (peak speed changes due to external load).
+   * Profile must contain relative values (ratio between 0 and 1)
    */
-  virtual void set_speed_profile(profile::Profile* profile);
+  virtual Cpu* set_speed_profile(profile::Profile* profile);
 
   /**
    * @brief Execute some quantity of computation
index f030e46..df5dd66 100644 (file)
@@ -328,7 +328,7 @@ CpuTi::~CpuTi()
   delete speed_integrated_trace_;
 }
 
-void CpuTi::set_speed_profile(kernel::profile::Profile* profile)
+Cpu* CpuTi::set_speed_profile(kernel::profile::Profile* profile)
 {
   delete speed_integrated_trace_;
   speed_integrated_trace_ = new CpuTiTmgr(profile, speed_.scale);
@@ -341,6 +341,7 @@ void CpuTi::set_speed_profile(kernel::profile::Profile* profile)
       speed_.event = prof->schedule(&profile::future_evt_set, this);
     }
   }
+  return this;
 }
 
 void CpuTi::apply_event(kernel::profile::Event* event, double value)
index 7ee7930..6997bfe 100644 (file)
@@ -105,7 +105,7 @@ public:
   CpuTi& operator&(const CpuTi&) = delete;
   ~CpuTi() override;
 
-  void set_speed_profile(profile::Profile* profile) override;
+  Cpu* set_speed_profile(profile::Profile* profile) override;
 
   void apply_event(profile::Event* event, double value) override;
   void update_actions_finish_time(double now);
index b1700c3..2c22bfb 100644 (file)
@@ -77,10 +77,8 @@ void sg_platf_new_host(const simgrid::kernel::routing::HostCreationArgs* args)
   host->pimpl_->set_disks(args->disks, host);
 
   /* Change from the defaults */
-  if (args->state_trace)
-    host->set_state_profile(args->state_trace);
-  if (args->speed_trace)
-    host->set_speed_profile(args->speed_trace);
+  host->set_state_profile(args->state_trace)->set_speed_profile(args->speed_trace);
+
   if (not args->coord.empty())
     new simgrid::kernel::routing::vivaldi::Coords(host->get_netpoint(), args->coord);
 
index a103fbb..f724c4d 100644 (file)
@@ -88,10 +88,10 @@ $ ./storage_client_server ${platfdir}/hosts_with_disks.xml "--log=root.fmt:[%10.
 > [  1.207952] (server@alice)   /tmp/tata.c size: 6217 bytes
 > [  1.207952] (server@alice)   /tmp/titi.xml size: 654 bytes
 > [  1.207952] (server@alice)   /tmp/toto.xml size: 972 bytes
+> [  1.207952] (server@alice) Disk1 is attached to alice
 > [  1.207952] (client@bob) *** GET/SET DATA for disk: Disk1 ***
 > [  1.207952] (client@bob) Get data: 'No User Data'
 > [  1.207952] (client@bob)   Set and get data: 'Some data'
-> [  1.207952] (server@alice) Disk1 is attached to alice
 > [  1.207952] (server@alice) Disk1 is attached to bob
 > [  1.207952] (server@alice) Disk2 is attached to bob
 > [  1.207952] (maestro@) Simulated time: 1.20795