Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Prepare optim for xbt_lib-get_or_null
[simgrid.git] / src / surf / network.c
index de14baa..ee43820 100644 (file)
@@ -45,6 +45,12 @@ typedef struct s_smpi_factor {
   double value;
 } s_smpi_factor_t;
 
+typedef struct s_net_card *net_card_t;
+typedef struct s_net_card {
+  char* name;
+  void* routing_obj;
+} s_net_card_t;
+
 double sg_sender_gap = 0.0;
 double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
 double sg_bandwidth_factor = 1.0;       /* default value; can be set by model or from command line */
@@ -344,11 +350,6 @@ static int net_action_unref(surf_action_t action)
       heap_remove((surf_action_network_CM02_t) action);
       xbt_swag_remove(action, net_modified_set);
     }
-#ifdef HAVE_TRACING
-    xbt_free(((surf_action_network_CM02_t) action)->src_name);
-    xbt_free(((surf_action_network_CM02_t) action)->dst_name);
-    xbt_free(action->category);
-#endif
     surf_action_free(&action);
     return 1;
   }
@@ -441,10 +442,10 @@ static double net_share_resources_full(double now)
 
   xbt_swag_foreach(action, running_actions) {
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-    if (lmm_is_variable_limited_by_latency(action->variable)) {
-      GENERIC_LMM_ACTION(action).latency_limited = 1;
+    if (lmm_is_variable_limited_by_latency(GENERIC_LMM_ACTION(action).variable)) {
+      action->latency_limited = 1;
     } else {
-      GENERIC_LMM_ACTION(action).latency_limited = 0;
+      action->latency_limited = 0;
     }
 #endif
     if (action->latency > 0) {
@@ -616,6 +617,23 @@ static void net_update_actions_state_lazy(double now, double delta)
     action = xbt_heap_pop(net_action_heap);
     XBT_DEBUG("Action %p: finish", action);
     GENERIC_ACTION(action).finish = surf_get_clock();
+#ifdef HAVE_TRACING
+    if (TRACE_is_enabled()) {
+      int n = lmm_get_number_of_cnst_from_var(network_maxmin_system, GENERIC_LMM_ACTION(action).variable);
+      unsigned int i;
+      for (i = 0; i < n; i++){
+        lmm_constraint_t constraint = lmm_get_cnst_from_var(network_maxmin_system,
+                                                            GENERIC_LMM_ACTION(action).variable,
+                                                            i);
+        link_CM02_t link = lmm_constraint_id(constraint);
+        TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
+                                        ((surf_action_t)action)->category,
+                                        lmm_variable_getvalue(GENERIC_LMM_ACTION(action).variable),
+                                        GENERIC_LMM_ACTION(action).last_update,
+                                        now - GENERIC_LMM_ACTION(action).last_update);
+      }
+    }
+#endif
 
     // if I am wearing a latency hat
     if (GENERIC_LMM_ACTION(action).hat == LATENCY) {
@@ -799,7 +817,7 @@ static surf_action_t net_communicate(const char *src_name,
       surf_action_new(sizeof(s_surf_action_network_CM02_t), size,
                       surf_network_model, failed);
 #ifdef HAVE_LATENCY_BOUND_TRACKING
-  (GENERIC_LMM_ACTION(action)).latency_limited = 0;
+  action->latency_limited = 0;
 #endif
   action->weight = action->latency = latency;
 
@@ -886,14 +904,6 @@ static surf_action_t net_communicate(const char *src_name,
                  GENERIC_LMM_ACTION(action).variable, .05);
     }
   }
-#ifdef HAVE_TRACING
-  if (TRACE_is_enabled()) {
-    action->src_name = xbt_strdup(src_name);
-    action->dst_name = xbt_strdup(dst_name);
-  } else {
-    action->src_name = action->dst_name = NULL;
-  }
-#endif
 
   xbt_dynar_free(&route);
   XBT_OUT();
@@ -1122,10 +1132,6 @@ static void surf_network_model_init_internal(void)
 
 static void set_update_mechanism(void)
 {
-#ifdef HAVE_TRACING
-  TRACE_set_network_update_mechanism();
-#endif
-
   char *optim = xbt_cfg_get_string(_surf_cfg_set, "network/optim");
   int select =
       xbt_cfg_get_int(_surf_cfg_set, "network/maxmin_selective_update");