Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix test: java-app-bittorrent
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 25 Mar 2021 13:56:12 +0000 (14:56 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 25 Mar 2021 14:27:38 +0000 (15:27 +0100)
Add a warning in Changelog, although no result has changed in our tests,
it's probably possible.

Simplify model management. As models must be added in order in the
engine, the list is already in the correct order respecting the
dependencies.

ChangeLog
src/kernel/EngineImpl.cpp
src/kernel/EngineImpl.hpp

index 3d92275..64b30db 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,15 @@ User-visible changes:
  - Removed all that was related to the "Storage" type in all APIs and bindings.
    "Disks" have been introduced more than a year ago to replace them for the better.
    It's time to finish this replacement.
+ - Model iteration order may change simulations.
+    *****************************************
+    *DO NOT MIX 3.27 RESULTS WITH OLDER ONES*
+    *****************************************
+       The order in which the different models (CPU, network, disk, etc) are
+       solved internally has changed in this version. Although rare (no current
+       test raises the problem), this change can result in slightest different simulations
+       results. Take care when comparing simulations from different SimGrid's
+       versions. Sorry for the inconvenience.
 
 S4U:
  - Define new template functions Mailbox::get_unique(), returning a std::unique_ptr.
index 9fba6da..0635354 100644 (file)
@@ -58,26 +58,13 @@ void EngineImpl::add_model(std::shared_ptr<resource::Model> model, const std::ve
   auto model_name = model->get_name();
   xbt_assert(models_prio_.find(model_name) == models_prio_.end(),
              "Model %s already exists, use model.set_name() to change its name", model_name.c_str());
-  int order = -1;
+
   for (const auto dep : dependencies) {
     xbt_assert(models_prio_.find(dep->get_name()) != models_prio_.end(),
                "Model %s doesn't exists. Impossible to use it as dependency.", dep->get_name().c_str());
-    if (models_prio_[dep->get_name()].prio > order) {
-      order = models_prio_[dep->get_name()].prio;
-    }
-  }
-  models_prio_[model_name] = {++order, std::move(model)};
-
-  auto sorted_models = std::vector<std::pair<std::string, ModelStruct>>(models_prio_.begin(), models_prio_.end());
-  std::sort(
-      sorted_models.begin(), sorted_models.end(),
-      [](const std::pair<std::string, ModelStruct>& first, const std::pair<std::string, ModelStruct>& second) -> bool {
-        return first.second.prio < second.second.prio;
-      });
-  models_.clear();
-  for (const auto& model : sorted_models) {
-    models_.push_back(model.second.ptr.get());
   }
+  models_.push_back(model.get());
+  models_prio_[model_name] = std::move(model);
 }
 
 } // namespace kernel
index 0a592de..69963c8 100644 (file)
@@ -25,11 +25,7 @@ class EngineImpl {
   std::unordered_map<std::string, actor::ActorCodeFactory> registered_functions; // Maps function names to actor code
   actor::ActorCodeFactory default_function; // Function to use as a fallback when the provided name matches nothing
   std::vector<resource::Model*> models_;
-  struct ModelStruct {
-    int prio;
-    std::shared_ptr<resource::Model> ptr;
-  };
-  std::unordered_map<std::string, struct ModelStruct> models_prio_;
+  std::unordered_map<std::string, std::shared_ptr<resource::Model>> models_prio_;
   routing::NetZoneImpl* netzone_root_ = nullptr;
 
   friend s4u::Engine;