4 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
5 "Logging specific to the SURF cpu module");
8 CpuModelPtr surf_cpu_model;
14 void CpuModel::updateActionsStateLazy(double now, double delta)
18 while ((xbt_heap_size(p_actionHeap) > 0)
19 && (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
20 action = (ActionLmmPtr) xbt_heap_pop(p_actionHeap);
21 XBT_DEBUG("Something happened to action %p", action);
23 if (TRACE_is_enabled()) {
24 CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_maxminSystem, action->p_variable, 0));
25 TRACE_surf_host_set_utilization(cpu->m_name, action->p_category,
26 lmm_variable_getvalue(action->p_variable),
28 now - action->m_lastUpdate);
32 action->m_finish = surf_get_clock();
33 XBT_DEBUG("Action %p finished", action);
35 /* set the remains to 0 due to precision problems when updating the remaining amount */
36 action->m_remains = 0;
37 action->setState(SURF_ACTION_DONE);
38 action->heapRemove(p_actionHeap); //FIXME: strange call since action was already popped
41 if (TRACE_is_enabled()) {
42 //defining the last timestamp that we can safely dump to trace file
43 //without losing the event ascending order (considering all CPU's)
45 xbt_swag_foreach(_action, p_runningActionSet) {
46 action = (ActionLmmPtr) _action;
48 smaller = action->m_lastUpdate;
51 if (action->m_lastUpdate < smaller) {
52 smaller = action->m_lastUpdate;
56 TRACE_last_timestamp_to_dump = smaller;
63 void CpuModel::updateActionsStateFull(double now, double delta)
65 void *_action, *_next_action;
66 ActionLmmPtr action = NULL;
67 ActionLmmPtr next_action = NULL;
68 xbt_swag_t running_actions = p_runningActionSet;
70 xbt_swag_foreach_safe(_action, _next_action, running_actions) {
71 action = (ActionLmmPtr) _action;
73 if (TRACE_is_enabled()) {
74 CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var
75 (p_maxminSystem, action->p_variable, 0));
77 TRACE_surf_host_set_utilization(x->m_name,
79 lmm_variable_getvalue(action->p_variable),
82 TRACE_last_timestamp_to_dump = now - delta;
86 double_update(&(action->m_remains),
87 lmm_variable_getvalue(action->p_variable) * delta);
90 if (action->m_maxDuration != NO_MAX_DURATION)
91 double_update(&(action->m_maxDuration), delta);
94 if ((action->m_remains <= 0) &&
95 (lmm_get_variable_weight(action->p_variable) > 0)) {
96 action->m_finish = surf_get_clock();
97 action->setState(SURF_ACTION_DONE);
99 } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
100 (action->m_maxDuration <= 0)) {
101 action->m_finish = surf_get_clock();
102 action->setState(SURF_ACTION_DONE);
113 double Cpu::getSpeed(double load)
115 return load * m_powerPeak;
118 double Cpu::getAvailableSpeed()
120 /* number between 0 and 1 */
133 void CpuActionLmm::updateRemainingLazy(double now)
137 xbt_assert(p_stateSet == p_model->p_runningActionSet,
138 "You're updating an action that is not running.");
140 /* bogus priority, skip it */
141 xbt_assert(m_priority > 0,
142 "You're updating an action that seems suspended.");
144 delta = now - m_lastUpdate;
147 XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", this, m_remains, m_lastUpdate);
148 double_update(&(m_remains), m_lastValue * delta);
151 if (TRACE_is_enabled()) {
152 CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0));
153 TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
156 XBT_DEBUG("Updating action(%p): remains is now %lf", this, m_remains);
160 m_lastValue = lmm_variable_getvalue(p_variable);