Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make maxmin_system_ a private field for resource::Model.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 27 Mar 2018 09:03:24 +0000 (11:03 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Tue, 27 Mar 2018 19:15:16 +0000 (21:15 +0200)
include/simgrid/kernel/resource/Model.hpp
src/surf/StorageImpl.cpp
src/surf/cpu_cas01.cpp
src/surf/network_cm02.cpp
src/surf/network_ib.cpp
src/surf/ptask_L07.cpp
src/surf/storage_n11.cpp

index dc228ad..5e8bbbf 100644 (file)
@@ -52,6 +52,9 @@ public:
   /** @brief Get the maxmin system of the current Model */
   lmm::System* get_maxmin_system() const { return maxmin_system_; }
 
+  /** @brief Set the maxmin system of the current Model */
+  void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
+
   /**
    * @brief Get the update mechanism of the current Model
    * @see e_UM_t
@@ -93,10 +96,8 @@ public:
    */
   virtual bool nextOccuringEventIsIdempotent() { return true; }
 
-protected:
-  lmm::System* maxmin_system_ = nullptr;
-
 private:
+  lmm::System* maxmin_system_           = nullptr;
   e_UM_t update_mechanism_        = UM_UNDEFINED;
   Action::StateSet* ready_action_set_   = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */
   Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */
index bafab94..d15f285 100644 (file)
@@ -32,7 +32,7 @@ simgrid::xbt::signal<void(StorageAction*, kernel::resource::Action::State, kerne
 
 StorageModel::StorageModel() : Model()
 {
-  maxmin_system_ = new simgrid::kernel::lmm::System(true /* selective update */);
+  set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
 }
 
 StorageModel::~StorageModel()
index bacf715..8fdf8d5 100644 (file)
@@ -51,10 +51,10 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
     xbt_die("Unsupported optimization (%s) for this model", optim.c_str());
   }
 
-  maxmin_system_ = new simgrid::kernel::lmm::System(select);
+  set_maxmin_system(new simgrid::kernel::lmm::System(select));
 
   if (getUpdateMechanism() == UM_LAZY)
-    maxmin_system_->modified_set_ = new kernel::resource::Action::ModifiedSet();
+    get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
 }
 
 CpuCas01Model::~CpuCas01Model()
index a0678ac..4065a0d 100644 (file)
@@ -151,22 +151,22 @@ NetworkCm02Model::NetworkCm02Model()
     xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim.c_str());
   }
 
-  maxmin_system_ = new simgrid::kernel::lmm::System(select);
+  set_maxmin_system(new simgrid::kernel::lmm::System(select));
   loopback_     = NetworkCm02Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 
   if (getUpdateMechanism() == UM_LAZY)
-    maxmin_system_->modified_set_ = new kernel::resource::Action::ModifiedSet();
+    get_maxmin_system()->modified_set_ = new kernel::resource::Action::ModifiedSet();
 }
 
 NetworkCm02Model::NetworkCm02Model(void (*specificSolveFun)(kernel::lmm::System* self)) : NetworkCm02Model()
 {
-  maxmin_system_->solve_fun = specificSolveFun;
+  get_maxmin_system()->solve_fun = specificSolveFun;
 }
 
 LinkImpl* NetworkCm02Model::createLink(const std::string& name, double bandwidth, double latency,
                                        e_surf_link_sharing_policy_t policy)
 {
-  return new NetworkCm02Link(this, name, bandwidth, latency, policy, maxmin_system_);
+  return new NetworkCm02Link(this, name, bandwidth, latency, policy, get_maxmin_system());
 }
 
 void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
@@ -190,7 +190,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
     // if I am wearing a latency hat
     if (action->get_type() == kernel::resource::Action::Type::LATENCY) {
       XBT_DEBUG("Latency paid for action %p. Activating", action);
-      maxmin_system_->update_variable_weight(action->get_variable(), action->weight_);
+      get_maxmin_system()->update_variable_weight(action->get_variable(), action->weight_);
       action->heapRemove();
       action->set_last_update();
 
@@ -222,7 +222,7 @@ void NetworkCm02Model::update_actions_state_full(double now, double delta)
         action.latency_ = 0.0;
       }
       if (action.latency_ <= 0.0 && not action.is_suspended())
-        maxmin_system_->update_variable_weight(action.get_variable(), action.weight_);
+        get_maxmin_system()->update_variable_weight(action.get_variable(), action.weight_);
     }
     if (TRACE_is_enabled()) {
       int n = action.get_variable()->get_number_of_constraint();
@@ -304,7 +304,7 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
   constraints_per_variable += back_route.size();
 
   if (action->latency_ > 0) {
-    action->set_variable(maxmin_system_->variable_new(action, 0.0, -1.0, constraints_per_variable));
+    action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
     if (getUpdateMechanism() == UM_LAZY) {
       // add to the heap the event when the latency is payed
       XBT_DEBUG("Added action (%p) one latency event at date %f", action, action->latency_ + action->get_last_update());
@@ -313,25 +313,25 @@ kernel::resource::Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Hos
                                                                            : kernel::resource::Action::Type::LATENCY);
     }
   } else
-    action->set_variable(maxmin_system_->variable_new(action, 1.0, -1.0, constraints_per_variable));
+    action->set_variable(get_maxmin_system()->variable_new(action, 1.0, -1.0, constraints_per_variable));
 
   if (action->rate_ < 0) {
-    maxmin_system_->update_variable_bound(
+    get_maxmin_system()->update_variable_bound(
         action->get_variable(), (action->latCurrent_ > 0) ? sg_tcp_gamma / (2.0 * action->latCurrent_) : -1.0);
   } else {
-    maxmin_system_->update_variable_bound(action->get_variable(),
-                                          (action->latCurrent_ > 0)
-                                              ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
-                                              : action->rate_);
+    get_maxmin_system()->update_variable_bound(action->get_variable(),
+                                               (action->latCurrent_ > 0)
+                                                   ? std::min(action->rate_, sg_tcp_gamma / (2.0 * action->latCurrent_))
+                                                   : action->rate_);
   }
 
   for (auto const& link : route)
-    maxmin_system_->expand(link->constraint(), action->get_variable(), 1.0);
+    get_maxmin_system()->expand(link->constraint(), action->get_variable(), 1.0);
 
   if (not back_route.empty()) { //  sg_network_crosstraffic was activated
     XBT_DEBUG("Crosstraffic active adding backward flow using 5%%");
     for (auto const& link : back_route)
-      maxmin_system_->expand(link->constraint(), action->get_variable(), .05);
+      get_maxmin_system()->expand(link->constraint(), action->get_variable(), .05);
 
     // Change concurrency_share here, if you want that cross-traffic is included in the SURF concurrency
     // (You would also have to change simgrid::kernel::lmm::Element::get_concurrency())
index 354b99d..76418ae 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2017. The SimGrid Team.
+/* Copyright (c) 2014-2018. The SimGrid Team.
 *All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -174,7 +174,7 @@ void NetworkIBModel::computeIBfactors(IBNode* root)
     if (not double_equals(penalized_bw, rate_before_update, sg_surf_precision)) {
       XBT_DEBUG("%d->%d action %p penalty updated : bw now %f, before %f , initial rate %f", root->id,
                 (*it)->destination->id, (*it)->action, penalized_bw, (*it)->action->get_bound(), (*it)->init_rate);
-      maxmin_system_->update_variable_bound((*it)->action->get_variable(), penalized_bw);
+      get_maxmin_system()->update_variable_bound((*it)->action->get_variable(), penalized_bw);
     } else {
       XBT_DEBUG("%d->%d action %p penalty not updated : bw %f, initial rate %f", root->id, (*it)->destination->id,
                 (*it)->action, penalized_bw, (*it)->init_rate);
index 2497ebd..34e525e 100644 (file)
@@ -34,10 +34,10 @@ namespace simgrid {
 namespace surf {
 
 HostL07Model::HostL07Model() : HostModel() {
-  maxmin_system_            = new simgrid::kernel::lmm::System(true /* selective update */);
-  maxmin_system_->solve_fun = &simgrid::kernel::lmm::bottleneck_solve;
-  surf_network_model        = new NetworkL07Model(this, maxmin_system_);
-  surf_cpu_model_pm         = new CpuL07Model(this, maxmin_system_);
+  set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
+  get_maxmin_system()->solve_fun = &simgrid::kernel::lmm::bottleneck_solve;
+  surf_network_model = new NetworkL07Model(this, get_maxmin_system());
+  surf_cpu_model_pm  = new CpuL07Model(this, get_maxmin_system());
 }
 
 HostL07Model::~HostL07Model()
@@ -48,23 +48,23 @@ HostL07Model::~HostL07Model()
 
 CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : CpuModel(), hostModel_(hmodel)
 {
-  maxmin_system_ = sys;
+  set_maxmin_system(sys);
 }
 
 CpuL07Model::~CpuL07Model()
 {
-  maxmin_system_ = nullptr;
+  set_maxmin_system(nullptr);
 }
 
 NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : NetworkModel(), hostModel_(hmodel)
 {
-  maxmin_system_ = sys;
+  set_maxmin_system(sys);
   loopback_     = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
 }
 
 NetworkL07Model::~NetworkL07Model()
 {
-  maxmin_system_ = nullptr;
+  set_maxmin_system(nullptr);
 }
 
 double HostL07Model::next_occuring_event(double now)
@@ -95,7 +95,7 @@ void HostL07Model::update_actions_state(double /*now*/, double delta)
       }
       if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
         action.updateBound();
-        maxmin_system_->update_variable_weight(action.get_variable(), 1.0);
+        get_maxmin_system()->update_variable_weight(action.get_variable(), 1.0);
       }
     }
     XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(),
index 9a7e82c..03b1cff 100644 (file)
@@ -61,7 +61,7 @@ StorageImpl* StorageN11Model::createStorage(std::string id, std::string type_id,
                                            "property Bwrite, storage", type_id.c_str());
 
   StorageImpl* storage =
-      new StorageN11(this, id, maxmin_system_, Bread, Bwrite, type_id, content_name, storage_type->size, attach);
+      new StorageN11(this, id, get_maxmin_system(), Bread, Bwrite, type_id, content_name, storage_type->size, attach);
   storageCreatedCallbacks(storage);
 
   XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tBread '%f'\n", id.c_str(), type_id.c_str(),