Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
kill all free_string functions declared locally to cleanup dynars afterward, and...
[simgrid.git] / src / surf / workstation_ptask_L07.c
index 2298b43..ec0c05e 100644 (file)
@@ -361,7 +361,7 @@ static void update_actions_state(double now, double delta)
 
 static void update_resource_state(void *id,
                                  tmgr_trace_event_t event_type,
-                                 double value)
+                                 double value, double date)
 {
   cpu_L07_t cpu = id;
   link_L07_t nw_link = id;
@@ -375,10 +375,11 @@ static void update_resource_state(void *id,
     } else if (event_type == nw_link->lat_event) {
       lmm_variable_t var = NULL;
       surf_action_workstation_L07_t action = NULL;
+      lmm_element_t elem = NULL;
 
       nw_link->lat_current = value;
-      while (lmm_get_var_from_cnst
-            (ptask_maxmin_system, nw_link->constraint, &var)) {
+      while ((var = lmm_get_var_from_cnst
+            (ptask_maxmin_system, nw_link->constraint, &elem))) {
        
 
        action = lmm_variable_id(var);
@@ -400,7 +401,7 @@ static void update_resource_state(void *id,
     if (event_type == cpu->power_event) {
       cpu->power_current = value;
       lmm_update_constraint_bound(ptask_maxmin_system, cpu->constraint,
-                                 cpu->power_current);
+                                 cpu->power_current * cpu->power_scale);
     } else if (event_type == cpu->state_event) {
       if (value > 0)
        cpu->state_current = SURF_CPU_ON;
@@ -868,7 +869,7 @@ static void parse_route_set_endpoints(void)
 
   route_action = A_surfxml_route_action;
 
-  route_link_list = xbt_dynar_new(sizeof(char*), &free_string);
+  route_link_list = xbt_dynar_new(sizeof(char*), &xbt_free_ref);
 }
 
 static void parse_route_set_route(void)
@@ -941,19 +942,65 @@ static void add_route(void)
    xbt_dict_free(&route_table);
 }
 
-static void add_traces(void)
-{
-   xbt_dynar_t trace_connect = NULL;
-   unsigned int cpt;
-   int connect_element, connect_kind;
-   char *value, *trace_id, *connector_id;
-   link_L07_t link;
-   cpu_L07_t host = NULL;
-   tmgr_trace_t trace;
+static void add_traces(void) {   
+   xbt_dict_cursor_t cursor=NULL;
+   char *trace_name,*elm;
    
-   if (!traces_connect_list) return;
+   if (!trace_connect_list_host_avail) return;
  
-   /*for all trace connects parse them and update traces for hosts or links */
+   /* Connect traces relative to cpu */
+   xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
+      tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
+      cpu_L07_t host = xbt_dict_get_or_null(workstation_set, elm);
+      
+      xbt_assert1(host, "Host %s undefined", elm);
+      xbt_assert1(trace, "Trace %s undefined", trace_name);
+      
+      host->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, host); 
+   }
+
+   xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
+      tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
+      cpu_L07_t host = xbt_dict_get_or_null(workstation_set, elm);
+      
+      xbt_assert1(host, "Host %s undefined", elm);
+      xbt_assert1(trace, "Trace %s undefined", trace_name);
+      
+      host->power_event = tmgr_history_add_trace(history, trace, 0.0, 0, host); 
+   }
+
+   /* Connect traces relative to network */
+   xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
+      tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
+      link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+      
+      xbt_assert1(link, "Link %s undefined", elm);
+      xbt_assert1(trace, "Trace %s undefined", trace_name);
+      
+      link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+   }
+
+   xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+      tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
+      link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+      
+      xbt_assert1(link, "Link %s undefined", elm);
+      xbt_assert1(trace, "Trace %s undefined", trace_name);
+      
+      link->bw_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+   }
+   
+   xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+      tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
+      link_L07_t link = xbt_dict_get_or_null(link_set, elm);
+      
+      xbt_assert1(link, "Link %s undefined", elm);
+      xbt_assert1(trace, "Trace %s undefined", trace_name);
+      
+      link->lat_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+   }
+/*
+   
    xbt_dynar_foreach (traces_connect_list, cpt, value) {
      trace_connect = xbt_str_split_str(value, "#");
      trace_id        = xbt_dynar_get_as(trace_connect, 0, char*);
@@ -979,9 +1026,13 @@ static void add_traces(void)
         }
      }
    }
-
-   xbt_dynar_free(&trace_connect);
-   xbt_dynar_free(&traces_connect_list);
+*/
+   xbt_dict_free(&trace_connect_list_host_avail);
+   xbt_dict_free(&trace_connect_list_power);
+   xbt_dict_free(&trace_connect_list_link_avail);
+   xbt_dict_free(&trace_connect_list_bandwidth);
+   xbt_dict_free(&trace_connect_list_latency);
+   
    xbt_dict_free(&traces_set_list); 
 }