Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
671f3639364cdd6f83f471d9a3895a88609e5fd5
[simgrid.git] / src / surf / cpu_cas01.c
1 /* Copyright (c) 2009-2011. The SimGrid Team.
2  * All rights reserved.                                                     */
3
4 /* This program is free software; you can redistribute it and/or modify it
5  * under the terms of the license (GNU LGPL) which comes with this package. */
6
7 #include "surf_private.h"
8 #include "surf/surf_resource.h"
9 #include "maxmin_private.h"
10 #include "simgrid/sg_config.h"
11 #include "cpu_cas01_private.h"
12
13 #include "string.h"
14 #include "stdlib.h"
15
16 surf_model_t surf_cpu_model = NULL;
17
18
19 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
20                                 "Logging specific to the SURF CPU IMPROVED module");
21
22 static xbt_swag_t
23     cpu_running_action_set_that_does_not_need_being_checked = NULL;
24
25 /* Additionnal callback function to cleanup some data, called from surf_resource_free */
26
27 static void cpu_cas1_cleanup(void* r){
28   cpu_Cas01_t cpu = (cpu_Cas01_t)r;
29   unsigned int iter;
30   xbt_dynar_t power_tuple = NULL;
31   xbt_dynar_foreach(cpu->energy->power_range_watts_list, iter, power_tuple)
32     xbt_dynar_free(&power_tuple);
33   xbt_dynar_free(&cpu->energy->power_range_watts_list);
34   xbt_dynar_free(&cpu->power_peak_list);
35   xbt_free(cpu->energy);
36   return;
37 }
38
39 /* This function is registered as a callback to sg_platf_new_host() and never called directly */
40 static void *cpu_create_resource(const char *name, xbt_dynar_t power_peak,
41                                                                  int pstate,
42                                  double power_scale,
43                                  tmgr_trace_t power_trace,
44                                  int core,
45                                  e_surf_resource_state_t state_initial,
46                                  tmgr_trace_t state_trace,
47                                  xbt_dict_t cpu_properties)
48 {
49   cpu_Cas01_t cpu = NULL;
50
51   xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
52              "Host '%s' declared several times in the platform file",
53              name);
54   cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
55                                         surf_cpu_model, name,
56                                         cpu_properties,  &cpu_cas1_cleanup);
57   cpu->power_peak = xbt_dynar_get_as(power_peak, pstate, double);
58   cpu->power_peak_list = power_peak;
59   cpu->pstate = pstate;
60
61   cpu->energy = xbt_new(s_energy_cpu_cas01_t, 1);
62   cpu->energy->total_energy = 0;
63   cpu->energy->power_range_watts_list = cpu_get_watts_range_list(cpu);
64   cpu->energy->last_updated = surf_get_clock();
65
66   XBT_DEBUG("CPU create: peak=%lf, pstate=%d",cpu->power_peak, cpu->pstate);
67
68   xbt_assert(cpu->power_peak > 0, "Power has to be >0");
69   cpu->power_scale = power_scale;
70   cpu->core = core;
71   xbt_assert(core > 0, "Invalid number of cores %d", core);
72
73   if (power_trace)
74     cpu->power_event =
75         tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
76
77   cpu->state_current = state_initial;
78   if (state_trace)
79     cpu->state_event =
80         tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
81
82   cpu->constraint =
83       lmm_constraint_new(surf_cpu_model->model_private->maxmin_system, cpu,
84                          cpu->core * cpu->power_scale * cpu->power_peak);
85
86   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
87
88   return xbt_lib_get_elm_or_null(host_lib, name);;
89 }
90
91
92 static void parse_cpu_init(sg_platf_host_cbarg_t host)
93 {
94   cpu_create_resource(host->id,
95                       host->power_peak,
96                       host->pstate,
97                       host->power_scale,
98                       host->power_trace,
99                       host->core_amount,
100                       host->initial_state,
101                       host->state_trace, host->properties);
102 }
103
104 static void cpu_add_traces_cpu(void)
105 {
106   xbt_dict_cursor_t cursor = NULL;
107   char *trace_name, *elm;
108   static int called = 0;
109   if (called)
110     return;
111   called = 1;
112
113   /* connect all traces relative to hosts */
114   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
115     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
116     cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
117
118     xbt_assert(host, "Host %s undefined", elm);
119     xbt_assert(trace, "Trace %s undefined", trace_name);
120
121     host->state_event =
122         tmgr_history_add_trace(history, trace, 0.0, 0, host);
123   }
124
125   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
126     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
127     cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
128
129     xbt_assert(host, "Host %s undefined", elm);
130     xbt_assert(trace, "Trace %s undefined", trace_name);
131
132     host->power_event =
133         tmgr_history_add_trace(history, trace, 0.0, 0, host);
134   }
135 }
136
137 static void cpu_define_callbacks()
138 {
139   sg_platf_host_add_cb(parse_cpu_init);
140   sg_platf_postparse_add_cb(cpu_add_traces_cpu);
141 }
142
143 static int cpu_resource_used(void *resource)
144 {
145   return lmm_constraint_used(surf_cpu_model->model_private->maxmin_system,
146                              ((cpu_Cas01_t) resource)->constraint);
147 }
148
149 static double cpu_share_resources_lazy(double now)
150 {
151   return generic_share_resources_lazy(now, surf_cpu_model);
152 }
153
154 static double cpu_share_resources_full(double now)
155 {
156   s_surf_action_cpu_Cas01_t action;
157   return generic_maxmin_share_resources(surf_cpu_model->states.
158                                         running_action_set,
159                                         xbt_swag_offset(action,
160                                                         generic_lmm_action.
161                                                         variable),
162                                         surf_cpu_model->model_private->maxmin_system, lmm_solve);
163 }
164
165 static void cpu_update_actions_state_lazy(double now, double delta)
166 {
167   generic_update_actions_state_lazy(now, delta, surf_cpu_model);
168 }
169
170 static void cpu_update_actions_state_full(double now, double delta)
171 {
172   generic_update_actions_state_full(now, delta, surf_cpu_model);
173 }
174
175 xbt_dynar_t cpu_get_watts_range_list(cpu_Cas01_t cpu_model)
176 {
177         xbt_dynar_t power_range_list = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
178         xbt_dynar_t power_tuple;
179         int i = 0, pstate_nb=0;
180         xbt_dynar_t current_power_values;
181         double min_power, max_power;
182         xbt_dict_t props = cpu_model->generic_resource.properties;
183
184         if (props == NULL)
185                 return NULL;
186
187         char* all_power_values_str = xbt_dict_get_or_null(props, "power_per_state");
188
189         if (all_power_values_str == NULL)
190                 return NULL;
191
192         xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
193
194         pstate_nb = xbt_dynar_length(all_power_values);
195         for (i=0; i< pstate_nb; i++)
196         {
197                 /* retrieve the power values associated with the current pstate */
198                 current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
199                 xbt_assert(xbt_dynar_length(current_power_values) > 1,
200                                 "Power properties incorrectly defined - could not retrieve min and max power values for host %s",
201                                 cpu_model->generic_resource.name);
202
203                 /* min_power corresponds to the idle power (cpu load = 0) */
204                 /* max_power is the power consumed at 100% cpu load       */
205                 min_power = atof(xbt_dynar_get_as(current_power_values, 0, char*));
206                 max_power = atof(xbt_dynar_get_as(current_power_values, 1, char*));
207
208                 power_tuple = xbt_dynar_new(sizeof(double), NULL);
209                 xbt_dynar_push_as(power_tuple, double, min_power);
210                 xbt_dynar_push_as(power_tuple, double, max_power);
211
212                 xbt_dynar_push_as(power_range_list, xbt_dynar_t, power_tuple);
213         }
214
215         return power_range_list;
216
217 }
218
219 /**
220  * Computes the power consumed by the host according to the current pstate and processor load
221  *
222  */
223 static double cpu_get_current_watts_value(cpu_Cas01_t cpu_model, double cpu_load)
224 {
225         xbt_dynar_t power_range_list = cpu_model->energy->power_range_watts_list;
226
227         if (power_range_list == NULL)
228         {
229                 XBT_DEBUG("No power range properties specified for host %s", cpu_model->generic_resource.name);
230                 return 0;
231         }
232         xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(cpu_model->power_peak_list),
233                                                 "The number of power ranges in the properties does not match the number of pstates for host %s",
234                                                 cpu_model->generic_resource.name);
235
236     /* retrieve the power values associated with the current pstate */
237     xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, cpu_model->pstate, xbt_dynar_t);
238
239     /* min_power corresponds to the idle power (cpu load = 0) */
240     /* max_power is the power consumed at 100% cpu load       */
241     double min_power = xbt_dynar_get_as(current_power_values, 0, double);
242     double max_power = xbt_dynar_get_as(current_power_values, 1, double);
243     double power_slope = max_power - min_power;
244
245     double current_power = min_power + cpu_load * power_slope;
246
247         XBT_DEBUG("[get_current_watts] min_power=%lf, max_power=%lf, slope=%lf", min_power, max_power, power_slope);
248     XBT_DEBUG("[get_current_watts] Current power (watts) = %lf, load = %lf", current_power, cpu_load);
249
250         return current_power;
251
252 }
253
254 /**
255  * Updates the total energy consumed as the sum of the current energy and
256  *                                               the energy consumed by the current action
257  */
258 void cpu_update_energy(cpu_Cas01_t cpu_model, double cpu_load)
259 {
260
261   double start_time = cpu_model->energy->last_updated;
262   double finish_time = surf_get_clock();
263
264   XBT_DEBUG("[cpu_update_energy] action time interval=(%lf-%lf), current power peak=%lf, current pstate=%d",
265                   start_time, finish_time, cpu_model->power_peak, cpu_model->pstate);
266   double current_energy = cpu_model->energy->total_energy;
267   double action_energy = cpu_get_current_watts_value(cpu_model, cpu_load)*(finish_time-start_time);
268
269   cpu_model->energy->total_energy = current_energy + action_energy;
270   cpu_model->energy->last_updated = finish_time;
271
272   XBT_DEBUG("[cpu_update_energy] old_energy_value=%lf, action_energy_value=%lf", current_energy, action_energy);
273
274 }
275
276 static void cpu_update_resource_state(void *id,
277                                       tmgr_trace_event_t event_type,
278                                       double value, double date)
279 {
280   cpu_Cas01_t cpu = id;
281   lmm_variable_t var = NULL;
282   lmm_element_t elem = NULL;
283
284   if (event_type == cpu->power_event) {
285     cpu->power_scale = value;
286     lmm_update_constraint_bound(surf_cpu_model->model_private->maxmin_system, cpu->constraint,
287                                 cpu->core * cpu->power_scale *
288                                 cpu->power_peak);
289 #ifdef HAVE_TRACING
290     TRACE_surf_host_set_power(date, cpu->generic_resource.name,
291                               cpu->core * cpu->power_scale *
292                               cpu->power_peak);
293 #endif
294     while ((var = lmm_get_var_from_cnst
295             (surf_cpu_model->model_private->maxmin_system, cpu->constraint, &elem))) {
296       surf_action_cpu_Cas01_t action = lmm_variable_id(var);
297       lmm_update_variable_bound(surf_cpu_model->model_private->maxmin_system,
298                                 GENERIC_LMM_ACTION(action).variable,
299                                 cpu->power_scale * cpu->power_peak);
300     }
301     if (tmgr_trace_event_free(event_type))
302       cpu->power_event = NULL;
303   } else if (event_type == cpu->state_event) {
304     if (value > 0) {
305       if(cpu->state_current == SURF_RESOURCE_OFF)
306         xbt_dynar_push_as(host_that_restart, char*, (cpu->generic_resource.name));
307       cpu->state_current = SURF_RESOURCE_ON;
308     } else {
309       lmm_constraint_t cnst = cpu->constraint;
310
311       cpu->state_current = SURF_RESOURCE_OFF;
312
313       while ((var = lmm_get_var_from_cnst(surf_cpu_model->model_private->maxmin_system, cnst, &elem))) {
314         surf_action_t action = lmm_variable_id(var);
315
316         if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
317             surf_action_state_get(action) == SURF_ACTION_READY ||
318             surf_action_state_get(action) ==
319             SURF_ACTION_NOT_IN_THE_SYSTEM) {
320           action->finish = date;
321           surf_action_state_set(action, SURF_ACTION_FAILED);
322         }
323       }
324     }
325     if (tmgr_trace_event_free(event_type))
326       cpu->state_event = NULL;
327   } else {
328     XBT_CRITICAL("Unknown event ! \n");
329     xbt_abort();
330   }
331
332   return;
333 }
334
335 static surf_action_t cpu_execute(void *cpu, double size)
336 {
337   surf_action_cpu_Cas01_t action = NULL;
338   //xbt_dict_cursor_t cursor = NULL;
339   cpu_Cas01_t CPU = surf_cpu_resource_priv(cpu);
340   //xbt_dict_t props = CPU->generic_resource.properties;
341
342   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
343   action =
344       surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size,
345                       surf_cpu_model,
346                       CPU->state_current != SURF_RESOURCE_ON);
347
348   GENERIC_LMM_ACTION(action).suspended = 0;     /* Should be useless because of the
349                                                    calloc but it seems to help valgrind... */
350
351   GENERIC_LMM_ACTION(action).variable =
352       lmm_variable_new(surf_cpu_model->model_private->maxmin_system, action,
353                        GENERIC_ACTION(action).priority,
354                        CPU->power_scale * CPU->power_peak, 1);
355   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
356     GENERIC_LMM_ACTION(action).index_heap = -1;
357     GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
358     GENERIC_LMM_ACTION(action).last_value = 0.0;
359   }
360
361   lmm_expand(surf_cpu_model->model_private->maxmin_system, CPU->constraint,
362              GENERIC_LMM_ACTION(action).variable, 1.0);
363   XBT_OUT();
364   return (surf_action_t) action;
365 }
366
367 static surf_action_t cpu_action_sleep(void *cpu, double duration)
368 {
369   surf_action_cpu_Cas01_t action = NULL;
370
371   if (duration > 0)
372     duration = MAX(duration, MAXMIN_PRECISION);
373
374   XBT_IN("(%s,%g)", surf_resource_name(surf_cpu_resource_priv(cpu)), duration);
375   action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
376   // FIXME: sleep variables should not consume 1.0 in lmm_expand
377   GENERIC_ACTION(action).max_duration = duration;
378   GENERIC_LMM_ACTION(action).suspended = 2;
379   if (duration == NO_MAX_DURATION) {
380     /* Move to the *end* of the corresponding action set. This convention
381        is used to speed up update_resource_state  */
382     xbt_swag_remove(action, ((surf_action_t) action)->state_set);
383     ((surf_action_t) action)->state_set =
384         cpu_running_action_set_that_does_not_need_being_checked;
385     xbt_swag_insert(action, ((surf_action_t) action)->state_set);
386   }
387
388   lmm_update_variable_weight(surf_cpu_model->model_private->maxmin_system,
389                              GENERIC_LMM_ACTION(action).variable, 0.0);
390   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {     // remove action from the heap
391     surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
392     // this is necessary for a variable with weight 0 since such
393     // variables are ignored in lmm and we need to set its max_duration
394     // correctly at the next call to share_resources
395     xbt_swag_insert_at_head(action,surf_cpu_model->model_private->modified_set);
396   }
397
398   XBT_OUT();
399   return (surf_action_t) action;
400 }
401
402 static e_surf_resource_state_t cpu_get_state(void *cpu)
403 {
404   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->state_current;
405 }
406
407 static double cpu_get_speed(void *cpu, double load)
408 {
409   return load * ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak;
410 }
411
412 static int cpu_get_core(void *cpu)
413 {
414   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->core;
415 }
416
417
418 static double cpu_get_available_speed(void *cpu)
419 {
420   /* number between 0 and 1 */
421   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_scale;
422 }
423
424 static double cpu_get_current_power_peak(void *cpu)
425 {
426   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak;
427 }
428
429 static double cpu_get_power_peak_at(void *cpu, int pstate_index)
430 {
431   xbt_dynar_t plist = ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak_list;
432   xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
433
434   return xbt_dynar_get_as(plist, pstate_index, double);
435 }
436
437 static int cpu_get_nb_pstates(void *cpu)
438 {
439   return xbt_dynar_length(((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak_list);
440 }
441
442 static void cpu_set_power_peak_at(void *cpu, int pstate_index)
443 {
444   cpu_Cas01_t cpu_implem = (cpu_Cas01_t)surf_cpu_resource_priv(cpu);
445   xbt_dynar_t plist = cpu_implem->power_peak_list;
446   xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
447
448   double new_power_peak = xbt_dynar_get_as(plist, pstate_index, double);
449   cpu_implem->pstate = pstate_index;
450   cpu_implem->power_peak = new_power_peak;
451 }
452
453 static double cpu_get_consumed_energy(void *cpu)
454 {
455   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->energy->total_energy;
456 }
457
458 static void cpu_finalize(void)
459 {
460   lmm_system_free(surf_cpu_model->model_private->maxmin_system);
461   surf_cpu_model->model_private->maxmin_system = NULL;
462
463   if (surf_cpu_model->model_private->action_heap)
464     xbt_heap_free(surf_cpu_model->model_private->action_heap);
465   xbt_swag_free(surf_cpu_model->model_private->modified_set);
466
467   surf_model_exit(surf_cpu_model);
468   surf_cpu_model = NULL;
469
470   xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
471   cpu_running_action_set_that_does_not_need_being_checked = NULL;
472 }
473
474 static void surf_cpu_model_init_internal()
475 {
476   s_surf_action_t action;
477   s_surf_action_cpu_Cas01_t comp;
478
479   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
480   int select =
481       xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update");
482
483   surf_cpu_model = surf_model_init();
484
485   if (!strcmp(optim, "Full")) {
486     surf_cpu_model->model_private->update_mechanism = UM_FULL;
487     surf_cpu_model->model_private->selective_update = select;
488   } else if (!strcmp(optim, "Lazy")) {
489     surf_cpu_model->model_private->update_mechanism = UM_LAZY;
490     surf_cpu_model->model_private->selective_update = 1;
491     xbt_assert((select == 1)
492                ||
493                (xbt_cfg_is_default_value
494                 (_sg_cfg_set, "cpu/maxmin_selective_update")),
495                "Disabling selective update while using the lazy update mechanism is dumb!");
496   } else {
497     xbt_die("Unsupported optimization (%s) for this model", optim);
498   }
499
500   cpu_running_action_set_that_does_not_need_being_checked =
501       xbt_swag_new(xbt_swag_offset(action, state_hookup));
502
503   surf_cpu_model->name = "cpu";
504
505   surf_cpu_model->action_unref = surf_action_unref;
506   surf_cpu_model->action_cancel = surf_action_cancel;
507   surf_cpu_model->action_state_set = surf_action_state_set;
508
509   surf_cpu_model->model_private->resource_used = cpu_resource_used;
510
511   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
512     surf_cpu_model->model_private->share_resources =
513         cpu_share_resources_lazy;
514     surf_cpu_model->model_private->update_actions_state =
515         cpu_update_actions_state_lazy;
516   } else if (surf_cpu_model->model_private->update_mechanism == UM_FULL) {
517     surf_cpu_model->model_private->share_resources =
518         cpu_share_resources_full;
519     surf_cpu_model->model_private->update_actions_state =
520         cpu_update_actions_state_full;
521   } else
522     xbt_die("Invalid cpu update mechanism!");
523
524   surf_cpu_model->model_private->update_resource_state =
525       cpu_update_resource_state;
526   surf_cpu_model->model_private->finalize = cpu_finalize;
527
528   surf_cpu_model->suspend = surf_action_suspend;
529   surf_cpu_model->resume = surf_action_resume;
530   surf_cpu_model->is_suspended = surf_action_is_suspended;
531   surf_cpu_model->set_max_duration = surf_action_set_max_duration;
532   surf_cpu_model->set_priority = surf_action_set_priority;
533 #ifdef HAVE_TRACING
534   surf_cpu_model->set_category = surf_action_set_category;
535 #endif
536   surf_cpu_model->get_remains = surf_action_get_remains;
537
538   surf_cpu_model->extension.cpu.execute = cpu_execute;
539   surf_cpu_model->extension.cpu.sleep = cpu_action_sleep;
540
541   surf_cpu_model->extension.cpu.get_state = cpu_get_state;
542   surf_cpu_model->extension.cpu.get_core = cpu_get_core;
543   surf_cpu_model->extension.cpu.get_speed = cpu_get_speed;
544   surf_cpu_model->extension.cpu.get_available_speed =
545       cpu_get_available_speed;
546   surf_cpu_model->extension.cpu.get_current_power_peak = cpu_get_current_power_peak;
547   surf_cpu_model->extension.cpu.get_power_peak_at = cpu_get_power_peak_at;
548   surf_cpu_model->extension.cpu.get_nb_pstates = cpu_get_nb_pstates;
549   surf_cpu_model->extension.cpu.set_power_peak_at = cpu_set_power_peak_at;
550   surf_cpu_model->extension.cpu.get_consumed_energy = cpu_get_consumed_energy;
551
552   surf_cpu_model->extension.cpu.add_traces = cpu_add_traces_cpu;
553
554   if (!surf_cpu_model->model_private->maxmin_system) {
555     surf_cpu_model->model_private->maxmin_system = lmm_system_new(surf_cpu_model->model_private->selective_update);
556   }
557   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
558     surf_cpu_model->model_private->action_heap = xbt_heap_new(8, NULL);
559     xbt_heap_set_update_callback(surf_cpu_model->model_private->action_heap,
560         surf_action_lmm_update_index_heap);
561     surf_cpu_model->model_private->modified_set =
562         xbt_swag_new(xbt_swag_offset(comp, generic_lmm_action.action_list_hookup));
563     surf_cpu_model->model_private->maxmin_system->keep_track = surf_cpu_model->model_private->modified_set;
564   }
565 }
566
567 /*********************************************************************/
568 /* Basic sharing model for CPU: that is where all this started... ;) */
569 /*********************************************************************/
570 /* @InProceedings{casanova01simgrid, */
571 /*   author =       "H. Casanova", */
572 /*   booktitle =    "Proceedings of the IEEE Symposium on Cluster Computing */
573 /*                  and the Grid (CCGrid'01)", */
574 /*   publisher =    "IEEE Computer Society", */
575 /*   title =        "Simgrid: {A} Toolkit for the Simulation of Application */
576 /*                  Scheduling", */
577 /*   year =         "2001", */
578 /*   month =        may, */
579 /*   note =         "Available at */
580 /*                  \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
581 /* } */
582
583 void surf_cpu_model_init_Cas01()
584 {
585   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
586
587   if (surf_cpu_model)
588     return;
589
590   if (!strcmp(optim, "TI")) {
591     surf_cpu_model_init_ti();
592     return;
593   }
594
595   surf_cpu_model_init_internal();
596   cpu_define_callbacks();
597   xbt_dynar_push(model_list, &surf_cpu_model);
598 }