1 /* Copyright (c) 2009-2011. The SimGrid Team.
2 * All rights reserved. */
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. */
7 #include "surf_private.h"
8 #include "surf/surf_resource.h"
9 #include "maxmin_private.h"
11 surf_model_t surf_cpu_model = NULL;
13 #undef GENERIC_LMM_ACTION
16 #define GENERIC_LMM_ACTION(action) action->generic_lmm_action
17 #define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
18 #define ACTION_GET_CPU(action) ((surf_action_cpu_Cas01_t) action)->cpu
20 typedef struct surf_action_cpu_cas01 {
21 s_surf_action_lmm_t generic_lmm_action;
22 } s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
24 typedef struct cpu_Cas01 {
25 s_surf_resource_t generic_resource;
26 s_xbt_swag_hookup_t modified_cpu_hookup;
29 tmgr_trace_event_t power_event;
31 e_surf_resource_state_t state_current;
32 tmgr_trace_event_t state_event;
33 lmm_constraint_t constraint;
34 } s_cpu_Cas01_t, *cpu_Cas01_t;
36 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
37 "Logging specific to the SURF CPU IMPROVED module");
42 cpu_running_action_set_that_does_not_need_being_checked = NULL;
45 static void *cpu_create_resource(const char *name, double power_peak,
47 tmgr_trace_t power_trace,
49 e_surf_resource_state_t state_initial,
50 tmgr_trace_t state_trace,
51 xbt_dict_t cpu_properties)
53 cpu_Cas01_t cpu = NULL;
55 xbt_assert(!surf_cpu_resource_by_name(name),
56 "Host '%s' declared several times in the platform file",
58 cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
61 cpu->power_peak = power_peak;
62 xbt_assert(cpu->power_peak > 0, "Power has to be >0");
63 cpu->power_scale = power_scale;
65 xbt_assert(core > 0, "Invalid number of cores %d", core);
69 tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
71 cpu->state_current = state_initial;
74 tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
77 lmm_constraint_new(surf_cpu_model->maxmin_system, cpu,
78 cpu->core * cpu->power_scale * cpu->power_peak);
80 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
86 static void parse_cpu_init(sg_platf_host_cbarg_t host)
88 cpu_create_resource(host->id,
94 host->state_trace, host->properties);
97 static void cpu_add_traces_cpu(void)
99 xbt_dict_cursor_t cursor = NULL;
100 char *trace_name, *elm;
101 static int called = 0;
106 /* connect all traces relative to hosts */
107 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
108 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
109 cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
111 xbt_assert(host, "Host %s undefined", elm);
112 xbt_assert(trace, "Trace %s undefined", trace_name);
115 tmgr_history_add_trace(history, trace, 0.0, 0, host);
118 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
119 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
120 cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
122 xbt_assert(host, "Host %s undefined", elm);
123 xbt_assert(trace, "Trace %s undefined", trace_name);
126 tmgr_history_add_trace(history, trace, 0.0, 0, host);
130 static void cpu_define_callbacks()
132 sg_platf_host_add_cb(parse_cpu_init);
133 sg_platf_postparse_add_cb(cpu_add_traces_cpu);
136 static int cpu_resource_used(void *resource)
138 return lmm_constraint_used(surf_cpu_model->maxmin_system,
139 ((cpu_Cas01_t) resource)->constraint);
142 static int cpu_action_unref(surf_action_t action)
145 if (!action->refcount) {
146 xbt_swag_remove(action, action->state_set);
147 if (((surf_action_lmm_t) action)->variable)
148 lmm_variable_free(surf_cpu_model->maxmin_system,
149 ((surf_action_lmm_t) action)->variable);
150 if (surf_cpu_model->update_mechanism == UM_LAZY) {
151 /* remove from heap */
152 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
153 xbt_swag_remove(action, surf_cpu_model->modified_set);
156 xbt_free(action->category);
158 surf_action_free(&action);
164 static void cpu_action_cancel(surf_action_t action)
166 surf_action_state_set(action, SURF_ACTION_FAILED);
167 if (surf_cpu_model->update_mechanism == UM_LAZY) {
168 xbt_swag_remove(action, surf_cpu_model->modified_set);
169 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
174 static void cpu_action_state_set(surf_action_t action,
175 e_surf_action_state_t state)
177 /* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
178 /* if(((surf_action_lmm_t)action)->variable) { */
179 /* lmm_variable_disable(surf_cpu_model->maxmin_system, ((surf_action_lmm_t)action)->variable); */
180 /* ((surf_action_lmm_t)action)->variable = NULL; */
183 surf_action_state_set(action, state);
187 static void cpu_update_action_remaining_lazy(surf_action_cpu_Cas01_t action, double now)
191 xbt_assert(GENERIC_ACTION(action).state_set == surf_cpu_model->states.running_action_set,
192 "You're updating an action that is not running.");
194 /* bogus priority, skip it */
195 xbt_assert(GENERIC_ACTION(action).priority > 0,
196 "You're updating an action that seems suspended.");
198 delta = now - GENERIC_LMM_ACTION(action).last_update;
199 if (GENERIC_ACTION(action).remains > 0) {
200 XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", action,
201 GENERIC_ACTION(action).remains,
202 GENERIC_LMM_ACTION(action).last_update);
203 double_update(&(GENERIC_ACTION(action).remains),
204 GENERIC_LMM_ACTION(action).last_value * delta);
207 if (TRACE_is_enabled()) {
209 lmm_constraint_id(lmm_get_cnst_from_var
210 (surf_cpu_model->maxmin_system,
211 GENERIC_LMM_ACTION(action).variable, 0));
212 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
213 ((surf_action_t)action)->category,
214 GENERIC_LMM_ACTION(action).last_value,
215 GENERIC_LMM_ACTION(action).last_update,
216 now - GENERIC_LMM_ACTION(action).last_update);
219 XBT_DEBUG("Updating action(%p): remains is now %lf", action,
220 GENERIC_ACTION(action).remains);
222 GENERIC_LMM_ACTION(action).last_update = now;
223 GENERIC_LMM_ACTION(action).last_value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
226 static double cpu_share_resources_lazy(double now)
228 surf_action_cpu_Cas01_t action = NULL;
233 ("Before share resources, the size of modified actions set is %d",
234 xbt_swag_size(surf_cpu_model->modified_set));
236 lmm_solve(surf_cpu_model->maxmin_system);
239 ("After share resources, The size of modified actions set is %d",
240 xbt_swag_size(surf_cpu_model->modified_set));
242 while((action = xbt_swag_extract(surf_cpu_model->modified_set))) {
243 int max_dur_flag = 0;
245 if (GENERIC_ACTION(action).state_set !=
246 surf_cpu_model->states.running_action_set)
249 /* bogus priority, skip it */
250 if (GENERIC_ACTION(action).priority <= 0)
253 cpu_update_action_remaining_lazy(action,now);
256 value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
258 if (GENERIC_ACTION(action).remains > 0) {
259 value = GENERIC_ACTION(action).remains / value;
267 if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
269 || GENERIC_ACTION(action).start +
270 GENERIC_ACTION(action).max_duration < min)) {
271 min = GENERIC_ACTION(action).start +
272 GENERIC_ACTION(action).max_duration;
276 XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
277 GENERIC_ACTION(action).start, now + value,
278 GENERIC_ACTION(action).max_duration);
281 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
282 surf_action_lmm_heap_insert(surf_cpu_model->action_heap,(surf_action_lmm_t)action, min, max_dur_flag ? MAX_DURATION : NORMAL);
283 XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
285 } else DIE_IMPOSSIBLE;
288 //hereafter must have already the min value for this resource model
289 if (xbt_heap_size(surf_cpu_model->action_heap) > 0)
290 min = xbt_heap_maxkey(surf_cpu_model->action_heap) - now;
294 XBT_DEBUG("The minimum with the HEAP %lf", min);
299 static double cpu_share_resources_full(double now)
301 s_surf_action_cpu_Cas01_t action;
302 return generic_maxmin_share_resources(surf_cpu_model->states.
304 xbt_swag_offset(action,
307 surf_cpu_model->maxmin_system, lmm_solve);
310 static void cpu_update_actions_state_lazy(double now, double delta)
312 surf_action_cpu_Cas01_t action;
313 while ((xbt_heap_size(surf_cpu_model->action_heap) > 0)
314 && (double_equals(xbt_heap_maxkey(surf_cpu_model->action_heap), now))) {
315 action = xbt_heap_pop(surf_cpu_model->action_heap);
316 XBT_DEBUG("Action %p: finish", action);
317 GENERIC_ACTION(action).finish = surf_get_clock();
319 if (TRACE_is_enabled()) {
321 lmm_constraint_id(lmm_get_cnst_from_var
322 (surf_cpu_model->maxmin_system,
323 GENERIC_LMM_ACTION(action).variable, 0));
324 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
325 ((surf_action_t)action)->category,
326 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
327 GENERIC_LMM_ACTION(action).last_update,
328 now - GENERIC_LMM_ACTION(action).last_update);
331 /* set the remains to 0 due to precision problems when updating the remaining amount */
332 GENERIC_ACTION(action).remains = 0;
333 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
334 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action); //FIXME: strange call since action was already popped
337 if (TRACE_is_enabled()) {
338 //defining the last timestamp that we can safely dump to trace file
339 //without losing the event ascending order (considering all CPU's)
341 xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
342 xbt_swag_foreach(action, running_actions) {
344 smaller = GENERIC_LMM_ACTION(action).last_update;
347 if (GENERIC_LMM_ACTION(action).last_update < smaller) {
348 smaller = GENERIC_LMM_ACTION(action).last_update;
352 TRACE_last_timestamp_to_dump = smaller;
359 static void cpu_update_actions_state_full(double now, double delta)
361 surf_action_cpu_Cas01_t action = NULL;
362 surf_action_cpu_Cas01_t next_action = NULL;
363 xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
364 xbt_swag_foreach_safe(action, next_action, running_actions) {
366 if (TRACE_is_enabled()) {
368 lmm_constraint_id(lmm_get_cnst_from_var
369 (surf_cpu_model->maxmin_system,
370 GENERIC_LMM_ACTION(action).variable, 0));
372 TRACE_surf_host_set_utilization(x->generic_resource.name,
373 ((surf_action_t)action)->category,
374 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
378 TRACE_last_timestamp_to_dump = now - delta;
381 double_update(&(GENERIC_ACTION(action).remains),
382 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
384 if (GENERIC_LMM_ACTION(action).generic_action.max_duration !=
386 double_update(&(GENERIC_ACTION(action).max_duration), delta);
387 if ((GENERIC_ACTION(action).remains <= 0) &&
388 (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) >
390 GENERIC_ACTION(action).finish = surf_get_clock();
391 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
392 } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
393 (GENERIC_ACTION(action).max_duration <= 0)) {
394 GENERIC_ACTION(action).finish = surf_get_clock();
395 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
402 static void cpu_update_resource_state(void *id,
403 tmgr_trace_event_t event_type,
404 double value, double date)
406 cpu_Cas01_t cpu = id;
407 lmm_variable_t var = NULL;
408 lmm_element_t elem = NULL;
410 if (event_type == cpu->power_event) {
411 cpu->power_scale = value;
412 lmm_update_constraint_bound(surf_cpu_model->maxmin_system, cpu->constraint,
413 cpu->core * cpu->power_scale *
416 TRACE_surf_host_set_power(date, cpu->generic_resource.name,
417 cpu->core * cpu->power_scale *
420 while ((var = lmm_get_var_from_cnst
421 (surf_cpu_model->maxmin_system, cpu->constraint, &elem))) {
422 surf_action_cpu_Cas01_t action = lmm_variable_id(var);
423 lmm_update_variable_bound(surf_cpu_model->maxmin_system,
424 GENERIC_LMM_ACTION(action).variable,
425 cpu->power_scale * cpu->power_peak);
427 if (tmgr_trace_event_free(event_type))
428 cpu->power_event = NULL;
429 } else if (event_type == cpu->state_event) {
431 cpu->state_current = SURF_RESOURCE_ON;
433 lmm_constraint_t cnst = cpu->constraint;
435 cpu->state_current = SURF_RESOURCE_OFF;
437 while ((var = lmm_get_var_from_cnst(surf_cpu_model->maxmin_system, cnst, &elem))) {
438 surf_action_t action = lmm_variable_id(var);
440 if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
441 surf_action_state_get(action) == SURF_ACTION_READY ||
442 surf_action_state_get(action) ==
443 SURF_ACTION_NOT_IN_THE_SYSTEM) {
444 action->finish = date;
445 cpu_action_state_set(action, SURF_ACTION_FAILED);
449 if (tmgr_trace_event_free(event_type))
450 cpu->state_event = NULL;
452 XBT_CRITICAL("Unknown event ! \n");
459 static surf_action_t cpu_execute(void *cpu, double size)
461 surf_action_cpu_Cas01_t action = NULL;
462 cpu_Cas01_t CPU = cpu;
464 XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
466 surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size,
468 CPU->state_current != SURF_RESOURCE_ON);
470 GENERIC_LMM_ACTION(action).suspended = 0; /* Should be useless because of the
471 calloc but it seems to help valgrind... */
473 GENERIC_LMM_ACTION(action).variable =
474 lmm_variable_new(surf_cpu_model->maxmin_system, action,
475 GENERIC_ACTION(action).priority,
476 CPU->power_scale * CPU->power_peak, 1);
477 if (surf_cpu_model->update_mechanism == UM_LAZY) {
478 GENERIC_LMM_ACTION(action).index_heap = -1;
479 GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
480 GENERIC_LMM_ACTION(action).last_value = 0.0;
482 lmm_expand(surf_cpu_model->maxmin_system, CPU->constraint,
483 GENERIC_LMM_ACTION(action).variable, 1.0);
485 return (surf_action_t) action;
488 static surf_action_t cpu_action_sleep(void *cpu, double duration)
490 surf_action_cpu_Cas01_t action = NULL;
493 duration = MAX(duration, MAXMIN_PRECISION);
495 XBT_IN("(%s,%g)", surf_resource_name(cpu), duration);
496 action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
497 // FIXME: sleep variables should not consume 1.0 in lmm_expand
498 GENERIC_ACTION(action).max_duration = duration;
499 GENERIC_LMM_ACTION(action).suspended = 2;
500 if (duration == NO_MAX_DURATION) {
501 /* Move to the *end* of the corresponding action set. This convention
502 is used to speed up update_resource_state */
503 xbt_swag_remove(action, ((surf_action_t) action)->state_set);
504 ((surf_action_t) action)->state_set =
505 cpu_running_action_set_that_does_not_need_being_checked;
506 xbt_swag_insert(action, ((surf_action_t) action)->state_set);
509 lmm_update_variable_weight(surf_cpu_model->maxmin_system,
510 GENERIC_LMM_ACTION(action).variable, 0.0);
511 if (surf_cpu_model->update_mechanism == UM_LAZY) { // remove action from the heap
512 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
513 // this is necessary for a variable with weight 0 since such
514 // variables are ignored in lmm and we need to set its max_duration
515 // correctly at the next call to share_resources
516 xbt_swag_insert_at_head(action,surf_cpu_model->modified_set);
520 return (surf_action_t) action;
523 static void cpu_action_suspend(surf_action_t action)
525 XBT_IN("(%p)", action);
526 if (((surf_action_lmm_t) action)->suspended != 2) {
527 lmm_update_variable_weight(surf_cpu_model->maxmin_system,
528 ((surf_action_lmm_t) action)->variable,
530 ((surf_action_lmm_t) action)->suspended = 1;
531 if (surf_cpu_model->update_mechanism == UM_LAZY)
532 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
537 static void cpu_action_resume(surf_action_t action)
540 XBT_IN("(%p)", action);
541 if (((surf_action_lmm_t) action)->suspended != 2) {
542 lmm_update_variable_weight(surf_cpu_model->maxmin_system,
543 ((surf_action_lmm_t) action)->variable,
545 ((surf_action_lmm_t) action)->suspended = 0;
546 if (surf_cpu_model->update_mechanism == UM_LAZY)
547 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
552 static int cpu_action_is_suspended(surf_action_t action)
554 return (((surf_action_lmm_t) action)->suspended == 1);
557 static void cpu_action_set_max_duration(surf_action_t action,
560 XBT_IN("(%p,%g)", action, duration);
562 action->max_duration = duration;
563 if (surf_cpu_model->update_mechanism == UM_LAZY)
564 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
568 static void cpu_action_set_priority(surf_action_t action, double priority)
570 XBT_IN("(%p,%g)", action, priority);
571 action->priority = priority;
572 lmm_update_variable_weight(surf_cpu_model->maxmin_system,
573 ((surf_action_lmm_t) action)->variable,
576 if (surf_cpu_model->update_mechanism == UM_LAZY)
577 surf_action_lmm_heap_remove(surf_cpu_model->action_heap,(surf_action_lmm_t)action);
582 static void cpu_action_set_category(surf_action_t action,
583 const char *category)
585 XBT_IN("(%p,%s)", action, category);
586 action->category = xbt_strdup(category);
591 static double cpu_action_get_remains(surf_action_t action)
593 XBT_IN("(%p)", action);
594 /* update remains before return it */
595 if (surf_cpu_model->update_mechanism == UM_LAZY)
596 cpu_update_action_remaining_lazy((surf_action_cpu_Cas01_t)action,
599 return action->remains;
602 static e_surf_resource_state_t cpu_get_state(void *cpu)
604 return ((cpu_Cas01_t) cpu)->state_current;
607 static double cpu_get_speed(void *cpu, double load)
609 return load * (((cpu_Cas01_t) cpu)->power_peak);
612 static double cpu_get_available_speed(void *cpu)
614 /* number between 0 and 1 */
615 return ((cpu_Cas01_t) cpu)->power_scale;
618 static void cpu_finalize(void)
620 lmm_system_free(surf_cpu_model->maxmin_system);
621 surf_cpu_model->maxmin_system = NULL;
623 if (surf_cpu_model->action_heap)
624 xbt_heap_free(surf_cpu_model->action_heap);
625 xbt_swag_free(surf_cpu_model->modified_set);
627 surf_model_exit(surf_cpu_model);
628 surf_cpu_model = NULL;
630 xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
631 cpu_running_action_set_that_does_not_need_being_checked = NULL;
634 static void surf_cpu_model_init_internal()
636 s_surf_action_t action;
637 s_surf_action_cpu_Cas01_t comp;
639 char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
641 xbt_cfg_get_int(_surf_cfg_set, "cpu/maxmin_selective_update");
643 surf_cpu_model = surf_model_init();
645 if (!strcmp(optim, "Full")) {
646 surf_cpu_model->update_mechanism = UM_FULL;
647 surf_cpu_model->selective_update = select;
648 } else if (!strcmp(optim, "Lazy")) {
649 surf_cpu_model->update_mechanism = UM_LAZY;
650 surf_cpu_model->selective_update = 1;
651 xbt_assert((select == 1)
653 (xbt_cfg_is_default_value
654 (_surf_cfg_set, "cpu/maxmin_selective_update")),
655 "Disabling selective update while using the lazy update mechanism is dumb!");
657 xbt_die("Unsupported optimization (%s) for this model", optim);
660 cpu_running_action_set_that_does_not_need_being_checked =
661 xbt_swag_new(xbt_swag_offset(action, state_hookup));
663 surf_cpu_model->name = "cpu";
665 surf_cpu_model->action_unref = cpu_action_unref;
666 surf_cpu_model->action_cancel = cpu_action_cancel;
667 surf_cpu_model->action_state_set = cpu_action_state_set;
669 surf_cpu_model->model_private->resource_used = cpu_resource_used;
671 if (surf_cpu_model->update_mechanism == UM_LAZY) {
672 surf_cpu_model->model_private->share_resources =
673 cpu_share_resources_lazy;
674 surf_cpu_model->model_private->update_actions_state =
675 cpu_update_actions_state_lazy;
676 } else if (surf_cpu_model->update_mechanism == UM_FULL) {
677 surf_cpu_model->model_private->share_resources =
678 cpu_share_resources_full;
679 surf_cpu_model->model_private->update_actions_state =
680 cpu_update_actions_state_full;
682 xbt_die("Invalid cpu update mechanism!");
684 surf_cpu_model->model_private->update_resource_state =
685 cpu_update_resource_state;
686 surf_cpu_model->model_private->finalize = cpu_finalize;
688 surf_cpu_model->suspend = cpu_action_suspend;
689 surf_cpu_model->resume = cpu_action_resume;
690 surf_cpu_model->is_suspended = cpu_action_is_suspended;
691 surf_cpu_model->set_max_duration = cpu_action_set_max_duration;
692 surf_cpu_model->set_priority = cpu_action_set_priority;
694 surf_cpu_model->set_category = cpu_action_set_category;
696 surf_cpu_model->get_remains = cpu_action_get_remains;
698 surf_cpu_model->extension.cpu.execute = cpu_execute;
699 surf_cpu_model->extension.cpu.sleep = cpu_action_sleep;
701 surf_cpu_model->extension.cpu.get_state = cpu_get_state;
702 surf_cpu_model->extension.cpu.get_speed = cpu_get_speed;
703 surf_cpu_model->extension.cpu.get_available_speed =
704 cpu_get_available_speed;
705 surf_cpu_model->extension.cpu.create_resource = cpu_create_resource;
706 surf_cpu_model->extension.cpu.add_traces = cpu_add_traces_cpu;
708 if (!surf_cpu_model->maxmin_system) {
709 surf_cpu_model->maxmin_system = lmm_system_new(surf_cpu_model->selective_update);
711 if (surf_cpu_model->update_mechanism == UM_LAZY) {
712 surf_cpu_model->action_heap = xbt_heap_new(8, NULL);
713 xbt_heap_set_update_callback(surf_cpu_model->action_heap,
714 surf_action_lmm_update_index_heap);
715 surf_cpu_model->modified_set =
716 xbt_swag_new(xbt_swag_offset(comp, generic_lmm_action.action_list_hookup));
717 surf_cpu_model->maxmin_system->keep_track = surf_cpu_model->modified_set;
721 /*********************************************************************/
722 /* Basic sharing model for CPU: that is where all this started... ;) */
723 /*********************************************************************/
724 /* @InProceedings{casanova01simgrid, */
725 /* author = "H. Casanova", */
726 /* booktitle = "Proceedings of the IEEE Symposium on Cluster Computing */
727 /* and the Grid (CCGrid'01)", */
728 /* publisher = "IEEE Computer Society", */
729 /* title = "Simgrid: {A} Toolkit for the Simulation of Application */
733 /* note = "Available at */
734 /* \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
737 void surf_cpu_model_init_Cas01()
739 char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
744 if (!strcmp(optim, "TI")) {
745 surf_cpu_model_init_ti();
749 surf_cpu_model_init_internal();
750 cpu_define_callbacks();
751 xbt_dynar_push(model_list, &surf_cpu_model);