Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
allow to set a profile to links and hosts from S4U
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 8 Feb 2019 09:33:29 +0000 (10:33 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Fri, 8 Feb 2019 09:33:29 +0000 (10:33 +0100)
docs/source/platform_howtos.rst
include/simgrid/s4u/Host.hpp
include/simgrid/s4u/Link.hpp
src/s4u/s4u_Host.cpp

index e96ffd0..5c68aca 100644 (file)
@@ -60,8 +60,8 @@ freely available, though.
 
 .. _howto_churn:
 
-Modeling Churn in P2P
-*********************
+Modeling Churn (e.g. in P2P)
+****************************
 
 One of the biggest challenges in P2P settings is to cope with the
 churn, meaning that resources keep appearing and disappearing. In
@@ -70,12 +70,10 @@ eg :cpp:func:`simgrid::s4u::Host::turn_on`. To reduce the burden when
 the churn is high, you can also attach a **state profile** to the host
 directly.
 
-This is not possible from S4U yet (TODO), and you should use the
-``state_file`` attribute of :ref:`pf_tag_host`, :ref:`pf_tag_cluster`
-or :ref:`pf_tag_link`.
-
-Every lines (but the last) of such files describe timed events with
-the form "date value". Example:
+This can be done through the XML file, using the ``state_file``
+attribute of :ref:`pf_tag_host`, :ref:`pf_tag_cluster` or
+:ref:`pf_tag_link`. Every lines (but the last) of such files describe
+timed events with the form "date value". Example:
 
 .. code-block:: python
                
@@ -91,6 +89,12 @@ the form "date value". Example:
 If your trace does not contain a LOOPAFTER line, then your profile is
 only executed once and not repetitively.
 
+Another possibility is to use the
+:cpp:func:`simgrid::s4u::Host::set_state_profile()` or 
+:cpp:func:`simgrid::s4u::Link::set_state_profile()` functions. These
+functions take a profile, that can be an fixed profile exhaustively
+listing the events, or something else if you wish.
+
 .. _howto_multicore:
 
 Modeling Multicore Machines
index b3736c6..45bfeb1 100644 (file)
@@ -101,6 +101,9 @@ public:
   void set_property(std::string key, std::string value);
   std::unordered_map<std::string, std::string>* get_properties();
 
+  void set_state_profile(kernel::profile::Profile* p);
+  void set_speed_profile(kernel::profile::Profile* p);
+
 #ifndef DOXYGEN
   /** @deprecated See Host::get_properties() */
   XBT_ATTRIB_DEPRECATED_v323("Please use Host::get_properties()") std::map<std::string, std::string>* getProperties()
index 735321a..04100c1 100644 (file)
@@ -83,9 +83,9 @@ public:
   }
 #endif
 
-  /** Setup the profile file with states events (ON or OFF). The profile must contain boolean values. */
+  /** Setup the profile with states events (ON or OFF). The profile must contain boolean values. */
   void set_state_profile(kernel::profile::Profile* profile);
-  /** Setup the profile file with bandwidth events (peak speed changes due to external load).
+  /** Setup the profile with bandwidth events (peak speed changes due to external load).
    * The profile must contain percentages (value between 0 and 1). */
   void set_bandwidth_profile(kernel::profile::Profile* profile);
   /** Setup the profile file with latency events (peak latency changes due to external load).
index 8000060..a308673 100644 (file)
@@ -196,6 +196,22 @@ void Host::set_property(std::string key, std::string value)
 {
   simgrid::simix::simcall([this, key, value] { this->pimpl_->set_property(key, value); });
 }
+/** Specify a profile turning the host on and off according to a exhaustive list or a stochastic law.
+ * The profile must contain boolean values. */
+void Host::set_state_profile(kernel::profile::Profile* p)
+{
+  return simgrid::simix::simcall([this, p] { pimpl_cpu->set_state_profile(p); });
+}
+/** Specify a profile modeling the external load according to a exhaustive list or a stochastic law.
+ *
+ * Each event of the profile represent a peak speed change that is due to external load. The values are given as a rate
+ * 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)
+{
+  return simgrid::simix::simcall([this, p] { pimpl_cpu->set_speed_profile(p); });
+}
 
 /** @brief Get the peak processor speed (in flops/s), at the specified pstate  */
 double Host::get_pstate_speed(int pstate_index) const