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;
12 lmm_system_t cpu_maxmin_system = NULL;
13 e_UM_t cpu_update_mechanism = UM_UNDEFINED;
14 static int cpu_selective_update = 0;
16 static xbt_swag_t cpu_modified_set= NULL;
17 static xbt_heap_t cpu_action_heap = NULL;
19 #undef GENERIC_LMM_ACTION
22 #define GENERIC_LMM_ACTION(action) action->generic_lmm_action
23 #define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
24 #define ACTION_GET_CPU(action) ((surf_action_cpu_Cas01_t) action)->cpu
26 typedef struct surf_action_cpu_cas01 {
27 s_surf_action_lmm_t generic_lmm_action;
28 } s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
30 typedef struct cpu_Cas01 {
31 s_surf_resource_t generic_resource;
32 s_xbt_swag_hookup_t modified_cpu_hookup;
35 tmgr_trace_event_t power_event;
37 e_surf_resource_state_t state_current;
38 tmgr_trace_event_t state_event;
39 lmm_constraint_t constraint;
40 } s_cpu_Cas01_t, *cpu_Cas01_t;
42 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
43 "Logging specific to the SURF CPU IMPROVED module");
48 cpu_running_action_set_that_does_not_need_being_checked = NULL;
50 /* added to manage the communication action's heap */
51 static void net_action_update_index_heap(void *action, int i)
53 surf_action_cpu_Cas01_t a = action;
54 GENERIC_LMM_ACTION(a).index_heap = i;
57 /* insert action on heap using a given key and a hat (heap_action_type)
58 * a hat can be of three types for communications:
60 * NORMAL = this is a normal heap entry stating the date to finish transmitting
61 * LATENCY = this is a heap entry to warn us when the latency is payed
62 * MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
64 static void heap_insert(surf_action_cpu_Cas01_t action, double key,
65 enum heap_action_type hat)
67 GENERIC_LMM_ACTION(action).hat = hat;
68 xbt_heap_push(cpu_action_heap, action, key);
71 static void heap_remove(surf_action_cpu_Cas01_t action)
73 GENERIC_LMM_ACTION(action).hat = NOTSET;
74 if (GENERIC_LMM_ACTION(action).index_heap >= 0) {
75 xbt_heap_remove(cpu_action_heap, GENERIC_LMM_ACTION(action).index_heap);
79 static void *cpu_create_resource(const char *name, double power_peak,
81 tmgr_trace_t power_trace,
83 e_surf_resource_state_t state_initial,
84 tmgr_trace_t state_trace,
85 xbt_dict_t cpu_properties)
87 cpu_Cas01_t cpu = NULL;
89 xbt_assert(!surf_cpu_resource_by_name(name),
90 "Host '%s' declared several times in the platform file",
92 cpu = (cpu_Cas01_t) surf_resource_new(sizeof(s_cpu_Cas01_t),
95 cpu->power_peak = power_peak;
96 xbt_assert(cpu->power_peak > 0, "Power has to be >0");
97 cpu->power_scale = power_scale;
99 xbt_assert(core > 0, "Invalid number of cores %d", core);
103 tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
105 cpu->state_current = state_initial;
108 tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
111 lmm_constraint_new(cpu_maxmin_system, cpu,
112 cpu->core * cpu->power_scale * cpu->power_peak);
114 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
120 static void parse_cpu_init(sg_platf_host_cbarg_t host)
122 cpu_create_resource(host->id,
128 host->state_trace, host->properties);
131 static void cpu_add_traces_cpu(void)
133 xbt_dict_cursor_t cursor = NULL;
134 char *trace_name, *elm;
135 static int called = 0;
140 /* connect all traces relative to hosts */
141 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
142 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
143 cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
145 xbt_assert(host, "Host %s undefined", elm);
146 xbt_assert(trace, "Trace %s undefined", trace_name);
149 tmgr_history_add_trace(history, trace, 0.0, 0, host);
152 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
153 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
154 cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
156 xbt_assert(host, "Host %s undefined", elm);
157 xbt_assert(trace, "Trace %s undefined", trace_name);
160 tmgr_history_add_trace(history, trace, 0.0, 0, host);
164 static void cpu_define_callbacks()
166 sg_platf_host_add_cb(parse_cpu_init);
167 sg_platf_postparse_add_cb(cpu_add_traces_cpu);
170 static int cpu_resource_used(void *resource)
172 return lmm_constraint_used(cpu_maxmin_system,
173 ((cpu_Cas01_t) resource)->constraint);
176 static int cpu_action_unref(surf_action_t action)
179 if (!action->refcount) {
180 xbt_swag_remove(action, action->state_set);
181 if (((surf_action_lmm_t) action)->variable)
182 lmm_variable_free(cpu_maxmin_system,
183 ((surf_action_lmm_t) action)->variable);
184 if (cpu_update_mechanism == UM_LAZY) {
185 /* remove from heap */
186 heap_remove((surf_action_cpu_Cas01_t) action);
187 xbt_swag_remove(action, cpu_modified_set);
190 xbt_free(action->category);
192 surf_action_free(&action);
198 static void cpu_action_cancel(surf_action_t action)
200 surf_action_state_set(action, SURF_ACTION_FAILED);
201 if (cpu_update_mechanism == UM_LAZY) {
202 xbt_swag_remove(action, cpu_modified_set);
203 heap_remove((surf_action_cpu_Cas01_t) action);
208 static void cpu_action_state_set(surf_action_t action,
209 e_surf_action_state_t state)
211 /* if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
212 /* if(((surf_action_lmm_t)action)->variable) { */
213 /* lmm_variable_disable(cpu_maxmin_system, ((surf_action_lmm_t)action)->variable); */
214 /* ((surf_action_lmm_t)action)->variable = NULL; */
217 surf_action_state_set(action, state);
221 static void update_action_remaining_lazy(double now)
223 surf_action_cpu_Cas01_t action;
226 xbt_swag_foreach(action, cpu_modified_set) {
227 if (GENERIC_ACTION(action).state_set !=
228 surf_cpu_model->states.running_action_set)
229 continue; // FIXME useless ????
231 /* bogus priority, skip it */
232 if (GENERIC_ACTION(action).priority <= 0)
235 delta = now - GENERIC_LMM_ACTION(action).last_update;
236 if (GENERIC_ACTION(action).remains > 0) {
238 double_update(&(GENERIC_ACTION(action).remains),
239 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * delta);
242 if (TRACE_is_enabled()) {
244 lmm_constraint_id(lmm_get_cnst_from_var
246 GENERIC_LMM_ACTION(action).variable, 0));
247 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
248 action->generic_lmm_action.
250 (surf_action_t) action,
251 lmm_variable_getvalue
252 (GENERIC_LMM_ACTION(action).
253 variable), GENERIC_LMM_ACTION(action).last_update,
254 now - GENERIC_LMM_ACTION(action).last_update);
257 XBT_DEBUG("Update action(%p) remains %lf", action,
258 GENERIC_ACTION(action).remains);
260 GENERIC_LMM_ACTION(action).last_update = now;
265 static double cpu_share_resources_lazy(double now)
267 surf_action_cpu_Cas01_t action = NULL;
272 ("Before share resources, the size of modified actions set is %d",
273 xbt_swag_size(cpu_modified_set));
274 update_action_remaining_lazy(now);
276 lmm_solve(cpu_maxmin_system);
279 ("After share resources, The size of modified actions set is %d",
280 xbt_swag_size(cpu_modified_set));
282 xbt_swag_foreach(action, cpu_modified_set) {
283 int max_dur_flag = 0;
285 if (GENERIC_ACTION(action).state_set !=
286 surf_cpu_model->states.running_action_set)
289 /* bogus priority, skip it */
290 if (GENERIC_ACTION(action).priority <= 0)
294 value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
296 if (GENERIC_ACTION(action).remains > 0) {
297 value = GENERIC_ACTION(action).remains / value;
305 if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
307 || GENERIC_ACTION(action).start +
308 GENERIC_ACTION(action).max_duration < min)) {
309 min = GENERIC_ACTION(action).start +
310 GENERIC_ACTION(action).max_duration;
314 XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
315 GENERIC_ACTION(action).start, now + value,
316 GENERIC_ACTION(action).max_duration);
320 heap_insert(action, min, max_dur_flag ? MAX_DURATION : NORMAL);
321 XBT_DEBUG("Insert at heap action(%p) min %lf now %lf", action, min,
323 } else DIE_IMPOSSIBLE;
326 //hereafter must have already the min value for this resource model
327 if (xbt_heap_size(cpu_action_heap) > 0)
328 min = xbt_heap_maxkey(cpu_action_heap) - now;
332 XBT_DEBUG("The minimum with the HEAP %lf", min);
337 static double cpu_share_resources_full(double now)
339 s_surf_action_cpu_Cas01_t action;
340 return generic_maxmin_share_resources(surf_cpu_model->states.
342 xbt_swag_offset(action,
345 cpu_maxmin_system, lmm_solve);
348 static void cpu_update_actions_state_lazy(double now, double delta)
350 surf_action_cpu_Cas01_t action;
351 while ((xbt_heap_size(cpu_action_heap) > 0)
352 && (double_equals(xbt_heap_maxkey(cpu_action_heap), now))) {
353 action = xbt_heap_pop(cpu_action_heap);
354 XBT_DEBUG("Action %p: finish", action);
355 GENERIC_ACTION(action).finish = surf_get_clock();
356 /* set the remains to 0 due to precision problems when updating the remaining amount */
358 if (TRACE_is_enabled()) {
360 lmm_constraint_id(lmm_get_cnst_from_var
362 GENERIC_LMM_ACTION(action).variable, 0));
363 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
364 GENERIC_LMM_ACTION(action).generic_action.data,
365 (surf_action_t) action,
366 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
367 GENERIC_LMM_ACTION(action).last_update,
368 now - GENERIC_LMM_ACTION(action).last_update);
371 GENERIC_ACTION(action).remains = 0;
372 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
376 if (TRACE_is_enabled()) {
377 //defining the last timestamp that we can safely dump to trace file
378 //without losing the event ascending order (considering all CPU's)
380 xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
381 xbt_swag_foreach(action, running_actions) {
383 smaller = GENERIC_LMM_ACTION(action).last_update;
386 if (GENERIC_LMM_ACTION(action).last_update < smaller) {
387 smaller = GENERIC_LMM_ACTION(action).last_update;
391 TRACE_last_timestamp_to_dump = smaller;
398 static void cpu_update_actions_state_full(double now, double delta)
400 surf_action_cpu_Cas01_t action = NULL;
401 surf_action_cpu_Cas01_t next_action = NULL;
402 xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
403 xbt_swag_foreach_safe(action, next_action, running_actions) {
405 if (TRACE_is_enabled()) {
407 lmm_constraint_id(lmm_get_cnst_from_var
409 GENERIC_LMM_ACTION(action).variable, 0));
411 TRACE_surf_host_set_utilization(x->generic_resource.name,
412 GENERIC_ACTION(action).data,
413 (surf_action_t) action,
414 lmm_variable_getvalue
415 (GENERIC_LMM_ACTION(action).
416 variable), now - delta, delta);
417 TRACE_last_timestamp_to_dump = now - delta;
420 double_update(&(GENERIC_ACTION(action).remains),
421 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).
423 if (GENERIC_LMM_ACTION(action).generic_action.max_duration !=
425 double_update(&(GENERIC_ACTION(action).max_duration), delta);
426 if ((GENERIC_ACTION(action).remains <= 0) &&
427 (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) >
429 GENERIC_ACTION(action).finish = surf_get_clock();
430 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
431 } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
432 (GENERIC_ACTION(action).max_duration <= 0)) {
433 GENERIC_ACTION(action).finish = surf_get_clock();
434 cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
441 static void cpu_update_resource_state(void *id,
442 tmgr_trace_event_t event_type,
443 double value, double date)
445 cpu_Cas01_t cpu = id;
446 lmm_variable_t var = NULL;
447 lmm_element_t elem = NULL;
449 if (event_type == cpu->power_event) {
450 cpu->power_scale = value;
451 lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint,
452 cpu->core * cpu->power_scale *
455 TRACE_surf_host_set_power(date, cpu->generic_resource.name,
456 cpu->core * cpu->power_scale *
459 while ((var = lmm_get_var_from_cnst
460 (cpu_maxmin_system, cpu->constraint, &elem))) {
461 surf_action_cpu_Cas01_t action = lmm_variable_id(var);
462 lmm_update_variable_bound(cpu_maxmin_system,
463 GENERIC_LMM_ACTION(action).variable,
464 cpu->power_scale * cpu->power_peak);
466 if (tmgr_trace_event_free(event_type))
467 cpu->power_event = NULL;
468 } else if (event_type == cpu->state_event) {
470 cpu->state_current = SURF_RESOURCE_ON;
472 lmm_constraint_t cnst = cpu->constraint;
474 cpu->state_current = SURF_RESOURCE_OFF;
476 while ((var = lmm_get_var_from_cnst(cpu_maxmin_system, cnst, &elem))) {
477 surf_action_t action = lmm_variable_id(var);
479 if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
480 surf_action_state_get(action) == SURF_ACTION_READY ||
481 surf_action_state_get(action) ==
482 SURF_ACTION_NOT_IN_THE_SYSTEM) {
483 action->finish = date;
484 cpu_action_state_set(action, SURF_ACTION_FAILED);
488 if (tmgr_trace_event_free(event_type))
489 cpu->state_event = NULL;
491 XBT_CRITICAL("Unknown event ! \n");
498 static surf_action_t cpu_execute(void *cpu, double size)
500 surf_action_cpu_Cas01_t action = NULL;
501 cpu_Cas01_t CPU = cpu;
503 XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
505 surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size,
507 CPU->state_current != SURF_RESOURCE_ON);
509 GENERIC_LMM_ACTION(action).suspended = 0; /* Should be useless because of the
510 calloc but it seems to help valgrind... */
512 GENERIC_LMM_ACTION(action).variable =
513 lmm_variable_new(cpu_maxmin_system, action,
514 GENERIC_ACTION(action).priority,
515 CPU->power_scale * CPU->power_peak, 1);
516 if (cpu_update_mechanism == UM_LAZY) {
517 GENERIC_LMM_ACTION(action).index_heap = -1;
518 GENERIC_LMM_ACTION(action).last_update = surf_get_clock();
520 lmm_expand(cpu_maxmin_system, CPU->constraint,
521 GENERIC_LMM_ACTION(action).variable, 1.0);
523 return (surf_action_t) action;
526 static surf_action_t cpu_action_sleep(void *cpu, double duration)
528 surf_action_cpu_Cas01_t action = NULL;
531 duration = MAX(duration, MAXMIN_PRECISION);
533 XBT_IN("(%s,%g)", surf_resource_name(cpu), duration);
534 action = (surf_action_cpu_Cas01_t) cpu_execute(cpu, 1.0);
535 GENERIC_ACTION(action).max_duration = duration;
536 GENERIC_LMM_ACTION(action).suspended = 2;
537 if (duration == NO_MAX_DURATION) {
538 /* Move to the *end* of the corresponding action set. This convention
539 is used to speed up update_resource_state */
540 xbt_swag_remove(action, ((surf_action_t) action)->state_set);
541 ((surf_action_t) action)->state_set =
542 cpu_running_action_set_that_does_not_need_being_checked;
543 xbt_swag_insert(action, ((surf_action_t) action)->state_set);
546 lmm_update_variable_weight(cpu_maxmin_system,
547 GENERIC_LMM_ACTION(action).variable, 0.0);
548 if (cpu_update_mechanism == UM_LAZY) { // remove action from the heap
549 heap_remove((surf_action_cpu_Cas01_t) action);
550 // this is necessary for a variable with weight 0 since such
551 // variables are ignored in lmm and we need to set its max_duration
552 // correctly at the next call to share_resources
553 xbt_swag_insert_at_head(action,cpu_modified_set);
557 return (surf_action_t) action;
560 static void cpu_action_suspend(surf_action_t action)
562 XBT_IN("(%p)", action);
563 if (((surf_action_lmm_t) action)->suspended != 2) {
564 lmm_update_variable_weight(cpu_maxmin_system,
565 ((surf_action_lmm_t) action)->variable,
567 ((surf_action_lmm_t) action)->suspended = 1;
568 if (cpu_update_mechanism == UM_LAZY)
569 heap_remove((surf_action_cpu_Cas01_t) action);
574 static void cpu_action_resume(surf_action_t action)
577 XBT_IN("(%p)", action);
578 if (((surf_action_lmm_t) action)->suspended != 2) {
579 lmm_update_variable_weight(cpu_maxmin_system,
580 ((surf_action_lmm_t) action)->variable,
582 ((surf_action_lmm_t) action)->suspended = 0;
583 if (cpu_update_mechanism == UM_LAZY)
584 heap_remove((surf_action_cpu_Cas01_t) action);
589 static int cpu_action_is_suspended(surf_action_t action)
591 return (((surf_action_lmm_t) action)->suspended == 1);
594 static void cpu_action_set_max_duration(surf_action_t action,
597 XBT_IN("(%p,%g)", action, duration);
599 action->max_duration = duration;
600 if (cpu_update_mechanism == UM_LAZY)
601 heap_remove((surf_action_cpu_Cas01_t) action);
605 static void cpu_action_set_priority(surf_action_t action, double priority)
607 XBT_IN("(%p,%g)", action, priority);
608 action->priority = priority;
609 lmm_update_variable_weight(cpu_maxmin_system,
610 ((surf_action_lmm_t) action)->variable,
613 if (cpu_update_mechanism == UM_LAZY)
614 heap_remove((surf_action_cpu_Cas01_t) action);
619 static void cpu_action_set_category(surf_action_t action,
620 const char *category)
622 XBT_IN("(%p,%s)", action, category);
623 action->category = xbt_strdup(category);
628 static double cpu_action_get_remains(surf_action_t action)
630 XBT_IN("(%p)", action);
631 /* update remains before return it */
632 if (cpu_update_mechanism == UM_LAZY)
633 update_action_remaining_lazy(surf_get_clock());
635 return action->remains;
638 static e_surf_resource_state_t cpu_get_state(void *cpu)
640 return ((cpu_Cas01_t) cpu)->state_current;
643 static double cpu_get_speed(void *cpu, double load)
645 return load * (((cpu_Cas01_t) cpu)->power_peak);
648 static double cpu_get_available_speed(void *cpu)
650 /* number between 0 and 1 */
651 return ((cpu_Cas01_t) cpu)->power_scale;
654 static void cpu_finalize(void)
656 lmm_system_free(cpu_maxmin_system);
657 cpu_maxmin_system = NULL;
659 surf_model_exit(surf_cpu_model);
660 surf_cpu_model = NULL;
662 xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
663 cpu_running_action_set_that_does_not_need_being_checked = NULL;
665 xbt_heap_free(cpu_action_heap);
668 static void surf_cpu_model_init_internal()
670 s_surf_action_t action;
671 s_surf_action_cpu_Cas01_t comp;
673 surf_cpu_model = surf_model_init();
675 cpu_running_action_set_that_does_not_need_being_checked =
676 xbt_swag_new(xbt_swag_offset(action, state_hookup));
678 surf_cpu_model->name = "cpu";
680 surf_cpu_model->action_unref = cpu_action_unref;
681 surf_cpu_model->action_cancel = cpu_action_cancel;
682 surf_cpu_model->action_state_set = cpu_action_state_set;
684 surf_cpu_model->model_private->resource_used = cpu_resource_used;
686 if (cpu_update_mechanism == UM_LAZY) {
687 surf_cpu_model->model_private->share_resources =
688 cpu_share_resources_lazy;
689 surf_cpu_model->model_private->update_actions_state =
690 cpu_update_actions_state_lazy;
691 } else if (cpu_update_mechanism == UM_FULL) {
692 surf_cpu_model->model_private->share_resources =
693 cpu_share_resources_full;
694 surf_cpu_model->model_private->update_actions_state =
695 cpu_update_actions_state_full;
697 xbt_die("Invalid update mechanism!");
699 surf_cpu_model->model_private->update_resource_state =
700 cpu_update_resource_state;
701 surf_cpu_model->model_private->finalize = cpu_finalize;
703 surf_cpu_model->suspend = cpu_action_suspend;
704 surf_cpu_model->resume = cpu_action_resume;
705 surf_cpu_model->is_suspended = cpu_action_is_suspended;
706 surf_cpu_model->set_max_duration = cpu_action_set_max_duration;
707 surf_cpu_model->set_priority = cpu_action_set_priority;
709 surf_cpu_model->set_category = cpu_action_set_category;
711 surf_cpu_model->get_remains = cpu_action_get_remains;
713 surf_cpu_model->extension.cpu.execute = cpu_execute;
714 surf_cpu_model->extension.cpu.sleep = cpu_action_sleep;
716 surf_cpu_model->extension.cpu.get_state = cpu_get_state;
717 surf_cpu_model->extension.cpu.get_speed = cpu_get_speed;
718 surf_cpu_model->extension.cpu.get_available_speed =
719 cpu_get_available_speed;
720 surf_cpu_model->extension.cpu.create_resource = cpu_create_resource;
721 surf_cpu_model->extension.cpu.add_traces = cpu_add_traces_cpu;
723 if (!cpu_maxmin_system) {
724 cpu_maxmin_system = lmm_system_new(cpu_selective_update);
726 if (cpu_update_mechanism == UM_LAZY) {
727 cpu_action_heap = xbt_heap_new(8, NULL);
728 xbt_heap_set_update_callback(cpu_action_heap,
729 net_action_update_index_heap);
731 xbt_swag_new(xbt_swag_offset(comp, generic_lmm_action.action_list_hookup));
732 cpu_maxmin_system->keep_track = cpu_modified_set;
736 /*********************************************************************/
737 /* Basic sharing model for CPU: that is where all this started... ;) */
738 /*********************************************************************/
739 /* @InProceedings{casanova01simgrid, */
740 /* author = "H. Casanova", */
741 /* booktitle = "Proceedings of the IEEE Symposium on Cluster Computing */
742 /* and the Grid (CCGrid'01)", */
743 /* publisher = "IEEE Computer Society", */
744 /* title = "Simgrid: {A} Toolkit for the Simulation of Application */
748 /* note = "Available at */
749 /* \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
752 void surf_cpu_model_init_Cas01()
754 char *optim = xbt_cfg_get_string(_surf_cfg_set, "cpu/optim");
756 xbt_cfg_get_int(_surf_cfg_set, "cpu/maxmin_selective_update");
758 if (!strcmp(optim, "Full")) {
759 cpu_update_mechanism = UM_FULL;
760 cpu_selective_update = select;
761 } else if (!strcmp(optim, "Lazy")) {
762 cpu_update_mechanism = UM_LAZY;
763 cpu_selective_update = 1;
764 xbt_assert((select == 1)
766 (xbt_cfg_is_default_value
767 (_surf_cfg_set, "cpu/maxmin_selective_update")),
768 "Disabling selective update while using the lazy update mechanism is dumb!");
769 } else if (!strcmp(optim, "TI")) {
770 surf_cpu_model_init_ti();
773 xbt_die("Unsupported optimization (%s) for this model", optim);
778 surf_cpu_model_init_internal();
779 cpu_define_callbacks();
780 xbt_dynar_push(model_list, &surf_cpu_model);