Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
proper use of the HAVE_TRACING variable defined by Cmake through -Dtracing=on
[simgrid.git] / src / surf / cpu_im.c
1 /*      $Id$     */
2
3 /* Copyright (c) 2004 Arnaud Legrand. All rights reserved.                  */
4
5 /* This program is free software; you can redistribute it and/or modify it
6  * under the terms of the license (GNU LGPL) which comes with this package. */
7
8 #include "surf_private.h"
9
10 #undef GENERIC_LMM_ACTION
11 #undef GENERIC_ACTION
12 #undef ACTION_GET_CPU
13 #define GENERIC_LMM_ACTION(action) action->generic_lmm_action
14 #define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
15 #define ACTION_GET_CPU(action) ((surf_action_cpu_Cas01_im_t) action)->cpu
16
17 typedef struct surf_action_cpu_cas01_im {
18   s_surf_action_lmm_t generic_lmm_action;
19   s_xbt_swag_hookup_t cpu_list_hookup;
20   int index_heap;
21   void *cpu;
22 } s_surf_action_cpu_Cas01_im_t, *surf_action_cpu_Cas01_im_t;
23
24 typedef struct cpu_Cas01_im {
25   s_surf_resource_t generic_resource;
26   s_xbt_swag_hookup_t modified_cpu_hookup;
27   double power_peak;
28   double power_scale;
29   tmgr_trace_event_t power_event;
30   e_surf_resource_state_t state_current;
31   tmgr_trace_event_t state_event;
32   lmm_constraint_t constraint;
33   xbt_swag_t action_set;
34   double last_update;
35 } s_cpu_Cas01_im_t, *cpu_Cas01_im_t;
36
37 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_im, surf,
38                                 "Logging specific to the SURF CPU IMPROVED module");
39
40
41 lmm_system_t cpu_im_maxmin_system = NULL;
42 static xbt_swag_t cpu_im_modified_cpu = NULL;
43 static xbt_heap_t cpu_im_action_heap = NULL;
44 extern int sg_maxmin_selective_update;
45
46
47 static xbt_swag_t cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
48
49 static cpu_Cas01_im_t cpu_im_new(char *name, double power_peak,
50                               double power_scale,
51                               tmgr_trace_t power_trace,
52                               e_surf_resource_state_t state_initial,
53                               tmgr_trace_t state_trace,
54                               xbt_dict_t cpu_properties)
55 {
56 #ifdef HAVE_TRACING
57   TRACE_surf_cpu_new (name, power_scale * power_peak);
58 #endif
59
60   cpu_Cas01_im_t cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
61   s_surf_action_cpu_Cas01_im_t action;
62   xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
63               "Host '%s' declared several times in the platform file", name);
64   cpu->generic_resource.model = surf_cpu_model;
65   cpu->generic_resource.name = name;
66   cpu->generic_resource.properties = cpu_properties;
67   cpu->power_peak = power_peak;
68   xbt_assert0(cpu->power_peak > 0, "Power has to be >0");
69   cpu->power_scale = power_scale;
70   if (power_trace)
71     cpu->power_event =
72       tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
73
74   cpu->state_current = state_initial;
75   if (state_trace)
76     cpu->state_event =
77       tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
78
79   cpu->constraint =
80     lmm_constraint_new(cpu_im_maxmin_system, cpu,
81                        cpu->power_scale * cpu->power_peak);
82
83   xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
84                surf_resource_free);
85   cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
86
87   return cpu;
88 }
89
90
91 static void parse_cpu_im_init(void)
92 {
93   double power_peak = 0.0;
94   double power_scale = 0.0;
95   tmgr_trace_t power_trace = NULL;
96   e_surf_resource_state_t state_initial = SURF_RESOURCE_OFF;
97   tmgr_trace_t state_trace = NULL;
98
99   power_peak = get_cpu_power(A_surfxml_host_power);
100   surf_parse_get_double(&power_scale, A_surfxml_host_availability);
101   power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
102
103   xbt_assert0((A_surfxml_host_state == A_surfxml_host_state_ON) ||
104               (A_surfxml_host_state == A_surfxml_host_state_OFF),
105               "Invalid state");
106   if (A_surfxml_host_state == A_surfxml_host_state_ON)
107     state_initial = SURF_RESOURCE_ON;
108   if (A_surfxml_host_state == A_surfxml_host_state_OFF)
109     state_initial = SURF_RESOURCE_OFF;
110   state_trace = tmgr_trace_new(A_surfxml_host_state_file);
111
112   current_property_set = xbt_dict_new();
113   cpu_im_new(xbt_strdup(A_surfxml_host_id), power_peak, power_scale,
114           power_trace, state_initial, state_trace, current_property_set);
115
116 }
117
118 static void cpu_im_add_traces_cpu(void)
119 {
120   xbt_dict_cursor_t cursor = NULL;
121   char *trace_name, *elm;
122
123   static int called = 0;
124
125   if (called)
126     return;
127   called = 1;
128
129
130   /* connect all traces relative to hosts */
131   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
132     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
133     cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
134
135     xbt_assert1(host, "Host %s undefined", elm);
136     xbt_assert1(trace, "Trace %s undefined", trace_name);
137
138     host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
139   }
140
141   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
142     tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
143     cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
144
145     xbt_assert1(host, "Host %s undefined", elm);
146     xbt_assert1(trace, "Trace %s undefined", trace_name);
147
148     host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host);
149   }
150 }
151
152 static void cpu_im_define_callbacks(const char *file)
153 {
154   surf_parse_reset_parser();
155   surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_im_init);
156   surfxml_add_callback(ETag_surfxml_platform_cb_list, &cpu_im_add_traces_cpu);
157 }
158
159 static int cpu_im_resource_used(void *resource_id)
160 {
161   return lmm_constraint_used(cpu_im_maxmin_system,
162                              ((cpu_Cas01_im_t) resource_id)->constraint);
163 }
164
165 static int cpu_im_action_unref(surf_action_t action)
166 {
167   action->refcount--;
168   if (!action->refcount) {
169     xbt_swag_remove(action, action->state_set);
170     if (((surf_action_lmm_t) action)->variable)
171       lmm_variable_free(cpu_im_maxmin_system,
172                         ((surf_action_lmm_t) action)->variable);
173     /* remove from heap */
174     xbt_heap_remove(cpu_im_action_heap,
175                     ((surf_action_cpu_Cas01_im_t) action)->index_heap);
176     xbt_swag_remove(action,
177                     ((cpu_Cas01_im_t) ACTION_GET_CPU(action))->action_set);
178     xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
179     free(action);
180     return 1;
181   }
182   return 0;
183 }
184
185 static void cpu_im_action_cancel(surf_action_t action)
186 {
187   surf_action_state_set(action, SURF_ACTION_FAILED);
188   xbt_heap_remove(cpu_im_action_heap,
189                   ((surf_action_cpu_Cas01_im_t) action)->index_heap);
190   xbt_swag_remove(action,
191                   ((cpu_Cas01_im_t) ACTION_GET_CPU(action))->action_set);
192   return;
193 }
194
195 static void cpu_im_cpu_action_state_set(surf_action_t action,
196                                  e_surf_action_state_t state)
197 {
198 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
199 /*     if(((surf_action_lmm_t)action)->variable) { */
200 /*       lmm_variable_disable(cpu_im_maxmin_system, ((surf_action_lmm_t)action)->variable); */
201 /*       ((surf_action_lmm_t)action)->variable = NULL; */
202 /*     } */
203
204   surf_action_state_set(action, state);
205   return;
206 }
207
208 static void cpu_im_update_remains(cpu_Cas01_im_t cpu, double now)
209 {
210   surf_action_cpu_Cas01_im_t action;
211
212   if (cpu->last_update >= now)
213     return;
214   xbt_swag_foreach(action, cpu->action_set) {
215     if (GENERIC_ACTION(action).state_set !=
216         surf_cpu_model->states.running_action_set)
217       continue;
218
219     /* bogus priority, skip it */
220     if (GENERIC_ACTION(action).priority <= 0)
221       continue;
222
223     if (GENERIC_ACTION(action).remains > 0) {
224       double_update(&(GENERIC_ACTION(action).remains),
225                     lmm_variable_getvalue(GENERIC_LMM_ACTION
226                                           (action).variable) * (now -
227                                                                 cpu->last_update));
228 #ifdef HAVE_TRACING
229       TRACE_surf_update_action_state (action, action->generic_lmm_action.generic_action.data,
230           lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), "PowerUsed", cpu->last_update, now-cpu->last_update);
231       TRACE_surf_update_action_state_cpu_resource (cpu->generic_resource.name,
232                 action->generic_lmm_action.generic_action.data, lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), cpu->last_update, now-cpu->last_update);
233 #endif
234       DEBUG2("Update action(%p) remains %lf", action,
235              GENERIC_ACTION(action).remains);
236     }
237   }
238   cpu->last_update = now;
239 }
240
241 static double cpu_im_share_resources(double now)
242 {
243   surf_action_cpu_Cas01_im_t action;
244   double min;
245   double value;
246   cpu_Cas01_im_t cpu, cpu_next;
247
248   xbt_swag_foreach(cpu, cpu_im_modified_cpu)
249     cpu_im_update_remains(cpu, now);
250
251   lmm_solve(cpu_im_maxmin_system);
252
253   xbt_swag_foreach_safe(cpu, cpu_next, cpu_im_modified_cpu) {
254     xbt_swag_foreach(action, cpu->action_set) {
255       if (GENERIC_ACTION(action).state_set !=
256           surf_cpu_model->states.running_action_set)
257         continue;
258
259       /* bogus priority, skip it */
260       if (GENERIC_ACTION(action).priority <= 0)
261         continue;
262
263       min = -1;
264       value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
265       if (value > 0) {
266         if (GENERIC_ACTION(action).remains > 0)
267           value = GENERIC_ACTION(action).remains / value;
268         else
269           value = 0.0;
270       }
271       if (value > 0)
272         min = now + value;
273
274       if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
275           && (min == -1
276               || GENERIC_ACTION(action).start +
277               GENERIC_ACTION(action).max_duration < min))
278         min =
279           GENERIC_ACTION(action).start + GENERIC_ACTION(action).max_duration;
280
281       DEBUG4("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
282              GENERIC_ACTION(action).start, now + value,
283              GENERIC_ACTION(action).max_duration);
284
285       if (action->index_heap >= 0) {
286         surf_action_cpu_Cas01_im_t heap_act =
287           xbt_heap_remove(cpu_im_action_heap, action->index_heap);
288         if (heap_act != action)
289           DIE_IMPOSSIBLE;
290       }
291       if (min != -1) {
292         xbt_heap_push(cpu_im_action_heap, action, min);
293         DEBUG2("Insert at heap action(%p) min %lf", action, min);
294       }
295     }
296     xbt_swag_remove(cpu, cpu_im_modified_cpu);
297   }
298   return xbt_heap_size(cpu_im_action_heap) >
299     0 ? xbt_heap_maxkey(cpu_im_action_heap) - now : -1;
300 }
301
302 static void cpu_im_update_actions_state(double now, double delta)
303 {
304   surf_action_cpu_Cas01_im_t action;
305
306   while ((xbt_heap_size(cpu_im_action_heap) > 0)
307          && (double_equals(xbt_heap_maxkey(cpu_im_action_heap), now))) {
308     action = xbt_heap_pop(cpu_im_action_heap);
309     DEBUG1("Action %p: finish", action);
310     GENERIC_ACTION(action).finish = surf_get_clock();
311     /* set the remains to 0 due to precision problems when updating the remaining amount */
312 #ifdef HAVE_TRACING
313     TRACE_surf_update_action_state (action, action->generic_lmm_action.generic_action.data,
314         lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), "PowerUsed", ((cpu_Cas01_im_t)(action->cpu))->last_update, now - ((cpu_Cas01_im_t)(action->cpu))->last_update);
315     TRACE_surf_update_action_state_cpu_resource (((cpu_Cas01_im_t)(action->cpu))->generic_resource.name,
316               action->generic_lmm_action.generic_action.data, lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable), ((cpu_Cas01_im_t)(action->cpu))->last_update, now-((cpu_Cas01_im_t)(action->cpu))->last_update);
317 #endif
318     GENERIC_ACTION(action).remains = 0;
319     cpu_im_cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
320     cpu_im_update_remains(action->cpu, surf_get_clock());
321   }
322   return;
323 }
324
325 static void cpu_im_update_resource_state(void *id,
326                                   tmgr_trace_event_t event_type,
327                                   double value, double date)
328 {
329   cpu_Cas01_im_t cpu = id;
330
331   if (event_type == cpu->power_event) {
332     cpu->power_scale = value;
333     lmm_update_constraint_bound(cpu_im_maxmin_system, cpu->constraint,
334                                 cpu->power_scale * cpu->power_peak);
335 #ifdef HAVE_TRACING
336     TRACE_surf_cpu_set_power (date, cpu->generic_resource.name, cpu->power_scale * cpu->power_peak);
337 #endif
338     xbt_swag_insert(cpu, cpu_im_modified_cpu);
339     if (tmgr_trace_event_free(event_type))
340       cpu->power_event = NULL;
341   } else if (event_type == cpu->state_event) {
342     if (value > 0)
343       cpu->state_current = SURF_RESOURCE_ON;
344     else {
345       lmm_constraint_t cnst = cpu->constraint;
346       lmm_variable_t var = NULL;
347       lmm_element_t elem = NULL;
348
349       cpu->state_current = SURF_RESOURCE_OFF;
350
351       while ((var = lmm_get_var_from_cnst(cpu_im_maxmin_system, cnst, &elem))) {
352         surf_action_t action = lmm_variable_id(var);
353
354         if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
355             surf_action_state_get(action) == SURF_ACTION_READY ||
356             surf_action_state_get(action) == SURF_ACTION_NOT_IN_THE_SYSTEM) {
357           action->finish = date;
358           cpu_im_cpu_action_state_set(action, SURF_ACTION_FAILED);
359         }
360       }
361     }
362     if (tmgr_trace_event_free(event_type))
363       cpu->state_event = NULL;
364   } else {
365     CRITICAL0("Unknown event ! \n");
366     xbt_abort();
367   }
368
369   return;
370 }
371
372 static surf_action_t cpu_im_execute(void *cpu, double size)
373 {
374   surf_action_cpu_Cas01_im_t action = NULL;
375   cpu_Cas01_im_t CPU = cpu;
376
377   XBT_IN2("(%s,%g)", surf_resource_name(CPU), size);
378   action =
379     surf_action_new(sizeof(s_surf_action_cpu_Cas01_im_t), size,
380                     surf_cpu_model, CPU->state_current != SURF_RESOURCE_ON);
381
382   GENERIC_LMM_ACTION(action).suspended = 0;     /* Should be useless because of the
383                                                    calloc but it seems to help valgrind... */
384
385   GENERIC_LMM_ACTION(action).variable =
386     lmm_variable_new(cpu_im_maxmin_system, action,
387                      GENERIC_ACTION(action).priority, -1.0, 1);
388   action->index_heap = -1;
389   action->cpu = CPU;
390   xbt_swag_insert(CPU, cpu_im_modified_cpu);
391   xbt_swag_insert(action, CPU->action_set);
392   lmm_expand(cpu_im_maxmin_system, CPU->constraint,
393              GENERIC_LMM_ACTION(action).variable, 1.0);
394   XBT_OUT;
395   return (surf_action_t) action;
396 }
397
398 static surf_action_t cpu_im_action_sleep(void *cpu, double duration)
399 {
400   surf_action_cpu_Cas01_im_t action = NULL;
401
402   if (duration > 0)
403     duration = MAX(duration, MAXMIN_PRECISION);
404
405   XBT_IN2("(%s,%g)", surf_resource_name(cpu), duration);
406   action = (surf_action_cpu_Cas01_im_t) cpu_im_execute(cpu, 1.0);
407   GENERIC_ACTION(action).max_duration = duration;
408   GENERIC_LMM_ACTION(action).suspended = 2;
409   if (duration == NO_MAX_DURATION) {
410     /* Move to the *end* of the corresponding action set. This convention
411        is used to speed up update_resource_state  */
412     xbt_swag_remove(action, ((surf_action_t) action)->state_set);
413     ((surf_action_t) action)->state_set =
414       cpu_im_running_action_set_that_does_not_need_being_checked;
415     xbt_swag_insert(action, ((surf_action_t) action)->state_set);
416   }
417
418   lmm_update_variable_weight(cpu_im_maxmin_system,
419                              GENERIC_LMM_ACTION(action).variable, 0.0);
420   xbt_swag_insert(cpu, cpu_im_modified_cpu);
421   XBT_OUT;
422   return (surf_action_t) action;
423 }
424
425 static void cpu_im_action_suspend(surf_action_t action)
426 {
427   XBT_IN1("(%p)", action);
428   if (((surf_action_lmm_t) action)->suspended != 2) {
429     lmm_update_variable_weight(cpu_im_maxmin_system,
430                                ((surf_action_lmm_t) action)->variable, 0.0);
431     ((surf_action_lmm_t) action)->suspended = 1;
432     xbt_heap_remove(cpu_im_action_heap,
433                     ((surf_action_cpu_Cas01_im_t) action)->index_heap);
434     xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
435   }
436   XBT_OUT;
437 }
438
439 static void cpu_im_action_resume(surf_action_t action)
440 {
441   XBT_IN1("(%p)", action);
442   if (((surf_action_lmm_t) action)->suspended != 2) {
443     lmm_update_variable_weight(cpu_im_maxmin_system,
444                                ((surf_action_lmm_t) action)->variable,
445                                action->priority);
446     ((surf_action_lmm_t) action)->suspended = 0;
447     xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
448   }
449   XBT_OUT;
450 }
451
452 static int cpu_im_action_is_suspended(surf_action_t action)
453 {
454   return (((surf_action_lmm_t) action)->suspended == 1);
455 }
456
457 static void cpu_im_action_set_max_duration(surf_action_t action, double duration)
458 {
459   XBT_IN2("(%p,%g)", action, duration);
460
461   action->max_duration = duration;
462   /* insert cpu in modified_cpu set to notice the max duration change */
463   xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
464   XBT_OUT;
465 }
466
467 static void cpu_im_action_set_priority(surf_action_t action, double priority)
468 {
469   XBT_IN2("(%p,%g)", action, priority);
470   action->priority = priority;
471   lmm_update_variable_weight(cpu_im_maxmin_system,
472                              ((surf_action_lmm_t) action)->variable,
473                              priority);
474
475   xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
476   XBT_OUT;
477 }
478
479 static double cpu_im_action_get_remains(surf_action_t action)
480 {
481   XBT_IN1("(%p)", action);
482   /* update remains before return it */
483   cpu_im_update_remains(ACTION_GET_CPU(action), surf_get_clock());
484   return action->remains;
485   XBT_OUT;
486 }
487
488 static e_surf_resource_state_t cpu_im_get_state(void *cpu)
489 {
490   return ((cpu_Cas01_im_t) cpu)->state_current;
491 }
492
493 static double cpu_im_get_speed(void *cpu, double load)
494 {
495   return load * (((cpu_Cas01_im_t) cpu)->power_peak);
496 }
497
498 static double cpu_im_get_available_speed(void *cpu)
499 {
500   /* number between 0 and 1 */
501   return ((cpu_Cas01_im_t) cpu)->power_scale;
502 }
503
504 static void cpu_im_action_update_index_heap(void *action, int i)
505 {
506   ((surf_action_cpu_Cas01_im_t) action)->index_heap = i;
507 }
508
509 static void cpu_im_finalize(void)
510 {
511   void *cpu;
512   xbt_dict_cursor_t cursor;
513   char *key;
514   xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, key, cpu) {
515     cpu_Cas01_im_t CPU = cpu;
516     xbt_swag_free(CPU->action_set);
517   }
518
519   lmm_system_free(cpu_im_maxmin_system);
520   cpu_im_maxmin_system = NULL;
521
522   surf_model_exit(surf_cpu_model);
523   surf_cpu_model = NULL;
524
525   xbt_swag_free(cpu_im_running_action_set_that_does_not_need_being_checked);
526   cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
527   xbt_heap_free(cpu_im_action_heap);
528   xbt_swag_free(cpu_im_modified_cpu);
529 }
530
531 static void surf_cpu_im_model_init_internal(void)
532 {
533   s_surf_action_t action;
534   s_cpu_Cas01_im_t cpu;
535
536   surf_cpu_model = surf_model_init();
537
538   cpu_im_running_action_set_that_does_not_need_being_checked =
539     xbt_swag_new(xbt_swag_offset(action, state_hookup));
540
541   surf_cpu_model->name = "CPU_IM";
542
543   surf_cpu_model->action_unref = cpu_im_action_unref;
544   surf_cpu_model->action_cancel = cpu_im_action_cancel;
545   surf_cpu_model->action_state_set = cpu_im_cpu_action_state_set;
546
547   surf_cpu_model->model_private->resource_used = cpu_im_resource_used;
548   surf_cpu_model->model_private->share_resources = cpu_im_share_resources;
549   surf_cpu_model->model_private->update_actions_state = cpu_im_update_actions_state;
550   surf_cpu_model->model_private->update_resource_state =
551     cpu_im_update_resource_state;
552   surf_cpu_model->model_private->finalize = cpu_im_finalize;
553
554   surf_cpu_model->suspend = cpu_im_action_suspend;
555   surf_cpu_model->resume = cpu_im_action_resume;
556   surf_cpu_model->is_suspended = cpu_im_action_is_suspended;
557   surf_cpu_model->set_max_duration = cpu_im_action_set_max_duration;
558   surf_cpu_model->set_priority = cpu_im_action_set_priority;
559   surf_cpu_model->get_remains = cpu_im_action_get_remains;
560
561   surf_cpu_model->extension.cpu.execute = cpu_im_execute;
562   surf_cpu_model->extension.cpu.sleep = cpu_im_action_sleep;
563
564   surf_cpu_model->extension.cpu.get_state = cpu_im_get_state;
565   surf_cpu_model->extension.cpu.get_speed = cpu_im_get_speed;
566   surf_cpu_model->extension.cpu.get_available_speed = cpu_im_get_available_speed;
567
568   if (!cpu_im_maxmin_system) {
569     sg_maxmin_selective_update = 1;
570     cpu_im_maxmin_system = lmm_system_new();
571   }
572   cpu_im_action_heap = xbt_heap_new(8, NULL);
573   xbt_heap_set_update_callback(cpu_im_action_heap, cpu_im_action_update_index_heap);
574   cpu_im_modified_cpu = xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
575 }
576
577 /*********************************************************************/
578 /* Basic sharing model for CPU: that is where all this started... ;) */
579 /*********************************************************************/
580 /* @InProceedings{casanova01simgrid, */
581 /*   author =       "H. Casanova", */
582 /*   booktitle =    "Proceedings of the IEEE Symposium on Cluster Computing */
583 /*                  and the Grid (CCGrid'01)", */
584 /*   publisher =    "IEEE Computer Society", */
585 /*   title =        "Simgrid: {A} Toolkit for the Simulation of Application */
586 /*                  Scheduling", */
587 /*   year =         "2001", */
588 /*   month =        may, */
589 /*   note =         "Available at */
590 /*                  \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
591 /* } */
592 void surf_cpu_model_init_Cas01_im(const char *filename)
593 {
594   if (surf_cpu_model)
595     return;
596   surf_cpu_im_model_init_internal();
597   cpu_im_define_callbacks(filename);
598   xbt_dynar_push(model_list, &surf_cpu_model);
599 }