#include "surf_private.h"
#include "surf/surf_resource.h"
#include "maxmin_private.h"
+#include "simgrid/sg_config.h"
surf_model_t surf_cpu_model = NULL;
static void cpu_update_actions_state_lazy(double now, double delta)
{
- surf_action_cpu_Cas01_t action;
- while ((xbt_heap_size(surf_cpu_model->model_private->action_heap) > 0)
- && (double_equals(xbt_heap_maxkey(surf_cpu_model->model_private->action_heap), now))) {
- action = xbt_heap_pop(surf_cpu_model->model_private->action_heap);
- XBT_DEBUG("Action %p: finish", action);
- GENERIC_ACTION(action).finish = surf_get_clock();
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- cpu_Cas01_t cpu =
- lmm_constraint_id(lmm_get_cnst_from_var
- (surf_cpu_model->model_private->maxmin_system,
- GENERIC_LMM_ACTION(action).variable, 0));
- TRACE_surf_host_set_utilization(cpu->generic_resource.name,
- ((surf_action_t)action)->category,
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
- GENERIC_LMM_ACTION(action).last_update,
- now - GENERIC_LMM_ACTION(action).last_update);
- }
-#endif
- /* set the remains to 0 due to precision problems when updating the remaining amount */
- GENERIC_ACTION(action).remains = 0;
- surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
- surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action); //FIXME: strange call since action was already popped
- }
-#ifdef HAVE_TRACING
- 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;
- xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
- xbt_swag_foreach(action, running_actions) {
- if (smaller < 0) {
- smaller = GENERIC_LMM_ACTION(action).last_update;
- continue;
- }
- if (GENERIC_LMM_ACTION(action).last_update < smaller) {
- smaller = GENERIC_LMM_ACTION(action).last_update;
- }
- }
- if (smaller > 0) {
- TRACE_last_timestamp_to_dump = smaller;
- }
- }
-#endif
- return;
+ generic_update_actions_state_lazy(now, delta, surf_cpu_model);
}
static void cpu_update_actions_state_full(double now, double delta)
{
- surf_action_cpu_Cas01_t action = NULL;
- surf_action_cpu_Cas01_t next_action = NULL;
- xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
- xbt_swag_foreach_safe(action, next_action, running_actions) {
-#ifdef HAVE_TRACING
- if (TRACE_is_enabled()) {
- cpu_Cas01_t x =
- lmm_constraint_id(lmm_get_cnst_from_var
- (surf_cpu_model->model_private->maxmin_system,
- GENERIC_LMM_ACTION(action).variable, 0));
-
- TRACE_surf_host_set_utilization(x->generic_resource.name,
- ((surf_action_t)action)->category,
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
- variable),
- now - delta,
- delta);
- TRACE_last_timestamp_to_dump = now - delta;
- }
-#endif
- double_update(&(GENERIC_ACTION(action).remains),
- lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
- variable) * delta);
- if (GENERIC_LMM_ACTION(action).generic_action.max_duration !=
- NO_MAX_DURATION)
- double_update(&(GENERIC_ACTION(action).max_duration), delta);
- if ((GENERIC_ACTION(action).remains <= 0) &&
- (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) >
- 0)) {
- GENERIC_ACTION(action).finish = surf_get_clock();
- surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
- } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
- (GENERIC_ACTION(action).max_duration <= 0)) {
- GENERIC_ACTION(action).finish = surf_get_clock();
- surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
- }
- }
-
- return;
+ generic_update_actions_state_full(now, delta, surf_cpu_model);
}
static void cpu_update_resource_state(void *id,
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
+ surf_watched_hosts();
+
if (event_type == cpu->power_event) {
cpu->power_scale = value;
lmm_update_constraint_bound(surf_cpu_model->model_private->maxmin_system, cpu->constraint,
s_surf_action_t action;
s_surf_action_cpu_Cas01_t comp;
- char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
+ char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
int select =
- xbt_cfg_get_int(_surf_cfg_set, "cpu/maxmin_selective_update");
+ xbt_cfg_get_int(_sg_cfg_set, "cpu/maxmin_selective_update");
surf_cpu_model = surf_model_init();
xbt_assert((select == 1)
||
(xbt_cfg_is_default_value
- (_surf_cfg_set, "cpu/maxmin_selective_update")),
+ (_sg_cfg_set, "cpu/maxmin_selective_update")),
"Disabling selective update while using the lazy update mechanism is dumb!");
} else {
xbt_die("Unsupported optimization (%s) for this model", optim);
void surf_cpu_model_init_Cas01()
{
- char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
+ char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
if (surf_cpu_model)
return;