Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
graph of platform is always traced if tracing is enabled
[simgrid.git] / src / instr / interface.c
index 524bde4..f08e3ad 100644 (file)
@@ -23,6 +23,10 @@ int TRACE_start()
     return 0;
   }
 
+  if (!TRACE_is_enabled()){
+    return 0;
+  }
+
   if (IS_TRACING) {             /* what? trace is already active... ignore.. */
     THROW0(tracing_error, TRACE_ERROR_START,
            "TRACE_start called, but tracing is already active.");
@@ -48,15 +52,17 @@ int TRACE_start()
   pajeDefineContainerType("PLATFORM", "0", "platform");
   pajeDefineContainerType("HOST", "PLATFORM", "HOST");
   pajeDefineContainerType("LINK", "PLATFORM", "LINK");
+  pajeDefineVariableType("power", "HOST", "power");
+  pajeDefineVariableType("bandwidth", "LINK", "bandwidth");
+  pajeDefineVariableType("latency", "LINK", "latency");
+  pajeDefineEventType("source", "LINK", "source");
+  pajeDefineEventType("destination", "LINK", "destination");
 
   if (IS_TRACING_PLATFORM) {
-    pajeDefineVariableType("power", "HOST", "power");
-    pajeDefineVariableType("power_used", "HOST", "power_used");
-    pajeDefineVariableType("bandwidth", "LINK", "bandwidth");
-    pajeDefineVariableType("bandwidth_used", "LINK", "bandwidth_used");
-    pajeDefineVariableType("latency", "LINK", "latency");
-    pajeDefineEventType("source", "LINK", "source");
-    pajeDefineEventType("destination", "LINK", "destination");
+    if (TRACE_uncategorized()){
+      pajeDefineVariableType("power_used", "HOST", "power_used");
+      pajeDefineVariableType("bandwidth_used", "LINK", "bandwidth_used");
+    }
   }
 
   if (IS_TRACING_PROCESSES || IS_TRACING_VOLUME) {
@@ -81,7 +87,11 @@ int TRACE_start()
   }
 
   if (IS_TRACING_SMPI) {
-    pajeDefineContainerType("MPI_PROCESS", "HOST", "MPI_PROCESS");
+    if (TRACE_smpi_is_grouped()){
+      pajeDefineContainerType("MPI_PROCESS", "HOST", "MPI_PROCESS");
+    }else{
+      pajeDefineContainerType("MPI_PROCESS", "PLATFORM", "MPI_PROCESS");
+    }
     pajeDefineStateType("MPI_STATE", "MPI_PROCESS", "MPI_STATE");
     pajeDefineLinkType("MPI_LINK", "0", "MPI_PROCESS", "MPI_PROCESS",
                        "MPI_LINK");
@@ -114,6 +124,11 @@ int TRACE_end()
 }
 
 int TRACE_category(const char *category)
+{
+  return TRACE_category_with_color (category, NULL);
+}
+
+int TRACE_category_with_color (const char *category, const char *color)
 {
   static int first_time = 1;
   if (!IS_TRACING)
@@ -123,7 +138,7 @@ int TRACE_category(const char *category)
     TRACE_define_type("user_type", "0", 1);
     first_time = 0;
   }
-  return TRACE_create_category(category, "user_type", "0");
+  return TRACE_create_category_with_color(category, "user_type", "0", color);
 }
 
 void TRACE_define_type(const char *type,
@@ -164,6 +179,14 @@ void TRACE_define_type(const char *type,
 
 int TRACE_create_category(const char *category,
                           const char *type, const char *parent_category)
+{
+  return TRACE_create_category_with_color (category, type, parent_category, NULL);
+}
+
+int TRACE_create_category_with_color(const char *category,
+                          const char *type,
+                          const char *parent_category,
+                          const char *color)
 {
   char state[100];
   char *val_one = NULL;
@@ -191,14 +214,24 @@ int TRACE_create_category(const char *category,
   pajeCreateContainer(MSG_get_clock(), category, type, parent_category,
                       category);
 
-  /* for registering application categories on top of platform */
+  char final_color[INSTR_DEFAULT_STR_SIZE];
+  if (!color){
+    //generate a random color
+    double red = drand48();
+    double green = drand48();
+    double blue = drand48();
+    snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
+  }else{
+    snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
+  }
 
+  /* for registering application categories on top of platform */
   snprintf(state, 100, "b%s", category);
   if (IS_TRACING_PLATFORM)
-    pajeDefineVariableType(state, "LINK", state);
+    pajeDefineVariableTypeWithColor(state, "LINK", state, final_color);
   snprintf(state, 100, "p%s", category);
   if (IS_TRACING_PLATFORM)
-    pajeDefineVariableType(state, "HOST", state);
+    pajeDefineVariableTypeWithColor(state, "HOST", state, final_color);
 
   val_one = xbt_strdup("1");
   xbt_dict_set(created_categories, category, &val_one, xbt_free);