Logo AND Algorithmique Numérique Distribuée

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