surf_model_t surf_cpu_model = NULL;
lmm_system_t cpu_maxmin_system = NULL;
e_UM_t cpu_update_mechanism = UM_UNDEFINED;
+static int cpu_selective_update = 0;
+
static xbt_swag_t cpu_modified_cpu = NULL;
static xbt_heap_t cpu_action_heap = NULL;
-extern int sg_maxmin_selective_update;
#undef GENERIC_LMM_ACTION
#undef GENERIC_ACTION
}
static double cpu_share_resources_full(double now) {
- surf_action_cpu_Cas01_t action;
+ s_surf_action_cpu_Cas01_t action;
return generic_maxmin_share_resources(surf_cpu_model->states.running_action_set,
- xbt_swag_offset(*action, generic_lmm_action.variable),
+ xbt_swag_offset(action, generic_lmm_action.variable),
cpu_maxmin_system, lmm_solve);
}
cpu->state_current = SURF_RESOURCE_ON;
else {
lmm_constraint_t cnst = cpu->constraint;
- lmm_variable_t var = NULL;
- lmm_element_t elem = NULL;
cpu->state_current = SURF_RESOURCE_OFF;
/* update remains before return it */
if(cpu_update_mechanism == UM_LAZY)
cpu_update_remains(ACTION_GET_CPU(action), surf_get_clock());
- return action->remains;
XBT_OUT();
+ return action->remains;
}
static e_surf_resource_state_t cpu_get_state(void *cpu)
if(cpu_modified_cpu) xbt_swag_free(cpu_modified_cpu);
}
-static void surf_cpu_model_init_internal(const char* name)
+static void surf_cpu_model_init_internal()
{
s_surf_action_t action;
s_cpu_Cas01_t cpu;
cpu_running_action_set_that_does_not_need_being_checked =
xbt_swag_new(xbt_swag_offset(action, state_hookup));
- surf_cpu_model->name = name;
+ surf_cpu_model->name = "cpu";
surf_cpu_model->action_unref = cpu_action_unref;
surf_cpu_model->action_cancel = cpu_action_cancel;
surf_cpu_model->model_private->resource_used = cpu_resource_used;
- if(cpu_update_mechanism == UM_LAZY)
+ if(cpu_update_mechanism == UM_LAZY) {
surf_cpu_model->model_private->share_resources = cpu_share_resources_lazy;
- else if (cpu_update_mechanism == UM_FULL)
- surf_cpu_model->model_private->share_resources = cpu_share_resources_full;
- else
- xbt_die("Invalide update mechanism!");
-
- if(cpu_update_mechanism == UM_LAZY)
surf_cpu_model->model_private->update_actions_state = cpu_update_actions_state_lazy;
- else if(cpu_update_mechanism == UM_FULL)
+ } else if (cpu_update_mechanism == UM_FULL) {
+ surf_cpu_model->model_private->share_resources = cpu_share_resources_full;
surf_cpu_model->model_private->update_actions_state = cpu_update_actions_state_full;
- else
- xbt_die("Incompatible optimization mode");
+ } else
+ xbt_die("Invalid update mechanism!");
surf_cpu_model->model_private->update_resource_state =
cpu_update_resource_state;
surf_cpu_model->extension.cpu.add_traces = cpu_add_traces_cpu;
if (!cpu_maxmin_system) {
- sg_maxmin_selective_update = 1;
- cpu_maxmin_system = lmm_system_new();
+ cpu_maxmin_system = lmm_system_new(cpu_selective_update);
}
if(cpu_update_mechanism == UM_LAZY){
cpu_action_heap = xbt_heap_new(8, NULL);
void surf_cpu_model_init_Cas01()
{
char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
- char *model = xbt_cfg_get_string(_surf_cfg_set, "cpu/model");
-
- if(!strcmp(model,"Cas01_fullupdate")) {
- XBT_WARN("[*Deprecated*. Use --cfg=cpu/model:Cas01 with option --cfg=cpu/optim:Full instead.]");
- } else if(!strcmp(model,"CpuTI")) {
- XBT_WARN("[*Deprecated*. Use --cfg=cpu/model:Cas01 with option --cfg=cpu/optim:TI instead.]");
- }
+ int select = xbt_cfg_get_int(_surf_cfg_set, "cpu/maxmin_selective_update");
if(!strcmp(optim,"Full")) {
cpu_update_mechanism = UM_FULL;
+ cpu_selective_update = select;
} else if (!strcmp(optim,"Lazy")) {
cpu_update_mechanism = UM_LAZY;
+ cpu_selective_update = 1;
+ xbt_assert((select==1) || (xbt_cfg_is_default_value(_surf_cfg_set,"cpu/maxmin_selective_update")),
+ "Disabling selective update while using the lazy update mechanism is dumb!");
} else if (!strcmp(optim,"TI")) {
surf_cpu_model_init_ti();
return;
if (surf_cpu_model)
return;
- surf_cpu_model_init_internal("CPU");
+ surf_cpu_model_init_internal();
cpu_define_callbacks();
xbt_dynar_push(model_list, &surf_cpu_model);
}