Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] updating the entry point functions of resource utilization tracing
[simgrid.git] / src / instr / instr_resource_utilization.c
index 5b9e795..96d21b2 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 (TRACE_platform_is_enabled())
+    if (TRACE_categorized ())
       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 (TRACE_platform_is_enabled())
+      if (TRACE_categorized ())
         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 (!TRACE_platform_is_enabled())
-    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 (!TRACE_platform_is_enabled())
-    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 (!TRACE_platform_is_enabled())
-    return;
-
   char key_time[INSTR_DEFAULT_STR_SIZE];
   char key_value[INSTR_DEFAULT_STR_SIZE];
   char nowstr[INSTR_DEFAULT_STR_SIZE];
@@ -274,7 +267,7 @@ static void __TRACE_C_end(smx_action_t action)
 /*
  * TRACE_surf_link_set_utilization: entry point from SimGrid
  */
-void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
+void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_action,
                                      surf_action_t surf_action,
                                      double value, double now,
                                      double delta)
@@ -284,34 +277,42 @@ void TRACE_surf_link_set_utilization(void *link, smx_action_t smx_action,
   if (!value)
     return;
   //only trace link utilization if link is known by tracing mechanism
-  if (!TRACE_surf_link_is_traced(link))
+  if (!instr_link_is_traced(resource))
     return;
   if (!value)
     return;
 
-  char resource[100];
-  snprintf(resource, 100, "%p", link);
+  //get link type
+  char *link_type = instr_link_type (resource);
 
   //trace uncategorized link utilization
   if (TRACE_uncategorized()){
+    DEBUG4("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
+    char bandwidth_used_type[INSTR_DEFAULT_STR_SIZE];
+    snprintf (bandwidth_used_type, INSTR_DEFAULT_STR_SIZE, "bandwidth_used-%s", link_type);
     TRACE_surf_resource_utilization_event(smx_action, now, delta,
-                                        "bandwidth_used", resource, value);
+        bandwidth_used_type, resource, value);
   }
 
   //trace categorized utilization
-  if (!IS_TRACED(surf_action))
-    return;
-  char type[100];
-  snprintf(type, 100, "b%s", surf_action->category);
-  TRACE_surf_resource_utilization_event(smx_action, now, delta, type,
-                                        resource, value);
+  if (TRACE_categorized()){
+    if (!surf_action->category)
+      return;
+
+    char cat_bw_used_type[INSTR_DEFAULT_STR_SIZE];
+    snprintf (cat_bw_used_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", surf_action->category, link_type);
+
+    DEBUG5("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, cat_bw_used_type, value);
+    TRACE_surf_resource_utilization_event(smx_action, now, delta, cat_bw_used_type,
+        resource, value);
+  }
   return;
 }
 
 /*
  * TRACE_surf_host_set_utilization: entry point from SimGrid
  */
-void TRACE_surf_host_set_utilization(const char *name,
+void TRACE_surf_host_set_utilization(const char *resource,
                                      smx_action_t smx_action,
                                      surf_action_t surf_action,
                                      double value, double now,
@@ -322,19 +323,30 @@ void TRACE_surf_host_set_utilization(const char *name,
   if (!value)
     return;
 
+  //get host type
+  char *host_type = instr_host_type (resource);
+
   //trace uncategorized host utilization
   if (TRACE_uncategorized()){
+    DEBUG4("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
+    char power_used_type[INSTR_DEFAULT_STR_SIZE];
+    snprintf (power_used_type, INSTR_DEFAULT_STR_SIZE, "power_used-%s", host_type);
     TRACE_surf_resource_utilization_event(smx_action, now, delta,
-                                        "power_used", name, value);
+        power_used_type, resource, value);
   }
 
   //trace categorized utilization
-  if (!IS_TRACED(surf_action))
-    return;
-  char type[100];
-  snprintf(type, 100, "p%s", surf_action->category);
-  TRACE_surf_resource_utilization_event(smx_action, now, delta, type, name,
-                                        value);
+  if (TRACE_categorized()){
+    if (!surf_action->category)
+      return;
+
+    char cat_p_used_type[INSTR_DEFAULT_STR_SIZE];
+    snprintf (cat_p_used_type, INSTR_DEFAULT_STR_SIZE, "%s-%s", surf_action->category, host_type);
+
+    DEBUG5("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, cat_p_used_type, value);
+    TRACE_surf_resource_utilization_event(smx_action, now, delta, cat_p_used_type, resource,
+        value);
+  }
   return;
 }
 
@@ -345,6 +357,7 @@ void TRACE_surf_resource_utilization_start(smx_action_t action)
 {
   if (!TRACE_is_active())
     return;
+  DEBUG1("START %p", action);
   TRACE_method_start(action);
 }
 
@@ -356,6 +369,7 @@ void TRACE_surf_resource_utilization_event(smx_action_t action, double now,
 {
   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);
 }
 
@@ -364,6 +378,7 @@ void TRACE_surf_resource_utilization_end(smx_action_t action)
   if (!TRACE_is_active())
     return;
   TRACE_method_end(action);
+  DEBUG1("END %p", action);
 }
 
 void TRACE_surf_resource_utilization_release()