Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Added a gtnets_jitter_seed parameter enabling jitted repeatable experiments, activate...
[simgrid.git] / src / surf / cpu.c
index d8580f8..6a9f6e5 100644 (file)
@@ -7,7 +7,8 @@
 
 #include "surf_private.h"
 
-typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t, *surf_action_cpu_Cas01_t;
+typedef s_surf_action_lmm_t s_surf_action_cpu_Cas01_t,
+  *surf_action_cpu_Cas01_t;
 
 typedef struct cpu_Cas01 {
   s_surf_resource_t generic_resource;
@@ -59,7 +60,8 @@ static cpu_Cas01_t cpu_new(char *name, double power_peak,
     lmm_constraint_new(cpu_maxmin_system, cpu,
                        cpu->power_scale * cpu->power_peak);
 
-  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, surf_resource_free);
+  xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu,
+               surf_resource_free);
 
   return cpu;
 }
@@ -130,6 +132,7 @@ static void define_callbacks(const char *file)
 {
   surf_parse_reset_parser();
   surfxml_add_callback(STag_surfxml_host_cb_list, parse_cpu_init);
+  surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces_cpu);
 }
 
 static int resource_used(void *resource_id)
@@ -159,7 +162,7 @@ static void action_cancel(surf_action_t action)
 }
 
 static void cpu_action_state_set(surf_action_t action,
-                                e_surf_action_state_t state)
+                                 e_surf_action_state_t state)
 {
 /*   if((state==SURF_ACTION_DONE) || (state==SURF_ACTION_FAILED)) */
 /*     if(((surf_action_cpu_Cas01_t)action)->variable) { */
@@ -174,8 +177,8 @@ static void cpu_action_state_set(surf_action_t action,
 static double share_resources(double now)
 {
   s_surf_action_cpu_Cas01_t action;
-  return generic_maxmin_share_resources(surf_cpu_model->states.
-                                        running_action_set,
+  return generic_maxmin_share_resources(surf_cpu_model->
+                                        states.running_action_set,
                                         xbt_swag_offset(action, variable),
                                         cpu_maxmin_system, lmm_solve);
 }
@@ -215,6 +218,8 @@ static void update_resource_state(void *id,
     cpu->power_scale = value;
     lmm_update_constraint_bound(cpu_maxmin_system, cpu->constraint,
                                 cpu->power_scale * cpu->power_peak);
+    if (tmgr_trace_event_free(event_type))
+      cpu->power_event = NULL;
   } else if (event_type == cpu->state_event) {
     if (value > 0)
       cpu->state_current = SURF_RESOURCE_ON;
@@ -236,6 +241,8 @@ static void update_resource_state(void *id,
         }
       }
     }
+    if (tmgr_trace_event_free(event_type))
+      cpu->state_event = NULL;
   } else {
     CRITICAL0("Unknown event ! \n");
     xbt_abort();
@@ -250,8 +257,9 @@ static surf_action_t execute(void *cpu, double size)
   cpu_Cas01_t CPU = cpu;
 
   XBT_IN2("(%s,%g)", surf_resource_name(CPU), size);
-  action = surf_action_new(sizeof(s_surf_action_cpu_Cas01_t),size,surf_cpu_model,
-      CPU->state_current != SURF_RESOURCE_ON);
+  action =
+    surf_action_new(sizeof(s_surf_action_cpu_Cas01_t), size, surf_cpu_model,
+                    CPU->state_current != SURF_RESOURCE_ON);
 
   action->suspended = 0;        /* Should be useless because of the
                                    calloc but it seems to help valgrind... */
@@ -336,6 +344,13 @@ static void action_set_priority(surf_action_t action, double priority)
   XBT_OUT;
 }
 
+static double action_get_remains(surf_action_t action)
+{
+  XBT_IN1("(%p)", action);
+  return action->remains;
+  XBT_OUT;
+}
+
 static e_surf_resource_state_t get_state(void *cpu)
 {
   return ((cpu_Cas01_t) cpu)->state_current;
@@ -391,6 +406,8 @@ static void surf_cpu_model_init_internal(void)
   surf_cpu_model->is_suspended = action_is_suspended;
   surf_cpu_model->set_max_duration = action_set_max_duration;
   surf_cpu_model->set_priority = action_set_priority;
+  surf_cpu_model->get_remains = action_get_remains;
+
   surf_cpu_model->extension.cpu.execute = execute;
   surf_cpu_model->extension.cpu.sleep = action_sleep;