Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Implement the last (?) Python functions needed for the tutorial
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Jan 2022 01:19:43 +0000 (02:19 +0100)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 23 Jan 2022 01:19:43 +0000 (02:19 +0100)
docs/source/Tutorial_Algorithms.rst
docs/source/XML_reference.rst
docs/source/app_msg.rst
docs/source/app_s4u.rst
examples/python/platform-profile/platform-profile.py
src/bindings/python/simgrid_python.cpp

index ab0cb35..3e34981 100644 (file)
@@ -819,15 +819,11 @@ Lab 4: What-if analysis
    * Change the platform characteristics during the simulation.
    * Explore other communication patterns.
 
-.. todo::
-
-   Some of the required functions are not implemented in Python yet. You can detect that if the method name is not a link to the documentation.
-
 Computational speed
 ...................
 
 Attach a profile to your hosts, so that their computational speed automatically vary over time, modeling an external load on these machines.
-This can be done with :cpp:func:`simgrid::s4u::Host::set_speed_profile` (C++) or :py:func:`simgrid.Host.set_speed_profile` (python). 
+This can be done with :cpp:func:`simgrid::s4u::Host::set_speed_profile` (C++) or :py:func:`simgrid.Host.set_speed_profile` (Python). 
 
 Make it so that one of the hosts get really really slow, and observe how your whole application performance decreases.
 This is because one slow host slows down the whole process. Instead of a round-robin dispatch push, 
index 9435ecf..1060796 100644 (file)
@@ -324,8 +324,8 @@ hyperlinks in an `hypergraph <https://en.wikipedia.org/wiki/Hypergraph>`_.
       8.0 60000000
       LOOPAFTER 12.0
 
-   - At time t = 4, the bandwidth is of 40 MBps.
-   - At time t = 8, it raises to 60MBps.
+   - At time t = 4, the bandwidth is of 40 Mb/s.
+   - At time t = 8, it raises to 60 Mb/s.
    - At time t = 24, it drops at 40 MBps again.
 
    If your profile does not contain any LOOPAFTER line, then it will
index d3dc33e..ebfc632 100644 (file)
@@ -359,6 +359,7 @@ Package org.simgrid.msg
 
    Class org.simgrid.msg.As <java/org/simgrid/msg/As>
    Class org.simgrid.msg.Comm <java/org/simgrid/msg/Comm>
+   Class org.simgrid.msg.File <java/org/simgrid/msg/File>
    Class org.simgrid.msg.Host <java/org/simgrid/msg/Host>
    Class org.simgrid.msg.HostFailureException <java/org/simgrid/msg/HostFailureException>
    Class org.simgrid.msg.HostNotFoundException <java/org/simgrid/msg/HostNotFoundException>
@@ -370,6 +371,8 @@ Package org.simgrid.msg
    Class org.simgrid.msg.ProcessKilledError <java/org/simgrid/msg/ProcessKilledError>
    Class org.simgrid.msg.ProcessNotFoundException <java/org/simgrid/msg/ProcessNotFoundException>
    Class org.simgrid.msg.Semaphore <java/org/simgrid/msg/Semaphore>
+   Class org.simgrid.msg.Storage <java/org/simgrid/msg/Storage>
+   Class org.simgrid.msg.StorageNotFoundException <java/org/simgrid/msg/StorageNotFoundException>
    Class org.simgrid.msg.Task <java/org/simgrid/msg/Task>
    Class org.simgrid.msg.TaskCancelledException <java/org/simgrid/msg/TaskCancelledException>
    Class org.simgrid.msg.TimeoutException <java/org/simgrid/msg/TimeoutException>
index c961b65..ee3d74b 100644 (file)
@@ -1324,6 +1324,7 @@ Querying info
       .. autoattribute:: simgrid.Host.load
       .. autoattribute:: simgrid.Host.pstate
       .. autoattribute:: simgrid.Host.speed
+      .. autoattribute:: simgrid.Host.available_speed
 
    .. group-tab:: C
 
@@ -1402,14 +1403,11 @@ DVFS
       .. doxygenfunction:: simgrid::s4u::Host::get_pstate_count() const
       .. doxygenfunction:: simgrid::s4u::Host::get_pstate_speed(unsigned long pstate_index) const
       .. doxygenfunction:: simgrid::s4u::Host::set_pstate(unsigned long pstate_index)
-      .. doxygenfunction:: simgrid::s4u::Host::set_speed_profile(kernel::profile::Profile *p)
-      .. doxygenfunction:: simgrid::s4u::Host::set_state_profile(kernel::profile::Profile *p)
 
    .. group-tab:: Python
 
       .. automethod:: simgrid.Host.get_pstate_count
       .. automethod:: simgrid.Host.get_pstate_speed
-      .. automethod:: simgrid.Host.set_speed_profile
 
    .. group-tab:: C
 
@@ -1419,6 +1417,21 @@ DVFS
       .. doxygenfunction:: sg_host_get_pstate_speed(const_sg_host_t host, unsigned long pstate_index)
       .. doxygenfunction:: sg_host_set_pstate(sg_host_t host, unsigned long pstate)
 
+Dynamic profiles
+----------------
+
+.. tabs::
+
+   .. group-tab:: C++
+
+      .. doxygenfunction:: simgrid::s4u::Host::set_speed_profile(kernel::profile::Profile *p)
+      .. doxygenfunction:: simgrid::s4u::Host::set_state_profile(kernel::profile::Profile *p)
+
+   .. group-tab:: Python
+
+      .. automethod:: simgrid.Host.set_speed_profile
+      .. automethod:: simgrid.Host.set_state_profile
+
 Execution
 ---------
 
@@ -1654,6 +1667,12 @@ See :ref:`howto_churn` for more details.
       .. doxygenfunction:: simgrid::s4u::Link::set_latency_profile(kernel::profile::Profile *profile)
       .. doxygenfunction:: simgrid::s4u::Link::set_state_profile(kernel::profile::Profile *profile)
 
+   .. group-tab:: Python
+
+      .. automethod:: simgrid.Link.set_bandwidth_profile
+      .. automethod:: simgrid.Link.set_latency_profile
+      .. automethod:: simgrid.Link.set_state_profile
+
 WIFI links
 ----------
 
@@ -2497,9 +2516,6 @@ Locking
 
       .. doxygentypedef:: sg_bar_t
       .. doxygentypedef:: const_sg_bar_t
-      .. cpp:type:: const s4u_Barrier* const_sg_bar_t
-
-         Pointer to a constant barrier object.
 
       .. doxygenfunction:: sg_barrier_init(unsigned int count)
       .. doxygenfunction:: sg_barrier_destroy(const_sg_bar_t bar)
index 399fde7..5c1cd20 100644 (file)
@@ -38,10 +38,8 @@ if __name__ == '__main__':
 
   # Add a new host programmatically, and attach a simple speed profile to it (alternate between full and half speed every two seconds
   lili = e.get_netzone_root().create_host("Lilibeth", 25e6)
-  lili.set_speed_profile("""
-0 1.0
-2 0.5
-""", 2)
+  lili.set_speed_profile("""0 1.0
+2 0.5""", 2)
   lili.seal()
 
   # Add a watcher of the changes
index c423bf7..5d99033 100644 (file)
@@ -269,11 +269,43 @@ PYBIND11_MODULE(simgrid, m)
             h->route_to(to, *list, &bw);
             return make_tuple(list, bw);
           },
-          "Retrieves the list of links and the bandwidth between two hosts")
-      .def("set_speed_profile",
-           [](Host* h, const std::string& profile, double period) {
-             h->set_speed_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
-           })
+          "Retrieves the list of links and the bandwidth between two hosts.")
+      .def(
+          "set_speed_profile",
+          [](Host* h, const std::string& profile, double period) {
+            h->set_speed_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+          },
+          py::call_guard<py::gil_scoped_release>(),
+          "Specify a profile modeling the external load according to an exhaustive list. "
+          "Each line of the profile describes timed events as ``date ratio``. "
+          "For example, the following content describes an host which computational speed is initially 1 (i.e, 100%) "
+          "and then halved after 42 seconds:\n\n"
+          ".. code-block:: python\n\n"
+          "   \"\"\"\n"
+          "   0 1.0\n"
+          "   42 0.5\n"
+          "   \"\"\"\n\n"
+          ".. warning:: Don't get fooled: bandwidth and latency profiles of links contain absolute values,"
+          " while speed profiles of hosts contain ratios.\n\n"
+          "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+          "the list. Set it to -1 to not loop over.")
+      .def(
+          "set_state_profile",
+          [](Host* h, const std::string& profile, double period) {
+            h->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+          },
+          py::call_guard<py::gil_scoped_release>(),
+          "Specify a profile modeling the churn. "
+          "Each line of the profile describes timed events as ``date boolean``, where the boolean (0 or 1) tells "
+          "whether the host is on. "
+          "For example, the following content describes a link which turns off at t=1 and back on at t=2:\n\n"
+          ".. code-block:: python\n\n"
+          "   \"\"\"\n"
+          "   1.0 0\n"
+          "   2.0 1\n"
+          "   \"\"\"\n\n"
+          "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+          "the list. Set it to -1 to not loop over.")
       .def("get_pstate_count", &Host::get_pstate_count, "Retrieve the count of defined pstate levels")
       .def("get_pstate_speed", &Host::get_pstate_speed, "Retrieve the maximal speed at the given pstate")
       .def("get_netpoint", &Host::get_netpoint, "Retrieve the netpoint associated to this host")
@@ -363,6 +395,60 @@ PYBIND11_MODULE(simgrid, m)
            py::call_guard<py::gil_scoped_release>(), "Set the latency as a float (in seconds).")
       .def("set_bandwidth", &simgrid::s4u::Link::set_bandwidth, py::call_guard<py::gil_scoped_release>(),
            "Set the bandwidth (in byte per second).")
+      .def(
+          "set_bandwidth_profile",
+          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+            l->set_bandwidth_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+          },
+          py::call_guard<py::gil_scoped_release>(),
+          "Specify a profile modeling the external load according to an exhaustive list. "
+          "Each line of the profile describes timed events as ``date bandwidth`` (in bytes per second). "
+          "For example, the following content describes a link which bandwidth changes to 40 Mb/s at t=4, and to 6 "
+          "Mb/s at t=8:\n\n"
+          ".. code-block:: python\n\n"
+          "   \"\"\"\n"
+          "   4.0 40000000\n"
+          "   8.0 60000000\n"
+          "   \"\"\"\n\n"
+          ".. warning:: Don't get fooled: bandwidth and latency profiles of links contain absolute values,"
+          " while speed profiles of hosts contain ratios.\n\n"
+          "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+          "the list. Set it to -1 to not loop over.")
+      .def(
+          "set_latency_profile",
+          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+            l->set_latency_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+          },
+          py::call_guard<py::gil_scoped_release>(),
+          "Specify a profile modeling the external load according to an exhaustive list. "
+          "Each line of the profile describes timed events as ``date latency`` (in seconds). "
+          "For example, the following content describes a link which latency changes to 1ms (0.001s) at t=1, and to 2s "
+          "at t=2:\n\n"
+          ".. code-block:: python\n\n"
+          "   \"\"\"\n"
+          "   1.0 0.001\n"
+          "   2.0 2\n"
+          "   \"\"\"\n\n"
+          ".. warning:: Don't get fooled: bandwidth and latency profiles of links contain absolute values,"
+          " while speed profiles of hosts contain ratios.\n\n"
+          "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+          "the list. Set it to -1 to not loop over.")
+      .def(
+          "set_state_profile",
+          [](simgrid::s4u::Link* l, const std::string& profile, double period) {
+            l->set_state_profile(simgrid::kernel::profile::ProfileBuilder::from_string("", profile, period));
+          },
+          "Specify a profile modeling the churn. "
+          "Each line of the profile describes timed events as ``date boolean``, where the boolean (0 or 1) tells "
+          "whether the link is on. "
+          "For example, the following content describes a link which turns off at t=1 and back on at t=2:\n\n"
+          ".. code-block:: python\n\n"
+          "   \"\"\"\n"
+          "   1.0 0\n"
+          "   2.0 1\n"
+          "   \"\"\"\n\n"
+          "The second function parameter is the periodicity: the time to wait after the last event to start again over "
+          "the list. Set it to -1 to not loop over.")
 
       .def("turn_on", &simgrid::s4u::Link::turn_on, py::call_guard<py::gil_scoped_release>(), "Turns the link on.")
       .def("turn_off", &simgrid::s4u::Link::turn_off, py::call_guard<py::gil_scoped_release>(), "Turns the link off.")