Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] Guard expensive computations with TRACE_is_active.
authorArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Mon, 16 May 2011 07:51:45 +0000 (09:51 +0200)
committerArnaud Giersch <arnaud.giersch@iut-bm.univ-fcomte.fr>
Tue, 17 May 2011 09:09:17 +0000 (11:09 +0200)
src/surf/cpu.c
src/surf/cpu_im.c
src/surf/network.c
src/surf/network_gtnets.c
src/surf/network_im.c

index 0e6fe65..ee98eed 100644 (file)
@@ -201,17 +201,19 @@ static void cpu_update_actions_state(double now, double delta)
 
   xbt_swag_foreach_safe(action, next_action, running_actions) {
 #ifdef HAVE_TRACING
-    cpu_Cas01_t x =
+    if (TRACE_is_active()) {
+      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);
-    TRACE_last_timestamp_to_dump = now-delta;
+      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);
+      TRACE_last_timestamp_to_dump = now-delta;
+    }
 #endif
     double_update(&(action->generic_action.remains),
                   lmm_variable_getvalue(action->variable) * delta);
index 11b9aaa..327469d 100644 (file)
@@ -234,15 +234,17 @@ static void cpu_im_update_remains(cpu_Cas01_im_t cpu, double now)
                                           (action).variable) * (now -
                                                                 cpu->last_update));
 #ifdef HAVE_TRACING
-      TRACE_surf_host_set_utilization(cpu->generic_resource.name,
-                                      action->
-                                      generic_lmm_action.generic_action.
-                                      data, (surf_action_t) action,
-                                      lmm_variable_getvalue
-                                      (GENERIC_LMM_ACTION
-                                       (action).variable),
-                                      cpu->last_update,
-                                      now - cpu->last_update);
+      if (TRACE_is_active()) {
+        TRACE_surf_host_set_utilization(cpu->generic_resource.name,
+                                        action->
+                                        generic_lmm_action.generic_action.
+                                        data, (surf_action_t) action,
+                                        lmm_variable_getvalue
+                                        (GENERIC_LMM_ACTION
+                                         (action).variable),
+                                        cpu->last_update,
+                                        now - cpu->last_update);
+      }
 #endif
       XBT_DEBUG("Update action(%p) remains %lf", action,
              GENERIC_ACTION(action).remains);
@@ -325,7 +327,7 @@ static void cpu_im_update_actions_state(double now, double delta)
     GENERIC_ACTION(action).finish = surf_get_clock();
     /* set the remains to 0 due to precision problems when updating the remaining amount */
 #ifdef HAVE_TRACING
-    {
+    if (TRACE_is_active()) {
       cpu_Cas01_im_t cpu = ((cpu_Cas01_im_t)(action->cpu));
       TRACE_surf_host_set_utilization(cpu->generic_resource.name,
           action->generic_lmm_action.generic_action.data,
@@ -340,7 +342,7 @@ static void cpu_im_update_actions_state(double now, double delta)
     cpu_im_update_remains(action->cpu, surf_get_clock());
   }
 #ifdef HAVE_TRACING
-  {
+  if (TRACE_is_active()) {
     //defining the last timestamp that we can safely dump to trace file
     //without losing the event ascending order (considering all CPU's)
     void **data;
index 5c61ee9..bbdd940 100644 (file)
@@ -733,9 +733,12 @@ static surf_action_t net_communicate(const char *src_name,
   /* LARGE PLATFORMS HACK:
      expand also with src->link and dst->link */
 #ifdef HAVE_TRACING
-  action->src_name = xbt_strdup(src_name);
-
-  action->dst_name = xbt_strdup(dst_name);
+  if (TRACE_is_active()) {
+    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);
index f36429d..4ef677c 100644 (file)
@@ -298,11 +298,11 @@ static void update_actions_state(double now, double delta)
              action->generic_action.remains);
 
 #ifdef HAVE_TRACING
-      double last_amount_sent = (action->generic_action.cost - action->last_remains);
-      double amount_sent = (action->generic_action.cost - action->generic_action.remains);
-
-      // tracing resource utilization
       if (TRACE_is_active()) {
+        double last_amount_sent = (action->generic_action.cost - action->last_remains);
+        double amount_sent = (action->generic_action.cost - action->generic_action.remains);
+
+        // tracing resource utilization
         xbt_dynar_t route = global_routing->get_route(action->src_name,
                                                       action->dst_name);
         network_link_GTNETS_t link;
index 3b1e091..38513f4 100644 (file)
@@ -781,9 +781,12 @@ static surf_action_t im_net_communicate(const char *src_name,
   /* LARGE PLATFORMS HACK:
      expand also with src->link and dst->link */
 #ifdef HAVE_TRACING
-  action->src_name = xbt_strdup(src_name);
-
-  action->dst_name = xbt_strdup(dst_name);
+  if (TRACE_is_active()) {
+    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);