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"
10 surf_model_t surf_cpu_model = NULL;
11 lmm_system_t cpu_maxmin_system = NULL;
19 e_UM_t update_mechanism = UM_LAZY;
21 #undef GENERIC_LMM_ACTION
24 #define GENERIC_LMM_ACTION(action) action->generic_lmm_action
25 #define GENERIC_ACTION(action) GENERIC_LMM_ACTION(action).generic_action
26 #define ACTION_GET_CPU(action) ((surf_action_cpu_Cas01_im_t) action)->cpu
28 typedef struct surf_action_cpu_cas01_im {
29 s_surf_action_lmm_t generic_lmm_action;
30 s_xbt_swag_hookup_t cpu_list_hookup;
33 } s_surf_action_cpu_Cas01_im_t, *surf_action_cpu_Cas01_im_t;
35 typedef struct cpu_Cas01_im {
36 s_surf_resource_t generic_resource;
37 s_xbt_swag_hookup_t modified_cpu_hookup;
40 tmgr_trace_event_t power_event;
42 e_surf_resource_state_t state_current;
43 tmgr_trace_event_t state_event;
44 lmm_constraint_t constraint;
45 xbt_swag_t action_set;
47 } s_cpu_Cas01_im_t, *cpu_Cas01_im_t;
49 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_im, surf,
50 "Logging specific to the SURF CPU IMPROVED module");
52 lmm_system_t cpu_im_maxmin_system = NULL;
53 static xbt_swag_t cpu_im_modified_cpu = NULL;
54 static xbt_heap_t cpu_im_action_heap = NULL;
55 extern int sg_maxmin_selective_update;
59 cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
61 static void* cpu_im_create_resource(const char *name, double power_peak,
63 tmgr_trace_t power_trace,
65 e_surf_resource_state_t state_initial,
66 tmgr_trace_t state_trace,
67 xbt_dict_t cpu_properties)
69 cpu_Cas01_im_t cpu = NULL;
70 s_surf_action_cpu_Cas01_im_t action;
72 xbt_assert(!surf_cpu_resource_by_name(name),
73 "Host '%s' declared several times in the platform file",
75 cpu = (cpu_Cas01_im_t) surf_resource_new(sizeof(s_cpu_Cas01_im_t),
76 surf_cpu_model, name,cpu_properties);
77 cpu->power_peak = power_peak;
78 xbt_assert(cpu->power_peak > 0, "Power has to be >0");
79 cpu->power_scale = power_scale;
81 xbt_assert(core>0,"Invalid number of cores %d",core);
85 tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
87 cpu->state_current = state_initial;
90 tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
93 lmm_constraint_new(cpu_im_maxmin_system, cpu,
94 cpu->core * cpu->power_scale * cpu->power_peak);
96 xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
97 if(update_mechanism == UM_FULL)
98 cpu->action_set = xbt_swag_new(xbt_swag_offset(action, cpu_list_hookup));
104 static void parse_cpu_im_init(sg_platf_host_cbarg_t host)
106 cpu_im_create_resource(host->id,
116 static void cpu_im_add_traces_cpu(void)
118 xbt_dict_cursor_t cursor = NULL;
119 char *trace_name, *elm;
120 static int called = 0;
125 /* connect all traces relative to hosts */
126 xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
127 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
128 cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
130 xbt_assert(host, "Host %s undefined", elm);
131 xbt_assert(trace, "Trace %s undefined", trace_name);
134 tmgr_history_add_trace(history, trace, 0.0, 0, host);
137 xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
138 tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
139 cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
141 xbt_assert(host, "Host %s undefined", elm);
142 xbt_assert(trace, "Trace %s undefined", trace_name);
145 tmgr_history_add_trace(history, trace, 0.0, 0, host);
149 static void cpu_im_define_callbacks()
151 sg_platf_host_add_cb(parse_cpu_im_init);
152 sg_platf_postparse_add_cb(cpu_im_add_traces_cpu);
155 static int cpu_im_resource_used(void *resource)
157 return lmm_constraint_used(cpu_im_maxmin_system,
158 ((cpu_Cas01_im_t) resource)->constraint);
161 static int cpu_im_action_unref(surf_action_t action)
164 if (!action->refcount) {
165 xbt_swag_remove(action, action->state_set);
166 if (((surf_action_lmm_t) action)->variable)
167 lmm_variable_free(cpu_im_maxmin_system,
168 ((surf_action_lmm_t) action)->variable);
169 if(update_mechanism == UM_FULL){
170 /* remove from heap */
171 xbt_heap_remove(cpu_im_action_heap,
172 ((surf_action_cpu_Cas01_im_t) action)->index_heap);
173 xbt_swag_remove(action,
174 ((cpu_Cas01_im_t) ACTION_GET_CPU(action))->action_set);
175 xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
178 xbt_free(action->category);
180 surf_action_free(&action);
186 static void cpu_im_action_cancel(surf_action_t action)
188 surf_action_state_set(action, SURF_ACTION_FAILED);
189 if(update_mechanism == UM_FULL){
190 xbt_heap_remove(cpu_im_action_heap,
191 ((surf_action_cpu_Cas01_im_t) action)->index_heap);
192 xbt_swag_remove(action,
193 ((cpu_Cas01_im_t) ACTION_GET_CPU(action))->action_set);
198 static void cpu_im_cpu_action_state_set(surf_action_t action,
199 e_surf_action_state_t state)
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; */
207 surf_action_state_set(action, state);
211 static void cpu_im_update_remains(cpu_Cas01_im_t cpu, double now)
213 surf_action_cpu_Cas01_im_t action;
215 if (cpu->last_update >= now)
217 xbt_swag_foreach(action, cpu->action_set) {
218 if (GENERIC_ACTION(action).state_set !=
219 surf_cpu_model->states.running_action_set)
222 /* bogus priority, skip it */
223 if (GENERIC_ACTION(action).priority <= 0)
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 -
232 if (TRACE_is_enabled()) {
233 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
235 generic_lmm_action.generic_action.
236 data, (surf_action_t) action,
237 lmm_variable_getvalue
241 now - cpu->last_update);
244 XBT_DEBUG("Update action(%p) remains %lf", action,
245 GENERIC_ACTION(action).remains);
248 cpu->last_update = now;
251 static double cpu_im_share_resources(double now)
253 surf_action_cpu_Cas01_im_t action;
256 cpu_Cas01_im_t cpu, cpu_next;
258 xbt_swag_foreach(cpu, cpu_im_modified_cpu)
259 cpu_im_update_remains(cpu, now);
261 lmm_solve(cpu_im_maxmin_system);
263 xbt_swag_foreach_safe(cpu, cpu_next, cpu_im_modified_cpu) {
264 xbt_swag_foreach(action, cpu->action_set) {
265 if (GENERIC_ACTION(action).state_set !=
266 surf_cpu_model->states.running_action_set)
269 /* bogus priority, skip it */
270 if (GENERIC_ACTION(action).priority <= 0)
274 value = lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable);
276 if (GENERIC_ACTION(action).remains > 0) {
277 value = GENERIC_ACTION(action).remains / value;
285 if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION)
287 || GENERIC_ACTION(action).start +
288 GENERIC_ACTION(action).max_duration < min))
290 GENERIC_ACTION(action).start +
291 GENERIC_ACTION(action).max_duration;
293 XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
294 GENERIC_ACTION(action).start, now + value,
295 GENERIC_ACTION(action).max_duration);
297 if (action->index_heap >= 0) {
298 surf_action_cpu_Cas01_im_t heap_act =
299 xbt_heap_remove(cpu_im_action_heap, action->index_heap);
300 if (heap_act != action)
304 xbt_heap_push(cpu_im_action_heap, action, min);
305 XBT_DEBUG("Insert at heap action(%p) min %lf", action, min);
308 xbt_swag_remove(cpu, cpu_im_modified_cpu);
310 return xbt_heap_size(cpu_im_action_heap) >
311 0 ? xbt_heap_maxkey(cpu_im_action_heap) - now : -1;
314 static void cpu_im_update_actions_state(double now, double delta)
316 surf_action_cpu_Cas01_im_t action;
317 while ((xbt_heap_size(cpu_im_action_heap) > 0)
318 && (double_equals(xbt_heap_maxkey(cpu_im_action_heap), now))) {
319 action = xbt_heap_pop(cpu_im_action_heap);
320 XBT_DEBUG("Action %p: finish", action);
321 GENERIC_ACTION(action).finish = surf_get_clock();
322 /* set the remains to 0 due to precision problems when updating the remaining amount */
324 if (TRACE_is_enabled()) {
325 cpu_Cas01_im_t cpu = ((cpu_Cas01_im_t)(action->cpu));
326 TRACE_surf_host_set_utilization(cpu->generic_resource.name,
327 GENERIC_LMM_ACTION(action).generic_action.data,
328 (surf_action_t) action,
329 lmm_variable_getvalue (GENERIC_LMM_ACTION(action).variable),
331 now - cpu->last_update);
334 GENERIC_ACTION(action).remains = 0;
335 cpu_im_cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
336 cpu_im_update_remains(action->cpu, surf_get_clock());
339 if (TRACE_is_enabled()) {
340 //defining the last timestamp that we can safely dump to trace file
341 //without losing the event ascending order (considering all CPU's)
344 xbt_lib_cursor_t cursor;
347 xbt_lib_foreach(host_lib, cursor, key, data){
348 if(data[SURF_CPU_LEVEL]){
349 cpu = data[SURF_CPU_LEVEL];
351 smaller = cpu->last_update;
354 if (cpu->last_update < smaller){
355 smaller = cpu->last_update;
360 TRACE_last_timestamp_to_dump = smaller;
367 static void cpu_im_update_resource_state(void *id,
368 tmgr_trace_event_t event_type,
369 double value, double date)
371 cpu_Cas01_im_t cpu = id;
372 lmm_variable_t var = NULL;
373 lmm_element_t elem = NULL;
375 if (event_type == cpu->power_event) {
376 cpu->power_scale = value;
377 lmm_update_constraint_bound(cpu_im_maxmin_system, cpu->constraint,
378 cpu->core * cpu->power_scale * cpu->power_peak);
380 TRACE_surf_host_set_power(date, cpu->generic_resource.name,
381 cpu->core * cpu->power_scale * cpu->power_peak);
383 while ((var = lmm_get_var_from_cnst
384 (cpu_im_maxmin_system, cpu->constraint, &elem))) {
385 surf_action_cpu_Cas01_im_t action = lmm_variable_id(var);
386 lmm_update_variable_bound(cpu_im_maxmin_system, GENERIC_LMM_ACTION(action).variable,
387 cpu->power_scale * cpu->power_peak);
389 if(update_mechanism == UM_FULL)
390 xbt_swag_insert(cpu, cpu_im_modified_cpu);
391 if (tmgr_trace_event_free(event_type))
392 cpu->power_event = NULL;
393 } else if (event_type == cpu->state_event) {
395 cpu->state_current = SURF_RESOURCE_ON;
397 lmm_constraint_t cnst = cpu->constraint;
398 lmm_variable_t var = NULL;
399 lmm_element_t elem = NULL;
401 cpu->state_current = SURF_RESOURCE_OFF;
404 lmm_get_var_from_cnst(cpu_im_maxmin_system, cnst, &elem))) {
405 surf_action_t action = lmm_variable_id(var);
407 if (surf_action_state_get(action) == SURF_ACTION_RUNNING ||
408 surf_action_state_get(action) == SURF_ACTION_READY ||
409 surf_action_state_get(action) ==
410 SURF_ACTION_NOT_IN_THE_SYSTEM) {
411 action->finish = date;
412 cpu_im_cpu_action_state_set(action, SURF_ACTION_FAILED);
416 if (tmgr_trace_event_free(event_type))
417 cpu->state_event = NULL;
419 XBT_CRITICAL("Unknown event ! \n");
426 static surf_action_t cpu_im_execute(void *cpu, double size)
428 surf_action_cpu_Cas01_im_t action = NULL;
429 cpu_Cas01_im_t CPU = cpu;
431 XBT_IN("(%s,%g)", surf_resource_name(CPU), size);
433 surf_action_new(sizeof(s_surf_action_cpu_Cas01_im_t), size,
435 CPU->state_current != SURF_RESOURCE_ON);
437 GENERIC_LMM_ACTION(action).suspended = 0; /* Should be useless because of the
438 calloc but it seems to help valgrind... */
440 GENERIC_LMM_ACTION(action).variable =
441 lmm_variable_new(cpu_im_maxmin_system, action,
442 GENERIC_ACTION(action).priority, CPU->power_scale * CPU->power_peak, 1);
443 if(update_mechanism == UM_FULL){
444 action->index_heap = -1;
446 xbt_swag_insert(CPU, cpu_im_modified_cpu);
447 xbt_swag_insert(action, CPU->action_set);
449 lmm_expand(cpu_im_maxmin_system, CPU->constraint,
450 GENERIC_LMM_ACTION(action).variable, 1.0);
452 return (surf_action_t) action;
455 static surf_action_t cpu_im_action_sleep(void *cpu, double duration)
457 surf_action_cpu_Cas01_im_t action = NULL;
460 duration = MAX(duration, MAXMIN_PRECISION);
462 XBT_IN("(%s,%g)", surf_resource_name(cpu), duration);
463 action = (surf_action_cpu_Cas01_im_t) cpu_im_execute(cpu, 1.0);
464 GENERIC_ACTION(action).max_duration = duration;
465 GENERIC_LMM_ACTION(action).suspended = 2;
466 if (duration == NO_MAX_DURATION) {
467 /* Move to the *end* of the corresponding action set. This convention
468 is used to speed up update_resource_state */
469 xbt_swag_remove(action, ((surf_action_t) action)->state_set);
470 ((surf_action_t) action)->state_set =
471 cpu_im_running_action_set_that_does_not_need_being_checked;
472 xbt_swag_insert(action, ((surf_action_t) action)->state_set);
475 lmm_update_variable_weight(cpu_im_maxmin_system,
476 GENERIC_LMM_ACTION(action).variable, 0.0);
477 if(update_mechanism == UM_FULL)
478 xbt_swag_insert(cpu, cpu_im_modified_cpu);
480 return (surf_action_t) action;
483 static void cpu_im_action_suspend(surf_action_t action)
485 XBT_IN("(%p)", action);
486 if (((surf_action_lmm_t) action)->suspended != 2) {
487 lmm_update_variable_weight(cpu_im_maxmin_system,
488 ((surf_action_lmm_t) action)->variable,
490 ((surf_action_lmm_t) action)->suspended = 1;
491 if(update_mechanism == UM_FULL){
492 xbt_heap_remove(cpu_im_action_heap,
493 ((surf_action_cpu_Cas01_im_t) action)->index_heap);
494 xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
500 static void cpu_im_action_resume(surf_action_t action)
503 XBT_IN("(%p)", action);
504 if (((surf_action_lmm_t) action)->suspended != 2) {
505 lmm_update_variable_weight(cpu_im_maxmin_system,
506 ((surf_action_lmm_t) action)->variable,
508 ((surf_action_lmm_t) action)->suspended = 0;
509 if(update_mechanism == UM_FULL)
510 xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
515 static int cpu_im_action_is_suspended(surf_action_t action)
517 return (((surf_action_lmm_t) action)->suspended == 1);
520 static void cpu_im_action_set_max_duration(surf_action_t action,
523 XBT_IN("(%p,%g)", action, duration);
525 action->max_duration = duration;
526 /* insert cpu in modified_cpu set to notice the max duration change */
527 if(update_mechanism == UM_FULL)
528 xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
532 static void cpu_im_action_set_priority(surf_action_t action,
535 XBT_IN("(%p,%g)", action, priority);
536 action->priority = priority;
537 lmm_update_variable_weight(cpu_im_maxmin_system,
538 ((surf_action_lmm_t) action)->variable,
541 if(update_mechanism == UM_FULL)
542 xbt_swag_insert(ACTION_GET_CPU(action), cpu_im_modified_cpu);
547 static void cpu_im_action_set_category(surf_action_t action,
548 const char *category)
550 XBT_IN("(%p,%s)", action, category);
551 action->category = xbt_strdup (category);
556 static double cpu_im_action_get_remains(surf_action_t action)
558 XBT_IN("(%p)", action);
559 /* update remains before return it */
560 if(update_mechanism == UM_FULL)
561 cpu_im_update_remains(ACTION_GET_CPU(action), surf_get_clock());
562 return action->remains;
566 static e_surf_resource_state_t cpu_im_get_state(void *cpu)
568 return ((cpu_Cas01_im_t) cpu)->state_current;
571 static double cpu_im_get_speed(void *cpu, double load)
573 return load * (((cpu_Cas01_im_t) cpu)->power_peak);
576 static double cpu_im_get_available_speed(void *cpu)
578 /* number between 0 and 1 */
579 return ((cpu_Cas01_im_t) cpu)->power_scale;
582 static void cpu_im_action_update_index_heap(void *action, int i)
584 ((surf_action_cpu_Cas01_im_t) action)->index_heap = i;
587 static void cpu_im_finalize(void)
590 xbt_lib_cursor_t cursor;
593 xbt_lib_foreach(host_lib, cursor, key, cpu){
594 if(cpu[SURF_CPU_LEVEL])
596 cpu_Cas01_im_t CPU = cpu[SURF_CPU_LEVEL];
597 xbt_swag_free(CPU->action_set);
601 lmm_system_free(cpu_im_maxmin_system);
602 cpu_im_maxmin_system = NULL;
604 surf_model_exit(surf_cpu_model);
605 surf_cpu_model = NULL;
608 (cpu_im_running_action_set_that_does_not_need_being_checked);
609 cpu_im_running_action_set_that_does_not_need_being_checked = NULL;
610 if(cpu_im_action_heap) xbt_heap_free(cpu_im_action_heap);
611 if(cpu_im_modified_cpu) xbt_swag_free(cpu_im_modified_cpu);
614 static void surf_cpu_im_model_init_internal(const char* name)
616 s_surf_action_t action;
617 s_cpu_Cas01_im_t cpu;
619 surf_cpu_model = surf_model_init();
621 cpu_im_running_action_set_that_does_not_need_being_checked =
622 xbt_swag_new(xbt_swag_offset(action, state_hookup));
624 surf_cpu_model->name = name;
626 surf_cpu_model->action_unref = cpu_im_action_unref;
627 surf_cpu_model->action_cancel = cpu_im_action_cancel;
628 surf_cpu_model->action_state_set = cpu_im_cpu_action_state_set;
630 surf_cpu_model->model_private->resource_used = cpu_im_resource_used;
631 surf_cpu_model->model_private->share_resources = generic_share_resources;
632 surf_cpu_model->model_private->update_actions_state =
633 generic_update_actions_state;//ok
634 surf_cpu_model->model_private->update_resource_state =
635 cpu_im_update_resource_state;//ok
636 surf_cpu_model->model_private->finalize = cpu_im_finalize;
638 surf_cpu_model->suspend = cpu_im_action_suspend;
639 surf_cpu_model->resume = cpu_im_action_resume;
640 surf_cpu_model->is_suspended = cpu_im_action_is_suspended;
641 surf_cpu_model->set_max_duration = cpu_im_action_set_max_duration;
642 surf_cpu_model->set_priority = cpu_im_action_set_priority;
644 surf_cpu_model->set_category = cpu_im_action_set_category;
646 surf_cpu_model->get_remains = cpu_im_action_get_remains;
648 surf_cpu_model->extension.cpu.execute = cpu_im_execute;
649 surf_cpu_model->extension.cpu.sleep = cpu_im_action_sleep;
651 surf_cpu_model->extension.cpu.get_state = cpu_im_get_state;
652 surf_cpu_model->extension.cpu.get_speed = cpu_im_get_speed;
653 surf_cpu_model->extension.cpu.get_available_speed =
654 cpu_im_get_available_speed;
655 surf_cpu_model->extension.cpu.create_resource = cpu_im_create_resource;
656 surf_cpu_model->extension.cpu.add_traces = cpu_im_add_traces_cpu;
658 if (!cpu_im_maxmin_system) {
659 sg_maxmin_selective_update = 1;
660 cpu_im_maxmin_system = lmm_system_new();
662 if(update_mechanism == UM_FULL){
663 cpu_im_action_heap = xbt_heap_new(8, NULL);
664 xbt_heap_set_update_callback(cpu_im_action_heap,
665 cpu_im_action_update_index_heap);
666 cpu_im_modified_cpu =
667 xbt_swag_new(xbt_swag_offset(cpu, modified_cpu_hookup));
671 /*********************************************************************/
672 /* Basic sharing model for CPU: that is where all this started... ;) */
673 /*********************************************************************/
674 /* @InProceedings{casanova01simgrid, */
675 /* author = "H. Casanova", */
676 /* booktitle = "Proceedings of the IEEE Symposium on Cluster Computing */
677 /* and the Grid (CCGrid'01)", */
678 /* publisher = "IEEE Computer Society", */
679 /* title = "Simgrid: {A} Toolkit for the Simulation of Application */
683 /* note = "Available at */
684 /* \url{http://grail.sdsc.edu/papers/simgrid_ccgrid01.ps.gz}." */
687 void surf_cpu_model_init_Cas01_im()
690 if( strcmp(xbt_cfg_get_string(_surf_cfg_set, "cpu/model"),"Cas01"))
691 update_mechanism = UM_FULL;
693 update_mechanism = UM_LAZY;
697 surf_cpu_im_model_init_internal("CPU");
698 cpu_im_define_callbacks();
699 xbt_dynar_push(model_list, &surf_cpu_model);
702 double generic_share_resources(double now)
704 surf_action_cpu_Cas01_im_t action;
705 if(update_mechanism == UM_FULL)
706 return cpu_im_share_resources(now);
707 else if (update_mechanism == UM_LAZY)
709 return generic_maxmin_share_resources(surf_cpu_model->states.running_action_set,
710 xbt_swag_offset(*action, generic_lmm_action.variable),
711 cpu_im_maxmin_system, lmm_solve);
713 xbt_die("Invalide update mechanism!");
718 static void cpu_update_actions_state(double now, double delta)
720 surf_action_cpu_Cas01_im_t action = NULL;
721 surf_action_cpu_Cas01_im_t next_action = NULL;
722 xbt_swag_t running_actions = surf_cpu_model->states.running_action_set;
723 xbt_swag_foreach_safe(action, next_action, running_actions) {
725 if (TRACE_is_enabled()) {
727 lmm_constraint_id(lmm_get_cnst_from_var
728 (cpu_maxmin_system, GENERIC_LMM_ACTION(action).variable, 0));
730 TRACE_surf_host_set_utilization(x->generic_resource.name,
731 GENERIC_ACTION(action).data,
732 (surf_action_t) action,
733 lmm_variable_getvalue
734 (GENERIC_LMM_ACTION(action).variable), now - delta,
736 TRACE_last_timestamp_to_dump = now-delta;
739 double_update(&(GENERIC_ACTION(action).remains),
740 lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable) * delta);
741 if (GENERIC_LMM_ACTION(action).generic_action.max_duration != NO_MAX_DURATION)
742 double_update(&(GENERIC_ACTION(action).max_duration), delta);
743 if ((GENERIC_ACTION(action).remains <= 0) &&
744 (lmm_get_variable_weight(GENERIC_LMM_ACTION(action).variable) > 0)) {
745 GENERIC_ACTION(action).finish = surf_get_clock();
746 cpu_im_cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
747 } else if ((GENERIC_ACTION(action).max_duration != NO_MAX_DURATION) &&
748 (GENERIC_ACTION(action).max_duration <= 0)) {
749 GENERIC_ACTION(action).finish = surf_get_clock();
750 cpu_im_cpu_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
757 void generic_update_actions_state(double now, double delta)
759 if(update_mechanism == UM_FULL)
760 cpu_im_update_actions_state(now, delta);
761 else if(update_mechanism == UM_LAZY)
763 cpu_update_actions_state(now, delta);
766 xbt_die("Not recognized surf cpu model!");