Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Workaround for multicore ptasks.
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 7 Jul 2022 15:53:30 +0000 (17:53 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 7 Jul 2022 15:53:30 +0000 (17:53 +0200)
Fixes https://framagit.org/simgrid/simgrid/-/issues/111.

Workaround for multicore ptasks (when user sets the same s4u::Host*
multiple times in the ptask).

The Element class in System.cpp links a variable and a constraint.
Ideally, we could have only 1 element for each pair variable/constraint.
However, the fair_bottleneck solver needs different elements to cope with multicore ptasks.
At FairBottleneck::solver, it considers each elem as a "variable" which must receive a full
share of the resource.

Multiple elements per contraint/variable isn't necessary for others solvers (maxmin, bmf).
However, it's probably not possible to use BMF at this moment
considering its instability and the current implementation in ptask_L07.cpp (especially the configuration of
task bound which is specific for FairBottleneck solver).

Partially revert change to set 1 element per constraint/variable pair (done at ecb0903f).

src/kernel/lmm/System.cpp
src/kernel/lmm/System.hpp
src/surf/ptask_L07.cpp

index 326b404..8723613 100644 (file)
@@ -270,18 +270,20 @@ Element& System::expand_add_to_elem(Element& elem, const Constraint* cnst, doubl
   return elem;
 }
 
-void System::expand(Constraint* cnst, Variable* var, double consumption_weight)
+void System::expand(Constraint* cnst, Variable* var, double consumption_weight, bool force_creation)
 {
   modified_ = true;
 
   auto elem_it =
       std::find_if(begin(var->cnsts_), end(var->cnsts_), [&cnst](Element const& x) { return x.constraint == cnst; });
-  if (elem_it != end(var->cnsts_) && var->sharing_penalty_ != 0.0) {
+
+  bool reuse_elem = elem_it != end(var->cnsts_) && not force_creation;
+  if (reuse_elem && var->sharing_penalty_ != 0.0) {
     /* before changing it, decreases concurrency on constraint, it'll be added back later */
     elem_it->decrease_concurrency();
   }
-  Element& elem = elem_it != end(var->cnsts_) ? expand_add_to_elem(*elem_it, cnst, consumption_weight)
-                                              : expand_create_elem(cnst, var, consumption_weight);
+  Element& elem = reuse_elem ? expand_add_to_elem(*elem_it, cnst, consumption_weight)
+                             : expand_create_elem(cnst, var, consumption_weight);
 
   // Check if we need to disable the variable
   if (var->sharing_penalty_ != 0) {
index 173d044..12a194f 100644 (file)
@@ -464,8 +464,11 @@ public:
    * @param cnst A constraint
    * @param var A variable
    * @param value The coefficient associated to the variable in the constraint
+   * @param force_creation Force the creation of new element linking the variable to the constraint. Should be used only
+   * by the model ptask_L07 to cope with ptasks composed of flows running on the same resource (see
+   * https://framagit.org/simgrid/simgrid/-/issues/111)
    */
-  void expand(Constraint * cnst, Variable * var, double value);
+  void expand(Constraint* cnst, Variable* var, double value, bool force_creation = false);
 
   /** @brief Update the bound of a variable */
   void update_variable_bound(Variable * var, double bound);
index 209639d..357dd10 100644 (file)
@@ -205,7 +205,7 @@ L07Action::L07Action(Model* model, const std::vector<s4u::Host*>& host_list, con
    * communication either */
   for (size_t i = 0; i < host_nb; i++) {
     model->get_maxmin_system()->expand(host_list[i]->get_cpu()->get_constraint(), get_variable(),
-                                       (flops_amount == nullptr ? 0.0 : flops_amount[i]));
+                                       (flops_amount == nullptr ? 0.0 : flops_amount[i]), true);
   }
 
   if (bytes_amount != nullptr) {