Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
further snake_casing in resource::Action
[simgrid.git] / src / surf / ptask_L07.cpp
index 00be086..4a7d7c1 100644 (file)
@@ -46,7 +46,7 @@ HostL07Model::~HostL07Model()
   delete surf_cpu_model_pm;
 }
 
-CpuL07Model::CpuL07Model(HostL07Model* hmodel, lmm_system_t sys) : CpuModel(), hostModel_(hmodel)
+CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : CpuModel(), hostModel_(hmodel)
 {
   maxmin_system_ = sys;
 }
@@ -56,7 +56,7 @@ CpuL07Model::~CpuL07Model()
   maxmin_system_ = nullptr;
 }
 
-NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, lmm_system_t sys) : NetworkModel(), hostModel_(hmodel)
+NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : NetworkModel(), hostModel_(hmodel)
 {
   maxmin_system_ = sys;
   loopback_     = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);
@@ -74,7 +74,7 @@ double HostL07Model::nextOccuringEvent(double now)
     const L07Action& net_action = static_cast<const L07Action&>(action);
     if (net_action.latency_ > 0 && (min < 0 || net_action.latency_ < min)) {
       min = net_action.latency_;
-      XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.getStartTime(), min);
+      XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min);
     }
   }
   XBT_DEBUG("min value: %f", min);
@@ -93,19 +93,19 @@ void HostL07Model::updateActionsState(double /*now*/, double delta)
       } else {
         action.latency_ = 0.0;
       }
-      if ((action.latency_ <= 0.0) && (action.isSuspended() == 0)) {
+      if ((action.latency_ <= 0.0) && (action.is_suspended() == 0)) {
         action.updateBound();
-        maxmin_system_->update_variable_weight(action.getVariable(), 1.0);
+        maxmin_system_->update_variable_weight(action.get_variable(), 1.0);
       }
     }
-    XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.getRemains(),
-              action.getVariable()->get_value() * delta);
-    action.updateRemains(action.getVariable()->get_value() * delta);
+    XBT_DEBUG("Action (%p) : remains (%g) updated by %g.", &action, action.get_remains(),
+              action.get_variable()->get_value() * delta);
+    action.update_remains(action.get_variable()->get_value() * delta);
 
-    if (action.getMaxDuration() > NO_MAX_DURATION)
-      action.updateMaxDuration(delta);
+    if (action.get_max_duration() > NO_MAX_DURATION)
+      action.update_max_duration(delta);
 
-    XBT_DEBUG("Action (%p) : remains (%g).", &action, action.getRemains());
+    XBT_DEBUG("Action (%p) : remains (%g).", &action, action.get_remains());
 
     /* In the next if cascade, the action can be finished either because:
      *  - The amount of remaining work reached 0
@@ -113,13 +113,13 @@ void HostL07Model::updateActionsState(double /*now*/, double delta)
      * If it's not done, it may have failed.
      */
 
-    if (((action.getRemains() <= 0) && (action.getVariable()->get_weight() > 0)) ||
-        ((action.getMaxDuration() > NO_MAX_DURATION) && (action.getMaxDuration() <= 0))) {
+    if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) ||
+        ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
       action.finish(kernel::resource::Action::State::done);
     } else {
       /* Need to check that none of the model has failed */
       int i = 0;
-      kernel::lmm::Constraint* cnst = action.getVariable()->get_constraint(i);
+      kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
       while (cnst != nullptr) {
         i++;
         void* constraint_id = cnst->get_id();
@@ -128,7 +128,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta)
           action.finish(kernel::resource::Action::State::failed);
           break;
         }
-        cnst = action.getVariable()->get_constraint(i);
+        cnst = action.get_variable()->get_constraint(i);
       }
     }
   }
@@ -181,13 +181,13 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos
   XBT_DEBUG("Creating a parallel task (%p) with %d hosts and %d unique links.", this, host_nb, nb_link);
   latency_ = latency;
 
-  setVariable(model->getMaxminSystem()->variable_new(this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
+  set_variable(model->getMaxminSystem()->variable_new(this, 1.0, (rate > 0 ? rate : -1.0), host_nb + nb_link));
 
   if (latency_ > 0)
-    model->getMaxminSystem()->update_variable_weight(getVariable(), 0.0);
+    model->getMaxminSystem()->update_variable_weight(get_variable(), 0.0);
 
   for (int i = 0; i < host_nb; i++)
-    model->getMaxminSystem()->expand(host_list[i]->pimpl_cpu->constraint(), getVariable(), flops_amount[i]);
+    model->getMaxminSystem()->expand(host_list[i]->pimpl_cpu->constraint(), get_variable(), flops_amount[i]);
 
   if(bytes_amount != nullptr) {
     for (int i = 0; i < host_nb; i++) {
@@ -197,7 +197,7 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos
           hostList_->at(i)->routeTo(hostList_->at(j), route, nullptr);
 
           for (auto const& link : route)
-            model->getMaxminSystem()->expand_add(link->constraint(), this->getVariable(),
+            model->getMaxminSystem()->expand_add(link->constraint(), this->get_variable(),
                                                  bytes_amount[i * host_nb + j]);
         }
       }
@@ -205,8 +205,8 @@ L07Action::L07Action(kernel::resource::Model* model, int host_nb, sg_host_t* hos
   }
 
   if (nb_link + nb_used_host == 0) {
-    this->setCost(1.0);
-    this->setRemains(0.0);
+    this->set_cost(1.0);
+    this->set_remains(0.0);
   }
   delete[] host_list;
 }
@@ -273,9 +273,9 @@ kernel::resource::Action* CpuL07::execution_start(double size)
 kernel::resource::Action* CpuL07::sleep(double duration)
 {
   L07Action *action = static_cast<L07Action*>(execution_start(1.0));
-  action->setMaxDuration(duration);
+  action->set_max_duration(duration);
   action->suspended_ = kernel::resource::Action::SuspendStates::sleeping;
-  model()->getMaxminSystem()->update_variable_weight(action->getVariable(), 0.0);
+  model()->getMaxminSystem()->update_variable_weight(action->get_variable(), 0.0);
 
   return action;
 }
@@ -293,7 +293,7 @@ void CpuL07::onSpeedChange() {
   while ((var = constraint()->get_variable(&elem))) {
     kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
 
-    model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
+    model()->getMaxminSystem()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
   }
 
   Cpu::onSpeedChange();
@@ -401,25 +401,11 @@ void L07Action::updateBound()
   XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
   if ((latency_ <= 0.0) && (suspended_ == Action::SuspendStates::not_suspended)) {
     if (rate_ < 0)
-      getModel()->getMaxminSystem()->update_variable_bound(getVariable(), lat_bound);
+      get_model()->getMaxminSystem()->update_variable_bound(get_variable(), lat_bound);
     else
-      getModel()->getMaxminSystem()->update_variable_bound(getVariable(), std::min(rate_, lat_bound));
+      get_model()->getMaxminSystem()->update_variable_bound(get_variable(), std::min(rate_, lat_bound));
   }
 }
 
-int L07Action::unref()
-{
-  refcount_--;
-  if (not refcount_) {
-    if (stateSetHook_.is_linked())
-      simgrid::xbt::intrusive_erase(*state_set_, *this);
-    if (getVariable())
-      getModel()->getMaxminSystem()->variable_free(getVariable());
-    delete this;
-    return 1;
-  }
-  return 0;
-}
-
 }
 }