Ejemplo n.º 1
0
void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
{
  NetworkConstantActionPtr action = NULL;
  ActionListPtr actionSet = getRunningActionSet();
  for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
     ; it != itend ; it=itNext) {
    ++itNext;
	action = static_cast<NetworkConstantActionPtr>(&*it);
    if (action->m_latency > 0) {
      if (action->m_latency > delta) {
        double_update(&(action->m_latency), delta, sg_surf_precision);
      } else {
        action->m_latency = 0.0;
      }
    }
    action->updateRemains(action->getCost() * delta / action->m_latInit);
    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);

    if (action->getRemainsNoUpdate() <= 0) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    } else if ((action->getMaxDuration() != NO_MAX_DURATION)
               && (action->getMaxDuration() <= 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    }
  }
}
Ejemplo n.º 2
0
    void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
    {
      NetworkConstantAction *action = nullptr;
      ActionList *actionSet = getRunningActionSet();
      for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
          ; it != itend ; it=itNext) {
        ++itNext;
        action = static_cast<NetworkConstantAction*>(&*it);
        if (action->latency_ > 0) {
          if (action->latency_ > delta) {
            double_update(&(action->latency_), delta, sg_surf_precision);
          } else {
            action->latency_ = 0.0;
          }
        }
        action->updateRemains(action->getCost() * delta / action->initialLatency_);
        if (action->getMaxDuration() != NO_MAX_DURATION)
          action->updateMaxDuration(delta);

        if (action->getRemainsNoUpdate() <= 0) {
          action->finish();
          action->setState(Action::State::done);
        } else if ((action->getMaxDuration() != NO_MAX_DURATION)
            && (action->getMaxDuration() <= 0)) {
          action->finish();
          action->setState(Action::State::done);
        }
      }
    }
Ejemplo n.º 3
0
void NetworkCm02Model::updateActionsStateFull(double now, double delta)
{
  NetworkCm02ActionPtr action;
  ActionListPtr running_actions = getRunningActionSet();

  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
     ; it != itend ; it=itNext) {
	++itNext;

    action = (NetworkCm02ActionPtr) &*it;
    XBT_DEBUG("Something happened to action %p", action);
      double deltap = delta;
      if (action->m_latency > 0) {
        if (action->m_latency > deltap) {
          double_update(&(action->m_latency), deltap, sg_surf_precision);
          deltap = 0.0;
        } else {
          double_update(&(deltap), action->m_latency, sg_surf_precision);
          action->m_latency = 0.0;
        }
        if (action->m_latency == 0.0 && !(action->isSuspended()))
          lmm_update_variable_weight(p_maxminSystem, action->getVariable(),
              action->m_weight);
      }
  #ifdef HAVE_TRACING
      if (TRACE_is_enabled()) {
        int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
        int i;
        for (i = 0; i < n; i++){
          lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
                                                            action->getVariable(),
                                                            i);
          NetworkCm02LinkPtr link = static_cast<NetworkCm02LinkPtr>(lmm_constraint_id(constraint));
          TRACE_surf_link_set_utilization(link->getName(),
                                        action->getCategory(),
                                        (lmm_variable_getvalue(action->getVariable())*
                                            lmm_get_cnst_weight_from_var(p_maxminSystem,
                                                action->getVariable(),
                                                i)),
                                        action->getLastUpdate(),
                                        now - action->getLastUpdate());
        }
      }
  #endif
      if (!lmm_get_number_of_cnst_from_var
          (p_maxminSystem, action->getVariable())) {
        /* There is actually no link used, hence an infinite bandwidth.
         * This happens often when using models like vivaldi.
         * In such case, just make sure that the action completes immediately.
         */
        action->updateRemains(action->getRemains());
      }
    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
                  
    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);
      
    if ((action->getRemains() <= 0) &&
        (lmm_get_variable_weight(action->getVariable()) > 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
      action->gapRemove();
    } else if (((action->getMaxDuration() != NO_MAX_DURATION)
        && (action->getMaxDuration() <= 0))) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
      action->gapRemove();
    }
  }
  return;
}
Ejemplo n.º 4
0
 /** @brief Update the remaining time of the current action
  *  @param delta Amount to remove from the remaining time */
 void updateRemains(double delta) {double_update(&remains_, delta, sg_maxmin_precision*sg_surf_precision);}
Ejemplo n.º 5
0
 /** @brief Update the maximum duration of the current action
  *  @param delta Amount to remove from the MaxDuration */
 void updateMaxDuration(double delta) {double_update(&maxDuration_, delta,sg_surf_precision);}
Ejemplo n.º 6
0
void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve()
{
  if (not modified_)
    return;

  XBT_DEBUG("Variable set : %zu", variable_set.size());
  for (Variable& var : variable_set) {
    var.value = 0.0;
    XBT_DEBUG("Handling variable %p", &var);
    if (var.sharing_weight > 0.0 && std::find_if(begin(var.cnsts), end(var.cnsts), [](Element const& x) {
                                      return x.consumption_weight != 0.0;
                                    }) != end(var.cnsts)) {
      saturated_variable_set.push_back(var);
    } else {
      XBT_DEBUG("Err, finally, there is no need to take care of variable %p", &var);
      if (var.sharing_weight > 0.0)
        var.value = 1.0;
    }
  }

  XBT_DEBUG("Active constraints : %zu", active_constraint_set.size());
  for (Constraint& cnst : active_constraint_set) {
    saturated_constraint_set.push_back(cnst);
  }
  for (Constraint& cnst : saturated_constraint_set) {
    cnst.remaining = cnst.bound;
    cnst.usage     = 0.0;
  }

  XBT_DEBUG("Fair bottleneck Initialized");

  /*
   * Compute Usage and store the variables that reach the maximum.
   */
  auto& var_list  = saturated_variable_set;
  auto& cnst_list = saturated_constraint_set;
  do {
    if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
      XBT_DEBUG("Fair bottleneck done");
      print();
    }
    XBT_DEBUG("******* Constraints to process: %zu *******", cnst_list.size());
    for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) {
      Constraint& cnst = *iter;
      int nb = 0;
      XBT_DEBUG("Processing cnst %p ", &cnst);
      cnst.usage = 0.0;
      for (Element& elem : cnst.enabled_element_set) {
        xbt_assert(elem.variable->sharing_weight > 0);
        if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook.is_linked())
          nb++;
      }
      XBT_DEBUG("\tThere are %d variables", nb);
      if (nb > 0 && cnst.sharing_policy == s4u::Link::SharingPolicy::FATPIPE)
        nb = 1;
      if (nb == 0) {
        cnst.remaining = 0.0;
        cnst.usage     = 0.0;
        iter           = cnst_list.erase(iter);
      } else {
        cnst.usage = cnst.remaining / nb;
        XBT_DEBUG("\tConstraint Usage %p : %f with %d variables", &cnst, cnst.usage, nb);
        iter++;
      }
    }

    for (auto iter = std::begin(var_list); iter != std::end(var_list);) {
      Variable& var  = *iter;
      double min_inc = DBL_MAX;
      for (Element const& elm : var.cnsts) {
        if (elm.consumption_weight > 0)
          min_inc = std::min(min_inc, elm.constraint->usage / elm.consumption_weight);
      }
      if (var.bound > 0)
        min_inc = std::min(min_inc, var.bound - var.value);
      var.mu    = min_inc;
      XBT_DEBUG("Updating variable %p maximum increment: %g", &var, var.mu);
      var.value += var.mu;
      if (var.value == var.bound)
        iter = var_list.erase(iter);
      else
        iter++;
    }

    for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) {
      Constraint& cnst = *iter;
      XBT_DEBUG("Updating cnst %p ", &cnst);
      if (cnst.sharing_policy != s4u::Link::SharingPolicy::FATPIPE) {
        for (Element& elem : cnst.enabled_element_set) {
          xbt_assert(elem.variable->sharing_weight > 0);
          XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", &cnst, cnst.remaining, elem.variable,
                    elem.variable->mu);
          double_update(&cnst.remaining, elem.consumption_weight * elem.variable->mu, sg_maxmin_precision);
        }
      } else {
        for (Element& elem : cnst.enabled_element_set) {
          xbt_assert(elem.variable->sharing_weight > 0);
          XBT_DEBUG("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g", &cnst,
                    cnst.usage, elem.variable, elem.variable->mu);
          cnst.usage = std::min(cnst.usage, elem.consumption_weight * elem.variable->mu);
        }
        XBT_DEBUG("\tUpdate constraint %p (%g) by %g", &cnst, cnst.remaining, cnst.usage);
        double_update(&cnst.remaining, cnst.usage, sg_maxmin_precision);
      }

      XBT_DEBUG("\tRemaining for %p : %g", &cnst, cnst.remaining);
      if (cnst.remaining <= 0.0) {
        XBT_DEBUG("\tGet rid of constraint %p", &cnst);

        iter = cnst_list.erase(iter);
        for (Element& elem : cnst.enabled_element_set) {
          if (elem.variable->sharing_weight <= 0)
            break;
          if (elem.consumption_weight > 0 && elem.variable->saturated_variable_set_hook.is_linked()) {
            XBT_DEBUG("\t\tGet rid of variable %p", elem.variable);
            simgrid::xbt::intrusive_erase(var_list, *elem.variable);
          }
        }
      } else {
        iter++;
      }
    }
  } while (not var_list.empty());

  cnst_list.clear();
  modified_ = true;
  if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) {
    XBT_DEBUG("Fair bottleneck done");
    print();
  }
}
Ejemplo n.º 7
0
void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now)
{
  double delta = 0.0;
  surf_model_t model = action->generic_action.model_type;

  if(model == surf_network_model)
  {
    if (action->suspended != 0)
      return;
  }
  else
  {
    xbt_assert(action->generic_action.state_set == model->states.running_action_set,
        "You're updating an action that is not running.");

      /* bogus priority, skip it */
    xbt_assert(action->generic_action.priority > 0,
        "You're updating an action that seems suspended.");
  }

  delta = now - action->last_update;

  if (action->generic_action.remains > 0) {
    XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", action, action->generic_action.remains, action->last_update);
    double_update(&(action->generic_action.remains),
        action->last_value * delta);

#ifdef HAVE_TRACING
    if (model == surf_cpu_model && TRACE_is_enabled()) {
      surf_resource_t cpu =
          lmm_constraint_id(lmm_get_cnst_from_var
              (model->model_private->maxmin_system,
                  action->variable, 0));
      TRACE_surf_host_set_utilization(cpu->name,
          action->generic_action.category,
          action->last_value,
          action->last_update,
          now - action->last_update);
    }
#endif
    XBT_DEBUG("Updating action(%p): remains is now %lf", action,
        action->generic_action.remains);
  }

  if(model == surf_network_model)
  {
    if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
      double_update(&(((surf_action_t)action)->max_duration), delta);

    if ((((surf_action_t)action)->remains <= 0) &&
        (lmm_get_variable_weight(action->variable) > 0)) {
      ((surf_action_t)action)->finish = surf_get_clock();
      model->action_state_set((surf_action_t) action,
          SURF_ACTION_DONE);

      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
    } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
        && (((surf_action_t)action)->max_duration <= 0))) {
      ((surf_action_t)action)->finish = surf_get_clock();
      model->action_state_set((surf_action_t) action,
          SURF_ACTION_DONE);
      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
    }
  }

  action->last_update = now;
  action->last_value = lmm_variable_getvalue(action->variable);
}
Ejemplo n.º 8
0
void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
{
  double deltap = 0.0;
  WorkstationL07ActionPtr action;

  ActionListPtr actionSet = getRunningActionSet();

  for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
	 ; it != itend ; it=itNext) {
	++itNext;
    action = static_cast<WorkstationL07ActionPtr>(&*it);
    deltap = delta;
    if (action->m_latency > 0) {
      if (action->m_latency > deltap) {
        double_update(&(action->m_latency), deltap, sg_surf_precision);
        deltap = 0.0;
      } else {
        double_update(&(deltap), action->m_latency, sg_surf_precision);
        action->m_latency = 0.0;
      }
      if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
        action->updateBound();
        lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
      }
    }
    XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
           action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);

    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);

    XBT_DEBUG("Action (%p) : remains (%g).",
           action, action->getRemains());
    if ((action->getRemains() <= 0) &&
        (lmm_get_variable_weight(action->getVariable()) > 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
               (action->getMaxDuration() <= 0)) {
      action->finish();
     action->setState(SURF_ACTION_DONE);
    } else {
      /* Need to check that none of the model has failed */
      lmm_constraint_t cnst = NULL;
      int i = 0;
      void *constraint_id = NULL;

      while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
                                    i++))) {
        constraint_id = lmm_constraint_id(cnst);

        if (static_cast<WorkstationPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
          XBT_DEBUG("Action (%p) Failed!!", action);
          action->finish();
          action->setState(SURF_ACTION_FAILED);
          break;
        }
      }
    }
  }
  return;
}