X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/07ce716b44d53a070fc2358ec727bb1975198200..936c8368c87c5a08ecc141096aca846cbc10a194:/src/surf/cpu.c diff --git a/src/surf/cpu.c b/src/surf/cpu.c index d37afd514c..4dcc8adf2a 100644 --- a/src/surf/cpu.c +++ b/src/surf/cpu.c @@ -1,6 +1,5 @@ -/* $Id$ */ - -/* Copyright (c) 2004 Arnaud Legrand. All rights reserved. */ +/* Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009, 2010. The SimGrid Team. + * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ @@ -62,6 +61,9 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak, xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, surf_resource_free); +#ifdef HAVE_TRACING + TRACE_surf_host_declaration (name, cpu->power_scale * cpu->power_peak); +#endif return cpu; } @@ -149,6 +151,9 @@ static int cpu_action_unref(surf_action_t action) if (((surf_action_cpu_Cas01_t) action)->variable) lmm_variable_free(cpu_maxmin_system, ((surf_action_cpu_Cas01_t) action)->variable); +#ifdef HAVE_TRACING + if (action->category) xbt_free (action->category); +#endif free(action); return 1; } @@ -190,6 +195,12 @@ static void cpu_update_actions_state(double now, double delta) xbt_swag_t running_actions = surf_cpu_model->states.running_action_set; xbt_swag_foreach_safe(action, next_action, running_actions) { +#ifdef HAVE_TRACING + cpu_Cas01_t x = lmm_constraint_id(lmm_get_cnst_from_var (cpu_maxmin_system, action->variable, 0)); + + TRACE_surf_host_set_utilization (x->generic_resource.name, + action->generic_action.data, (surf_action_t)action, lmm_variable_getvalue(action->variable), now-delta, delta); +#endif double_update(&(action->generic_action.remains), lmm_variable_getvalue(action->variable) * delta); if (action->generic_action.max_duration != NO_MAX_DURATION) @@ -218,6 +229,9 @@ static void cpu_update_resource_state(void *id, cpu->power_scale = value; lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint, cpu->power_scale * cpu->power_peak); +#ifdef HAVE_TRACING + TRACE_surf_host_set_power (date, cpu->generic_resource.name, cpu->power_scale * cpu->power_peak); +#endif if (tmgr_trace_event_free(event_type)) cpu->power_event = NULL; } else if (event_type == cpu->state_event) { @@ -367,6 +381,17 @@ static double cpu_get_available_speed(void *cpu) return ((cpu_Cas01_t) cpu)->power_scale; } +static void cpu_create_resource(char *name, double power_peak, + double power_scale, + tmgr_trace_t power_trace, + e_surf_resource_state_t state_initial, + tmgr_trace_t state_trace, + xbt_dict_t cpu_properties) +{ + cpu_new(name,power_peak,power_scale,power_trace, + state_initial,state_trace,cpu_properties); +} + static void cpu_finalize(void) { lmm_system_free(cpu_maxmin_system); @@ -414,6 +439,8 @@ static void surf_cpu_model_init_internal(void) surf_cpu_model->extension.cpu.get_state = cpu_get_state; surf_cpu_model->extension.cpu.get_speed = cpu_get_speed; surf_cpu_model->extension.cpu.get_available_speed = cpu_get_available_speed; + surf_cpu_model->extension.cpu.create_resource = cpu_create_resource; + surf_cpu_model->extension.cpu.add_traces = add_traces_cpu; if (!cpu_maxmin_system) cpu_maxmin_system = lmm_system_new();