Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
authormlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 5 Jun 2023 14:09:11 +0000 (16:09 +0200)
committermlaurent <mathieu.laurent@ens-rennes.fr>
Mon, 5 Jun 2023 14:09:11 +0000 (16:09 +0200)
18 files changed:
.gitlab-ci.yml
docs/requirements.txt
examples/cpp/exec-dependent/s4u-exec-dependent.cpp
examples/python/task-io/task-io.py
examples/python/task-simple/task-simple.py
examples/python/task-switch-host/task-switch-host.py
examples/python/task-variable-load/task-variable-load.py
include/simgrid/s4u/Activity.hpp
src/bindings/python/simgrid_python.cpp
src/kernel/activity/ActivityImpl.cpp
src/kernel/activity/CommImpl.cpp
src/kernel/xml/platf_sax_cb.cpp
src/mc/explo/odpor/Execution.hpp
src/mc/explo/odpor/WakeupTree.hpp
src/mc/explo/odpor/odpor_forward.hpp
src/plugins/task.cpp
src/s4u/s4u_Comm.cpp
tools/docker/Dockerfile.build-deps

index 67a8202..efb1950 100644 (file)
@@ -86,12 +86,13 @@ pip:
 pages:
   stage: deploy
   script:
-  - pip3 install --requirement docs/requirements.txt
+  - apt install python3-breathe python3-sphinx python3-sphinx-rtd-theme python3-sphinx-copybutton python3-sphinx-tabs
+ # - pip3 install --requirement docs/requirements.txt # Forbidden in Debian:12
   - cd docs
   - LC_ALL=C.UTF-8 ./Build.sh
   - mv build/html ../public
   # - The CSS contains a reference to a font or something, not something we gonna fix on our side
-#not installed   - linkchecker --ignore-url='.*\.css$' ../public
+# not installed   - linkchecker --ignore-url='.*\.css$' ../public
   # From time to time, we should check external links with the
   # following, but it has a lot of false positive
   # - linkchecker --ignore-url='.*\.css$' --check-extern ../public
index a98401b..d6238d6 100644 (file)
@@ -1,5 +1,5 @@
 breathe>=4.26
-sphinx>=3.4.3,<4.0
+sphinx
 sphinx_rtd_theme>=0.5.2
 # sphinx_tabs v1.2.1 is required for Sphinx 2
 sphinx_tabs>=1.2.1
index 23e67b7..f473664 100644 (file)
@@ -55,7 +55,6 @@ int main(int argc, char* argv[])
   sg4::Actor::create("worker", e.host_by_name("Fafard"), worker);
 
   sg4::Exec::on_veto_cb([&e](sg4::Exec& exec) {
-
     // First display the situation
     XBT_INFO("Activity '%s' vetoed. Dependencies: %s; Ressources: %s", exec.get_cname(),
              (exec.dependencies_solved() ? "solved" : "NOT solved"),
index 18a4cb2..b74c411 100644 (file)
@@ -17,8 +17,8 @@ def parse():
     )
     return parser.parse_args()
 
-def callback( t):
-    print(f'[{Engine.clock}] { t} finished ({ t.count})')
+def callback(t):
+    print(f'[{Engine.clock}] {t} finished ({t.count})')
 
 if __name__ == '__main__':
     args = parse()
@@ -48,4 +48,4 @@ if __name__ == '__main__':
     exec1.enqueue_execs(2)
 
     # runs the simulation
-    e.run()
\ No newline at end of file
+    e.run()
index 29a24b7..1219906 100644 (file)
@@ -27,8 +27,8 @@ def parse():
     )
     return parser.parse_args()
 
-def callback( t):
-    print(f'[{Engine.clock}] { t} finished ({ t.count})')
+def callback(t):
+    print(f'[{Engine.clock}] {t} finished ({t.count})')
 
 if __name__ == '__main__':
     args = parse()
index f8d8dfa..3bd21e6 100644 (file)
@@ -43,13 +43,13 @@ def parse():
     )
     return parser.parse_args()
 
-def callback( t):
-    print(f'[{Engine.clock}] { t} finished ({ t.count})')
+def callback(t):
+    print(f'[{Engine.clock}] {t} finished ({t.count})')
 
-def switch( t, hosts, execs):
-    comm0.destination = hosts[ t.count % 2]
-    comm0.remove_successor(execs[ t.count % 2 - 1])
-    comm0.add_successor(execs[ t.count % 2])
+def switch(t, hosts, execs):
+    comm0.destination = hosts[t.count % 2]
+    comm0.remove_successor(execs[t.count % 2 - 1])
+    comm0.add_successor(execs[t.count % 2])
 
 if __name__ == '__main__':
     args = parse()
@@ -81,7 +81,7 @@ if __name__ == '__main__':
     # Add a function to be called before each executions of comm0
     # This function modifies the graph of tasks by adding or removing
     # successors to comm0
-    comm0.on_this_start(lambda  t: switch( t, [jupiter, fafard], [exec1,exec2]))
+    comm0.on_this_start(lambda t: switch(t, [jupiter, fafard], [exec1,exec2]))
 
     # Enqueue two executions for task exec1
     comm0.enqueue_execs(4)
index 5e437e3..7310584 100644 (file)
@@ -27,17 +27,17 @@ def parse():
     )
     return parser.parse_args()
 
-def callback( t):
-    print(f'[{Engine.clock}] { t} finished ({ t.count})')
+def callback(t):
+    print(f'[{Engine.clock}] {t} finished ({t.count})')
 
-def variable_load( t):
+def variable_load(t):
     print('--- Small load ---')
-    for i in range(3):
+    for _ in range(3):
         t.enqueue_execs(1)
         this_actor.sleep_for(100)
     this_actor.sleep_for(1000)
     print('--- Heavy load ---')
-    for i in range(3):
+    for _ in range(3):
         t.enqueue_execs(1)
         this_actor.sleep_for(1)
 
index 2b8175c..3c6a4eb 100644 (file)
@@ -272,7 +272,6 @@ public:
   XBT_ATTRIB_DEPRECATED_v337("Please use on_resume_cb() instead") static void on_resumed_cb(
       const std::function<void(Activity const&)>& cb) { on_resume.connect(cb);  }
 
-
   AnyActivity* add_successor(ActivityPtr a)
   {
     Activity::add_successor(a);
index a89056d..d0ce338 100644 (file)
@@ -927,9 +927,9 @@ PYBIND11_MODULE(simgrid, m)
           [](py::object cb) {
             cb.inc_ref(); // keep alive after return
             const py::gil_scoped_release gil_release;
-            Task::on_start_cb([cb](Task* op) {
+            Task::on_start_cb([cb_p = cb.ptr()](Task* op) {
               const py::gil_scoped_acquire py_context; // need a new context for callback
-              py::reinterpret_borrow<py::function>(cb.ptr())(op);
+              py::reinterpret_borrow<py::function>(cb_p)(op);
             });
           },
           "Add a callback called when each task starts.")
@@ -938,9 +938,9 @@ PYBIND11_MODULE(simgrid, m)
           [](py::object cb) {
             cb.inc_ref(); // keep alive after return
             const py::gil_scoped_release gil_release;
-            Task::on_end_cb([cb](Task* op) {
+            Task::on_end_cb([cb_p = cb.ptr()](Task* op) {
               const py::gil_scoped_acquire py_context; // need a new context for callback
-              py::reinterpret_borrow<py::function>(cb.ptr())(op);
+              py::reinterpret_borrow<py::function>(cb_p)(op);
             });
           },
           "Add a callback called when each task ends.")
index a81face..69a6936 100644 (file)
@@ -176,10 +176,6 @@ void ActivityImpl::wait_any_for(actor::ActorImpl* issuer, const std::vector<Acti
 
 void ActivityImpl::suspend()
 {
-  if (model_action_ == nullptr) {
-    XBT_CRITICAL("POUET");
-    return;
-  }
   XBT_VERB("This activity is suspended (remain: %f)", model_action_->get_remains());
   get_iface()->fire_on_suspend();
   get_iface()->fire_on_this_suspend();
index 5dedf54..7452071 100644 (file)
@@ -470,6 +470,7 @@ void CommImpl::finish()
 
   if (get_iface()) {
     const auto& piface = static_cast<const s4u::Comm&>(*get_iface());
+    set_iface(nullptr); // reset iface to protect against multiple trigger of the on_completion signals
     s4u::Comm::on_completion(piface);
     piface.on_this_completion(piface);
   }
index 2a2abe8..340b47a 100644 (file)
@@ -310,7 +310,6 @@ void ETag_simgrid_parse_platform()
   simgrid::s4u::Engine::on_simulation_end_cb(&remove_remote_disks);
   if (fire_on_platform_created_callback)
     simgrid::s4u::Engine::on_platform_created();
-
 }
 
 void STag_simgrid_parse_prop()
index f3bd7ed..6d8ca42 100644 (file)
@@ -118,7 +118,7 @@ public:
    * 9 |    --> add some q in I_[E'](v) to backtrack(E')
    *
    * This method computes all of the lines simultaneously,
-   * returning some actor `q` if it passes line 8 and exists.
+   * returning the set `I_[E'](v)` if condition on line 8 holds.
    * The event `e` and the set `backtrack(E')` are the provided
    * arguments to the method.
    *
@@ -135,20 +135,21 @@ public:
    * See the SDPOR algorithm pseudocode in [1] for more
    * details for the context of the function.
    *
-   * @invariant: This method assumes that events `e` and
-   * `e' := get_latest_event_handle()` are in a *reversible* race
+   * @precondition: This method assumes that events `e` and
+   * `e' := get_latest_event_handle()` are in a *reversible* race,
    * as is explicitly the case in SDPOR
    *
-   * @returns an actor not contained in `disqualified` which
-   * can serve as an initial to reverse the race between `e`
-   * and `e'`
+   * @returns a set of actors not already contained in `backtrack_set`
+   * which serve as an initials to reverse the race between `e`
+   * and `e' := get_latest_event_handle()`; that is, an initial that is
+   * not already contained in the set `backtrack_set`.
    */
   std::unordered_set<aid_t> get_missing_source_set_actors_from(EventHandle e,
                                                                const std::unordered_set<aid_t>& backtrack_set) const;
 
   /**
    * @brief Computes the analogous lines from the SDPOR algorithm
-   * in the ODPOR algorithm, viz. the intersection of the slee set
+   * in the ODPOR algorithm, viz. the intersection of the sleep set
    * and the set of weak initials with respect to the given pair
    * of racing events
    *
@@ -156,14 +157,20 @@ public:
    *
    * 4 | let E' := pre(E, e)
    * 5 | let v := notdep(e, E).e'^
-   * 6 | if sleep(E') ∩ WI_[E'](v) = empty then ...
+   * 6 | if sleep(E') ∩ WI_[E'](v) = empty then
+   * 7 |   --> wut(E') := insert_[E'](v, wut(E'))
    *
    * The sequence `v` is computed and returned as needed, based on whether
    * the check on line 6 passes.
    *
-   * @invariant: This method assumes that events `e` and
-   * `e_prime` are in a *reversible* race as is the case
-   * in ODPOR
+   * @precondition: This method assumes that events `e` and
+   * `e_prime` are in a *reversible* race, as is the case
+   * in ODPOR.
+   *
+   * @returns a partial execution `v := notdep(e, E)` (where `E` refers
+   * to this execution) that should be inserted into a wakeup tree with
+   * respect to this execution if `sleep(E') ∩ WI_[E'](v) = empty`, and
+   * `std::nullopt` otherwise
    */
   std::optional<PartialExecution> get_odpor_extension_from(EventHandle e, EventHandle e_prime,
                                                            const State& state_at_e) const;
@@ -184,10 +191,7 @@ public:
    * | and add `v.w'` as a new leaf, ordered after all already existing nodes
    * | of the form `v.w''`
    *
-   * This method computes the result `v.w'` as needed (viz. only if `v ~_[E] w`
-   * with respect to this execution `E`)
-   *
-   * The procedure for determining `v ~_[E] w` is given as Lemma 4.6 of
+   * The procedure for determining whether `v ~_[E] w` is given as Lemma 4.6 of
    * Abdulla et al. 2017:
    *
    * | The relation `v ~_[E] w` holds if either
@@ -196,13 +200,22 @@ public:
    * |     (a) p in I_[E](w) and `v' ~_[E.p] (w \ p)`
    * |     (b) E ⊢ p ◊ w and `v' ~_[E.p] w`
    *
-   * @invariant: This method assumes that `E.v` is a valid execution, viz.
+   * This method computes the result `v.w'` as needed (viz. only if `v ~_[E] w`
+   * with respect to this execution `E`). The implementation takes advantage
+   * of the fact that determining whether `v ~_[E] w` yields "for free" the
+   * the shortest such `w'` we are looking for; if we ultimately determine
+   * that `v ~_[E] w`, the work we did to do so leaves us precisely with `w'`,
+   * so we can simply prepend `v` to it and call it a day
+   *
+   * @precondition: This method assumes that `E.v` is a valid execution, viz.
    * that the events of `E` are sufficient to enabled `v_0` and that
    * `v_0, ..., v_{i - 1}` are sufficient to enable `v_i`. This is the
    * case when e.g. `v := notdep(e, E).p` for example in ODPOR
    *
-   * @returns a partial execution `w'` that should be inserted
-   * as a child of a wakeup tree node with the associated sequence `v`.
+   * @returns a partial execution `v.w'` that should be inserted
+   * as a child of a wakeup tree node representing the sequence `v`
+   * if `v ~_[E] w`, or `std::nullopt` if that relation does not hold
+   * between the two sequences `v` and `w`
    */
   std::optional<PartialExecution> get_shortest_odpor_sq_subset_insertion(const PartialExecution& v,
                                                                          const PartialExecution& w) const;
@@ -226,14 +239,12 @@ public:
   bool is_independent_with_execution_of(const PartialExecution& w, std::shared_ptr<Transition> next_E_p) const;
 
   /**
-   * @brief Determines the event associated with
-   * the given handle `handle`
+   * @brief Determines the event associated with the given handle `handle`
    */
   const Event& get_event_with_handle(EventHandle handle) const { return contents_[handle]; }
 
   /**
-   * @brief Determines the actor associated with
-   * the given event handle `handle`
+   * @brief Determines the actor associated with the given event handle `handle`
    */
   aid_t get_actor_with_handle(EventHandle handle) const { return get_event_with_handle(handle).get_transition()->aid_; }
 
@@ -246,8 +257,11 @@ public:
   }
 
   /**
-   * @brief Returns a handle to the newest event of the execution,
-   * if such an event exists
+   * @brief Returns a handle to the newest event of the execution, if such an event exists
+   *
+   * @returns the handle to the last event of the execution.
+   * If the sequence is empty, no such handle exists and the
+   * method returns `std::nullopt`
    */
   std::optional<EventHandle> get_latest_event_handle() const
   {
@@ -260,7 +274,7 @@ public:
    * in the ODPOR paper) with the given event
    *
    * Two events `e` and `e'` in an execution `E` are said to
-   * race iff
+   * *race* iff
    *
    * 1. `proc(e) != proc(e')`; that is, the events correspond to
    * the execution of different actors
@@ -271,7 +285,8 @@ public:
    *
    * @param handle the event with respect to which races are
    * computed
-   * @returns a set of event handles from which race with `handle`
+   * @returns a set of event handles, each element of which is an
+   * event in this execution which is in a *race* with event `handle`
    */
   std::unordered_set<EventHandle> get_racing_events_of(EventHandle handle) const;
 
@@ -280,7 +295,7 @@ public:
    * race with the given event handle `handle`
    *
    * Two events `e` and `e'` in an execution `E` are said to
-   * be in a reversible race iff
+   * be in a *reversible race* iff
    *
    * 1. `e` and `e'` race
    * 2. In any equivalent execution sequence `E'` to `E`
@@ -289,8 +304,8 @@ public:
    *
    * @param handle the event with respect to which
    * reversible races are computed
-   * @returns a set of event handles from which are in a reversible
-   * race with `handle`
+   * @returns a set of event handles, each element of which is an event
+   * in this execution which is in a *reversible race* with event `handle`
    */
   std::unordered_set<EventHandle> get_reversible_races_of(EventHandle handle) const;
 
@@ -299,10 +314,10 @@ public:
    *
    * The execution `pre(e, E)` for an event `e` in an
    * execution `E` is the contiguous prefix of events
-   * `E' <= E` up to by excluding the event `e` itself.
-   * The prefix intuitively represents the "history" of
-   * causes that permitted event `e` to exist (roughly
-   * speaking)
+   * `E' <= E` up to but excluding the event `e` itself.
+   * Roughly speaking, the prefix intuitively represents
+   * the "history" of causes which permitted event `e`
+   * to exist
    */
   Execution get_prefix_before(EventHandle) const;
 
@@ -338,6 +353,10 @@ public:
 
   /**
    * @brief Extends the execution by a sequence of steps
+   *
+   * This method has the equivalent effect of pushing the
+   * transitions of the partial execution one-by-one onto
+   * the execution
    */
   void push_partial_execution(const PartialExecution&);
 };
index ea8cf29..59b96c3 100644 (file)
@@ -21,7 +21,17 @@ namespace simgrid::mc::odpor {
 /**
  * @brief A single node in a wakeup tree
  *
- * Each node in a wakeup tree contains
+ * Each node in a wakeup tree represents a single step
+ * taken in an extension of the execution represented
+ * by the tree within which the node is contained. That is,
+ * a node in the tree is one step on a "pre-defined"
+ * path forward for some execution sequence. The partial
+ * execution that is implicitly represented by the node
+ * is that formed by taking each step on the (unique)
+ * path in the tree from the root node to this node.
+ * Thus, the tree itself contains all of the paths
+ * that "should be" searched, while each node is
+ * simply a step on each path.
  */
 class WakeupTreeNode {
 private:
@@ -167,7 +177,7 @@ public:
    * @brief Returns the number of *non-empty* entries in the tree, viz. the
    * number of nodes in the tree that have an action mapped to them
    */
-  size_t get_num_entries() const { return !empty() ? (nodes_.size() - 1) : static_cast<size_t>(0); }
+  size_t get_num_entries() const { return not empty() ? (nodes_.size() - 1) : static_cast<size_t>(0); }
 
   /**
    * @brief Returns the number of nodes in the tree, including the root node
index 52388bc..946e3f4 100644 (file)
@@ -25,7 +25,7 @@ class Execution;
 class ReversibleRaceCalculator;
 class WakeupTree;
 class WakeupTreeNode;
-class WakeupTreeIterator;
+struct WakeupTreeIterator;
 
 } // namespace simgrid::mc::odpor
 
index f0bf5b1..c464f04 100644 (file)
@@ -101,7 +101,7 @@ void Task::complete()
     working_ = false;
     count_++;
   });
-  for (auto end_func : end_func_handlers_)
+  for (auto const& end_func : end_func_handlers_)
     end_func(this);
   Task::on_end(this);
   for (auto const& t : successors_)
@@ -241,7 +241,7 @@ ExecTaskPtr ExecTask::init(const std::string& name, double flops, s4u::Host* hos
  */
 void ExecTask::fire()
 {
-  for (auto start_func : start_func_handlers_)
+  for (auto const& start_func : start_func_handlers_)
     start_func(this);
   Task::on_start(this);
   kernel::actor::simcall_answered([this] {
@@ -305,7 +305,7 @@ CommTaskPtr CommTask::init(const std::string& name, double bytes, s4u::Host* sou
  */
 void CommTask::fire()
 {
-  for (auto start_func : start_func_handlers_)
+  for (auto const& start_func : start_func_handlers_)
     start_func(this);
   Task::on_start(this);
   kernel::actor::simcall_answered([this] {
@@ -399,7 +399,7 @@ IoTaskPtr IoTask::set_op_type(s4u::Io::OpType type)
 
 void IoTask::fire()
 {
-  for (auto start_func : start_func_handlers_)
+  for (auto const& start_func : start_func_handlers_)
     start_func(this);
   Task::on_start(this);
   kernel::actor::simcall_answered([this] {
index f7bfc9e..a6ada2f 100644 (file)
@@ -58,8 +58,6 @@ Comm::~Comm()
       XBT_INFO("pimpl_ is null");
     xbt_backtrace_display_current();
   }
-  if (pimpl_ != nullptr)
-    pimpl_->set_iface(nullptr);
 }
 
 void Comm::send(kernel::actor::ActorImpl* sender, const Mailbox* mbox, double task_size, double rate, void* src_buff,
index 8fdaa14..8ce4d26 100644 (file)
@@ -1,5 +1,5 @@
-# Base image
-FROM debian:11
+# Base image: bookworm is Debian 12
+FROM debian:bookworm
 
 # Install the dependencies:
 #  - of the website