Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
model-checker : parallel system state comparison for safety MC
[simgrid.git] / src / surf / cpu_cas01.c
1 /* Copyright (c) 2009-2013. 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_cas01_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_cas01_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;
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
193         power_range_list = xbt_dynar_new(sizeof(xbt_dynar_t), NULL);
194         xbt_dynar_t all_power_values = xbt_str_split(all_power_values_str, ",");
195
196         pstate_nb = xbt_dynar_length(all_power_values);
197         for (i=0; i< pstate_nb; i++)
198         {
199                 /* retrieve the power values associated with the current pstate */
200                 current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
201                 xbt_assert(xbt_dynar_length(current_power_values) > 1,
202                                 "Power properties incorrectly defined - could not retrieve min and max power values for host %s",
203                                 cpu_model->generic_resource.name);
204
205                 /* min_power corresponds to the idle power (cpu load = 0) */
206                 /* max_power is the power consumed at 100% cpu load       */
207                 min_power = atof(xbt_dynar_get_as(current_power_values, 0, char*));
208                 max_power = atof(xbt_dynar_get_as(current_power_values, 1, char*));
209
210                 power_tuple = xbt_dynar_new(sizeof(double), NULL);
211                 xbt_dynar_push_as(power_tuple, double, min_power);
212                 xbt_dynar_push_as(power_tuple, double, max_power);
213
214                 xbt_dynar_push_as(power_range_list, xbt_dynar_t, power_tuple);
215                 xbt_dynar_free(&current_power_values);
216         }
217         xbt_dynar_free(&all_power_values);
218         return power_range_list;
219
220 }
221
222 /**
223  * Computes the power consumed by the host according to the current pstate and processor load
224  *
225  */
226 static double cpu_get_current_watts_value(cpu_Cas01_t cpu_model, double cpu_load)
227 {
228         xbt_dynar_t power_range_list = cpu_model->energy->power_range_watts_list;
229
230         if (power_range_list == NULL)
231         {
232                 XBT_DEBUG("No power range properties specified for host %s", cpu_model->generic_resource.name);
233                 return 0;
234         }
235         xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(cpu_model->power_peak_list),
236                                                 "The number of power ranges in the properties does not match the number of pstates for host %s",
237                                                 cpu_model->generic_resource.name);
238
239     /* retrieve the power values associated with the current pstate */
240     xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, cpu_model->pstate, xbt_dynar_t);
241
242     /* min_power corresponds to the idle power (cpu load = 0) */
243     /* max_power is the power consumed at 100% cpu load       */
244     double min_power = xbt_dynar_get_as(current_power_values, 0, double);
245     double max_power = xbt_dynar_get_as(current_power_values, 1, double);
246     double power_slope = max_power - min_power;
247
248     double current_power = min_power + cpu_load * power_slope;
249
250         XBT_DEBUG("[get_current_watts] min_power=%lf, max_power=%lf, slope=%lf", min_power, max_power, power_slope);
251     XBT_DEBUG("[get_current_watts] Current power (watts) = %lf, load = %lf", current_power, cpu_load);
252
253         return current_power;
254
255 }
256
257 /**
258  * Updates the total energy consumed as the sum of the current energy and
259  *                                               the energy consumed by the current action
260  */
261 void cpu_update_energy(cpu_Cas01_t cpu_model, double cpu_load)
262 {
263
264   double start_time = cpu_model->energy->last_updated;
265   double finish_time = surf_get_clock();
266
267   XBT_DEBUG("[cpu_update_energy] action time interval=(%lf-%lf), current power peak=%lf, current pstate=%d",
268                   start_time, finish_time, cpu_model->power_peak, cpu_model->pstate);
269   double current_energy = cpu_model->energy->total_energy;
270   double action_energy = cpu_get_current_watts_value(cpu_model, cpu_load)*(finish_time-start_time);
271
272   cpu_model->energy->total_energy = current_energy + action_energy;
273   cpu_model->energy->last_updated = finish_time;
274
275   XBT_DEBUG("[cpu_update_energy] old_energy_value=%lf, action_energy_value=%lf", current_energy, action_energy);
276
277 }
278
279 static void cpu_update_resource_state(void *id,
280                                       tmgr_trace_event_t event_type,
281                                       double value, double date)
282 {
283   cpu_Cas01_t cpu = id;
284   lmm_variable_t var = NULL;
285   lmm_element_t elem = NULL;
286
287   if (event_type == cpu->power_event) {
288     cpu->power_scale = value;
289     lmm_update_constraint_bound(surf_cpu_model->model_private->maxmin_system, cpu->constraint,
290                                 cpu->core * cpu->power_scale *
291                                 cpu->power_peak);
292 #ifdef HAVE_TRACING
293     TRACE_surf_host_set_power(date, cpu->generic_resource.name,
294                               cpu->core * cpu->power_scale *
295                               cpu->power_peak);
296 #endif
297     while ((var = lmm_get_var_from_cnst
298             (surf_cpu_model->model_private->maxmin_system, cpu->constraint, &elem))) {
299       surf_action_cpu_Cas01_t action = lmm_variable_id(var);
300       lmm_update_variable_bound(surf_cpu_model->model_private->maxmin_system,
301                                 GENERIC_LMM_ACTION(action).variable,
302                                 cpu->power_scale * cpu->power_peak);
303     }
304     if (tmgr_trace_event_free(event_type))
305       cpu->power_event = NULL;
306   } else if (event_type == cpu->state_event) {
307     if (value > 0) {
308       if(cpu->state_current == SURF_RESOURCE_OFF)
309         xbt_dynar_push_as(host_that_restart, char*, (cpu->generic_resource.name));
310       cpu->state_current = SURF_RESOURCE_ON;
311     } else {
312       lmm_constraint_t cnst = cpu->constraint;
313
314       cpu->state_current = SURF_RESOURCE_OFF;
315
316       while ((var = lmm_get_var_from_cnst(surf_cpu_model->model_private->maxmin_system, cnst, &elem))) {
317         surf_action_t action = lmm_variable_id(var);
318
319         if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
320             surf_action_state_get(action) == SURF_ACTION_READY ||
321             surf_action_state_get(action) ==
322             SURF_ACTION_NOT_IN_THE_SYSTEM) {
323           action->finish = date;
324           surf_action_state_set(action, SURF_ACTION_FAILED);
325         }
326       }
327     }
328     if (tmgr_trace_event_free(event_type))
329       cpu->state_event = NULL;
330   } else {
331     XBT_CRITICAL("Unknown event ! \n");
332     xbt_abort();
333   }
334
335   return;
336 }
337
338 static surf_action_t cpu_execute(void *cpu, double size)
339 {
340   surf_action_cpu_Cas01_t action = NULL;
341   //xbt_dict_cursor_t cursor = NULL;
342   cpu_Cas01_t CPU = surf_cpu_resource_priv(cpu);
343   //xbt_dict_t props = CPU->generic_resource.properties;
344
345   XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
346   action =
347       surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size,
348                       surf_cpu_model,
349                       CPU->state_current != SURF_RESOURCE_ON);
350
351   GENERIC_LMM_ACTION(action).suspended = 0;     /* Should be useless because of the
352                                                    calloc but it seems to help valgrind... */
353
354   GENERIC_LMM_ACTION(action).variable =
355       lmm_variable_new(surf_cpu_model->model_private->maxmin_system, action,
356                        GENERIC_ACTION(action).priority,
357                        CPU->power_scale * CPU->power_peak, 1);
358   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
359     GENERIC_LMM_ACTION(action).index_heap = -1;
360     GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
361     GENERIC_LMM_ACTION(action).last_value = 0.0;
362   }
363
364   lmm_expand(surf_cpu_model->model_private->maxmin_system, CPU->constraint,
365              GENERIC_LMM_ACTION(action).variable, 1.0);
366   XBT_OUT();
367   return (surf_action_t) action;
368 }
369
370 static surf_action_t cpu_action_sleep(void *cpu, double duration)
371 {
372   surf_action_cpu_Cas01_t action = NULL;
373
374   if (duration > 0)
375     duration = MAX(duration, MAXMIN_PRECISION);
376
377   XBT_IN("(%s,%g)", surf_resource_name(surf_cpu_resource_priv(cpu)), duration);
378   action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
379   // FIXME: sleep variables should not consume 1.0 in lmm_expand
380   GENERIC_ACTION(action).max_duration = duration;
381   GENERIC_LMM_ACTION(action).suspended = 2;
382   if (duration == NO_MAX_DURATION) {
383     /* Move to the *end* of the corresponding action set. This convention
384        is used to speed up update_resource_state  */
385     xbt_swag_remove(action, ((surf_action_t) action)->state_set);
386     ((surf_action_t) action)->state_set =
387         cpu_running_action_set_that_does_not_need_being_checked;
388     xbt_swag_insert(action, ((surf_action_t) action)->state_set);
389   }
390
391   lmm_update_variable_weight(surf_cpu_model->model_private->maxmin_system,
392                              GENERIC_LMM_ACTION(action).variable, 0.0);
393   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {     // remove action from the heap
394     surf_action_lmm_heap_remove(surf_cpu_model->model_private->action_heap,(surf_action_lmm_t)action);
395     // this is necessary for a variable with weight 0 since such
396     // variables are ignored in lmm and we need to set its max_duration
397     // correctly at the next call to share_resources
398     xbt_swag_insert_at_head(action,surf_cpu_model->model_private->modified_set);
399   }
400
401   XBT_OUT();
402   return (surf_action_t) action;
403 }
404
405 static e_surf_resource_state_t cpu_get_state(void *cpu)
406 {
407   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->state_current;
408 }
409
410 static double cpu_get_speed(void *cpu, double load)
411 {
412   return load * ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak;
413 }
414
415 static int cpu_get_core(void *cpu)
416 {
417   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->core;
418 }
419
420
421 static double cpu_get_available_speed(void *cpu)
422 {
423   /* number between 0 and 1 */
424   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_scale;
425 }
426
427 static double cpu_get_current_power_peak(void *cpu)
428 {
429   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak;
430 }
431
432 static double cpu_get_power_peak_at(void *cpu, int pstate_index)
433 {
434   xbt_dynar_t plist = ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak_list;
435   xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
436
437   return xbt_dynar_get_as(plist, pstate_index, double);
438 }
439
440 static int cpu_get_nb_pstates(void *cpu)
441 {
442   return xbt_dynar_length(((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_peak_list);
443 }
444
445 static void cpu_set_power_peak_at(void *cpu, int pstate_index)
446 {
447   cpu_Cas01_t cpu_implem = (cpu_Cas01_t)surf_cpu_resource_priv(cpu);
448   xbt_dynar_t plist = cpu_implem->power_peak_list;
449   xbt_assert((pstate_index <= xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
450
451   double new_power_peak = xbt_dynar_get_as(plist, pstate_index, double);
452   cpu_implem->pstate = pstate_index;
453   cpu_implem->power_peak = new_power_peak;
454 }
455
456 static double cpu_get_consumed_energy(void *cpu)
457 {
458   return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->energy->total_energy;
459 }
460
461 static void cpu_finalize(void)
462 {
463   lmm_system_free(surf_cpu_model->model_private->maxmin_system);
464   surf_cpu_model->model_private->maxmin_system = NULL;
465
466   if (surf_cpu_model->model_private->action_heap)
467     xbt_heap_free(surf_cpu_model->model_private->action_heap);
468   xbt_swag_free(surf_cpu_model->model_private->modified_set);
469
470   surf_model_exit(surf_cpu_model);
471   surf_cpu_model = NULL;
472
473   xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
474   cpu_running_action_set_that_does_not_need_being_checked = NULL;
475 }
476
477 static void surf_cpu_model_init_internal()
478 {
479   s_surf_action_t action;
480   s_surf_action_cpu_Cas01_t comp;
481
482   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
483   int select =
484       xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update");
485
486   surf_cpu_model = surf_model_init();
487
488   if (!strcmp(optim, "Full")) {
489     surf_cpu_model->model_private->update_mechanism = UM_FULL;
490     surf_cpu_model->model_private->selective_update = select;
491   } else if (!strcmp(optim, "Lazy")) {
492     surf_cpu_model->model_private->update_mechanism = UM_LAZY;
493     surf_cpu_model->model_private->selective_update = 1;
494     xbt_assert((select == 1)
495                ||
496                (xbt_cfg_is_default_value
497                 (_sg_cfg_set, "cpu/maxmin_selective_update")),
498                "Disabling selective update while using the lazy update mechanism is dumb!");
499   } else {
500     xbt_die("Unsupported optimization (%s) for this model", optim);
501   }
502
503   cpu_running_action_set_that_does_not_need_being_checked =
504       xbt_swag_new(xbt_swag_offset(action, state_hookup));
505
506   surf_cpu_model->name = "cpu";
507
508   surf_cpu_model->action_unref = surf_action_unref;
509   surf_cpu_model->action_cancel = surf_action_cancel;
510   surf_cpu_model->action_state_set = surf_action_state_set;
511
512   surf_cpu_model->model_private->resource_used = cpu_resource_used;
513
514   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
515     surf_cpu_model->model_private->share_resources =
516         cpu_share_resources_lazy;
517     surf_cpu_model->model_private->update_actions_state =
518         cpu_update_actions_state_lazy;
519   } else if (surf_cpu_model->model_private->update_mechanism == UM_FULL) {
520     surf_cpu_model->model_private->share_resources =
521         cpu_share_resources_full;
522     surf_cpu_model->model_private->update_actions_state =
523         cpu_update_actions_state_full;
524   } else
525     xbt_die("Invalid cpu update mechanism!");
526
527   surf_cpu_model->model_private->update_resource_state =
528       cpu_update_resource_state;
529   surf_cpu_model->model_private->finalize = cpu_finalize;
530
531   surf_cpu_model->suspend = surf_action_suspend;
532   surf_cpu_model->resume = surf_action_resume;
533   surf_cpu_model->is_suspended = surf_action_is_suspended;
534   surf_cpu_model->set_max_duration = surf_action_set_max_duration;
535   surf_cpu_model->set_priority = surf_action_set_priority;
536 #ifdef HAVE_TRACING
537   surf_cpu_model->set_category = surf_action_set_category;
538 #endif
539   surf_cpu_model->get_remains = surf_action_get_remains;
540
541   surf_cpu_model->extension.cpu.execute = cpu_execute;
542   surf_cpu_model->extension.cpu.sleep = cpu_action_sleep;
543
544   surf_cpu_model->extension.cpu.get_state = cpu_get_state;
545   surf_cpu_model->extension.cpu.get_core = cpu_get_core;
546   surf_cpu_model->extension.cpu.get_speed = cpu_get_speed;
547   surf_cpu_model->extension.cpu.get_available_speed =
548       cpu_get_available_speed;
549   surf_cpu_model->extension.cpu.get_current_power_peak = cpu_get_current_power_peak;
550   surf_cpu_model->extension.cpu.get_power_peak_at = cpu_get_power_peak_at;
551   surf_cpu_model->extension.cpu.get_nb_pstates = cpu_get_nb_pstates;
552   surf_cpu_model->extension.cpu.set_power_peak_at = cpu_set_power_peak_at;
553   surf_cpu_model->extension.cpu.get_consumed_energy = cpu_get_consumed_energy;
554
555   surf_cpu_model->extension.cpu.add_traces = cpu_add_traces_cpu;
556
557   if (!surf_cpu_model->model_private->maxmin_system) {
558     surf_cpu_model->model_private->maxmin_system = lmm_system_new(surf_cpu_model->model_private->selective_update);
559   }
560   if (surf_cpu_model->model_private->update_mechanism == UM_LAZY) {
561     surf_cpu_model->model_private->action_heap = xbt_heap_new(8, NULL);
562     xbt_heap_set_update_callback(surf_cpu_model->model_private->action_heap,
563         surf_action_lmm_update_index_heap);
564     surf_cpu_model->model_private->modified_set =
565         xbt_swag_new(xbt_swag_offset(comp, generic_lmm_action.action_list_hookup));
566     surf_cpu_model->model_private->maxmin_system->keep_track = surf_cpu_model->model_private->modified_set;
567   }
568 }
569
570 /*********************************************************************/
571 /* Basic sharing model for CPU: that is where all this started... ;) */
572 /*********************************************************************/
573 /* @InProceedings{casanova01simgrid, */
574 /*   author =       "H. Casanova", */
575 /*   booktitle =    "Proceedings of the IEEE Symposium on Cluster Computing */
576 /*                  and the Grid (CCGrid'01)", */
577 /*   publisher =    "IEEE Computer Society", */
578 /*   title =        "Simgrid: {A} Toolkit for the Simulation of Application */
579 /*                  Scheduling", */
580 /*   year =         "2001", */
581 /*   month =        may, */
582 /*   note =         "Available at */
583 /*                  \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
584 /* } */
585
586 void surf_cpu_model_init_Cas01()
587 {
588   char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
589
590   if (surf_cpu_model)
591     return;
592
593   if (!strcmp(optim, "TI")) {
594     surf_cpu_model_init_ti();
595     return;
596   }
597
598   surf_cpu_model_init_internal();
599   cpu_define_callbacks();
600   xbt_dynar_push(model_list, &surf_cpu_model);
601 }