Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] logging the categorized/uncategorized resource utilization tracing mechanism
[simgrid.git] / src / instr / instr_resource_utilization.c
index 87e93bb..9e0921c 100644 (file)
@@ -8,6 +8,8 @@
 
 #ifdef HAVE_TRACING
 
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_resource, instr, "tracing (un)-categorized resource utilization");
+
 //to check if variables were previously set to 0, otherwise paje won't simulate them
 static xbt_dict_t platform_variables;   /* host or link name -> array of categories */
 
@@ -37,7 +39,7 @@ static void __TRACE_surf_check_variable_set_to_zero(double now,
     xbt_dynar_t array = xbt_dynar_new(sizeof(char *), xbt_free);
     char *var_cpy = xbt_strdup(variable);
     xbt_dynar_push(array, &var_cpy);
-    if (IS_TRACING_PLATFORM)
+    if (TRACE_platform_is_enabled())
       pajeSetVariable(now, variable, resource, "0");
     xbt_dict_set(platform_variables, resource, array,
                  xbt_dynar_free_voidp);
@@ -54,7 +56,7 @@ static void __TRACE_surf_check_variable_set_to_zero(double now,
     if (flag == 0) {
       char *var_cpy = xbt_strdup(variable);
       xbt_dynar_push(array, &var_cpy);
-      if (IS_TRACING_PLATFORM)
+      if (TRACE_platform_is_enabled())
         pajeSetVariable(now, variable, resource, "0");
     }
   }
@@ -79,9 +81,6 @@ static void __TRACE_A_event(smx_action_t action, double now, double delta,
                             const char *variable, const char *resource,
                             double value)
 {
-  if (!IS_TRACING_PLATFORM)
-    return;
-
   char valuestr[100];
   snprintf(valuestr, 100, "%f", value);
 
@@ -104,9 +103,6 @@ static void __TRACE_B_alloc(void)
 
 static void __TRACE_B_release(void)
 {
-  if (!IS_TRACING_PLATFORM)
-    return;
-
   char *key, *time;
   xbt_dict_cursor_t cursor = NULL;
   xbt_dict_foreach(method_b_dict, cursor, key, time) {
@@ -132,9 +128,6 @@ static void __TRACE_B_event(smx_action_t action, double now, double delta,
                             const char *variable, const char *resource,
                             double value)
 {
-  if (!IS_TRACING_PLATFORM)
-    return;
-
   char key_time[INSTR_DEFAULT_STR_SIZE];
   char key_value[INSTR_DEFAULT_STR_SIZE];
   char nowstr[INSTR_DEFAULT_STR_SIZE];
@@ -279,7 +272,7 @@ void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
                                      double value, double now,
                                      double delta)
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
   if (!value)
     return;
@@ -294,15 +287,17 @@ void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
 
   //trace uncategorized link utilization
   if (TRACE_uncategorized()){
+    DEBUG4("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
     TRACE_surf_resource_utilization_event(smx_action, now, delta,
                                         "bandwidth_used", resource, value);
   }
 
   //trace categorized utilization
-  if (!IS_TRACED(surf_action))
+  if (!surf_action->category)
     return;
   char type[100];
   snprintf(type, 100, "b%s", surf_action->category);
+  DEBUG5("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, type, value);
   TRACE_surf_resource_utilization_event(smx_action, now, delta, type,
                                         resource, value);
   return;
@@ -317,22 +312,24 @@ void TRACE_surf_host_set_utilization(const char *name,
                                      double value, double now,
                                      double delta)
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
   if (!value)
     return;
 
   //trace uncategorized host utilization
   if (TRACE_uncategorized()){
+    DEBUG4("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, name, value);
     TRACE_surf_resource_utilization_event(smx_action, now, delta,
                                         "power_used", name, value);
   }
 
   //trace categorized utilization
-  if (!IS_TRACED(surf_action))
+  if (!surf_action->category)
     return;
   char type[100];
   snprintf(type, 100, "p%s", surf_action->category);
+  DEBUG5("CAT HOST [%f - %f] %s %s %f", now, now+delta, name, type, value);
   TRACE_surf_resource_utilization_event(smx_action, now, delta, type, name,
                                         value);
   return;
@@ -343,8 +340,9 @@ void TRACE_surf_host_set_utilization(const char *name,
  */
 void TRACE_surf_resource_utilization_start(smx_action_t action)
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
+  DEBUG1("START %p", action);
   TRACE_method_start(action);
 }
 
@@ -354,21 +352,23 @@ void TRACE_surf_resource_utilization_event(smx_action_t action, double now,
                                            const char *resource,
                                            double value)
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
+  DEBUG6("EVENT %p [%f - %f] %s %s %f", action, now, now+delta, resource, variable, value);
   TRACE_method_event(action, now, delta, variable, resource, value);
 }
 
 void TRACE_surf_resource_utilization_end(smx_action_t action)
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
   TRACE_method_end(action);
+  DEBUG1("END %p", action);
 }
 
 void TRACE_surf_resource_utilization_release()
 {
-  if (!IS_TRACING)
+  if (!TRACE_is_active())
     return;
   TRACE_method_release();
 }
@@ -402,4 +402,4 @@ void TRACE_surf_resource_utilization_alloc()
   __TRACE_define_method(TRACE_get_platform_method());
   TRACE_method_alloc();
 }
-#endif
+#endif /* HAVE_TRACING */