コード例 #1
0
ファイル: cpu_interface.cpp プロジェクト: tempbottle/simgrid
/*********
 * Model *
 *********/
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
  CpuAction *action;
  while ((xbt_heap_size(getActionHeap()) > 0)
         && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
    action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
    XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
    if (TRACE_is_enabled()) {
      Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
      TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      action->getLastUpdate(),
                                      now - action->getLastUpdate());
    }

    action->finish();
    XBT_CDEBUG(surf_kernel, "Action %p finished", action);

    /* set the remains to 0 due to precision problems when updating the remaining amount */
    action->setRemains(0);
    action->setState(SURF_ACTION_DONE);
    action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
  }
  if (TRACE_is_enabled()) {
    //defining the last timestamp that we can safely dump to trace file
    //without losing the event ascending order (considering all CPU's)
    double smaller = -1;
    ActionList *actionSet = getRunningActionSet();
    for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
       ; it != itend ; ++it) {
      action = static_cast<CpuAction*>(&*it);
        if (smaller < 0) {
          smaller = action->getLastUpdate();
          continue;
        }
        if (action->getLastUpdate() < smaller) {
          smaller = action->getLastUpdate();
        }
    }
    if (smaller > 0) {
      TRACE_last_timestamp_to_dump = smaller;
    }
  }
  return;
}
コード例 #2
0
ファイル: cpu_interface.cpp プロジェクト: tempbottle/simgrid
void CpuModel::updateActionsStateFull(double now, double delta)
{
  CpuAction *action = NULL;
  ActionList *running_actions = getRunningActionSet();

  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
     ; it != itend ; it=itNext) {
	++itNext;
    action = static_cast<CpuAction*>(&*it);
    if (TRACE_is_enabled()) {
      Cpu *x = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) );

      TRACE_surf_host_set_utilization(x->getName(),
                                      action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      now - delta,
                                      delta);
      TRACE_last_timestamp_to_dump = now - delta;
    }

    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);


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


    if ((action->getRemainsNoUpdate() <= 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);
    }
  }

  return;
}
コード例 #3
0
ファイル: surf_action.c プロジェクト: cemsbr/simgrid
void generic_update_actions_state_lazy(double now, double delta, surf_model_t model)
{
  surf_action_lmm_t action;
  while ((xbt_heap_size(model->model_private->action_heap) > 0)
         && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
    action = xbt_heap_pop(model->model_private->action_heap);
    XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      if(model == surf_cpu_model){
      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,
                                      ((surf_action_t)action)->category,
                                      lmm_variable_getvalue(action->variable),
                                      action->last_update,
                                      now - action->last_update);
      }
      else{
        int n = lmm_get_number_of_cnst_from_var(model->model_private->maxmin_system, action->variable);
        unsigned int i;
        for (i = 0; i < n; i++){
          lmm_constraint_t constraint = lmm_get_cnst_from_var(model->model_private->maxmin_system,
                                                              action->variable,
                                                              i);
          link_CM02_t link = lmm_constraint_id(constraint);
          TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
                                          ((surf_action_t)action)->category,
                                          (lmm_variable_getvalue(action->variable)*
                                              lmm_get_cnst_weight_from_var(model->model_private->maxmin_system,
                                                  action->variable,
                                                  i)),
                                          action->last_update,
                                          now - action->last_update);
        }
      }
    }
#endif

    if(model == surf_cpu_model){
      action->generic_action.finish = surf_get_clock();

      update_resource_energy(model, action);

      /* set the remains to 0 due to precision problems when updating the remaining amount */
      action->generic_action.remains = 0;
      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
      surf_action_lmm_heap_remove(model->model_private->action_heap,action); //FIXME: strange call since action was already popped
    }
    else{
      // if I am wearing a latency hat
      if (action->hat == LATENCY) {
        XBT_DEBUG("Latency paid for action %p. Activating", action);
        lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
            ((surf_action_network_CM02_t)(action))->weight);
        surf_action_lmm_heap_remove(model->model_private->action_heap,action);
        action->last_update = surf_get_clock();

        // if I am wearing a max_duration or normal hat
      } else if (action->hat == MAX_DURATION ||
          action->hat == NORMAL) {
        // no need to communicate anymore
        // assume that flows that reached max_duration have remaining of 0
      	action->generic_action.finish = surf_get_clock();
     	XBT_DEBUG("Action %p finished", action);
  	action->generic_action.remains = 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,action);

        if (model->gap_remove && model == surf_network_model)
          model->gap_remove(action);
      }
    }
  }
#ifdef HAVE_TRACING
  if (TRACE_is_enabled() && model == surf_cpu_model) {
    //defining the last timestamp that we can safely dump to trace file
    //without losing the event ascending order (considering all CPU's)
    double smaller = -1;
    xbt_swag_t running_actions = model->states.running_action_set;
    xbt_swag_foreach(action, running_actions) {
        if (smaller < 0) {
          smaller = action->last_update;
          continue;
        }
        if (action->last_update < smaller) {
          smaller = action->last_update;
        }
    }
    if (smaller > 0) {
      TRACE_last_timestamp_to_dump = smaller;
    }
  }
コード例 #4
0
ファイル: surf_action.c プロジェクト: cemsbr/simgrid
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);
}