Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
renaming some tracing functions to make easy to remember what they do
[simgrid.git] / src / instr / surf_instr.c
index 81a2be7..f1afcef 100644 (file)
@@ -11,7 +11,6 @@
  */
 
 #include "instr/private.h"
-#include "instr/config.h"
 
 #ifdef HAVE_TRACING
 
@@ -23,8 +22,7 @@ static xbt_dict_t hosts_id;
 static xbt_dict_t created_links;
 static xbt_dict_t link_bandwidth;
 static xbt_dict_t link_latency;
-//static xbt_dict_t platform_variable_last_value; /* to control the amount of add/sub variables events*/
-//static xbt_dict_t platform_variable_last_time; /* to control the amount of add/sub variables events*/
+static xbt_dict_t host_containers;
 
 static xbt_dict_t last_platform_variables; /* to control the amount of add/sub variables events:
    dict with key {RESOURCE_NAME}#Time or {RESOURCE_NAME}#Value of dict with variables types == string */
@@ -44,14 +42,9 @@ void __TRACE_surf_init (void)
   link_bandwidth = xbt_dict_new();
   link_latency = xbt_dict_new();
   platform_variables = xbt_dict_new();
-
-  //platform_variable_last_value = xbt_dict_new();
-  //platform_variable_last_time = xbt_dict_new();
-
+  host_containers = xbt_dict_new();
   last_platform_variables =  xbt_dict_new();
-
   resource_variables = xbt_dict_new ();
-
   gtnets_src = xbt_dict_new ();
   gtnets_dst = xbt_dict_new ();
 }
@@ -115,10 +108,9 @@ void __TRACE_surf_finalize (void)
       char *variable = xbt_dict_get (last_platform_variables, variablekey);
       pajeSubVariable (atof(time), variable, resource, value);
 
-      //TODO: should remove, but it is causing sigabort
-      //xbt_dict_remove (last_platform_variables, timekey);
-      //xbt_dict_remove (last_platform_variables, valuekey);
-      //xbt_dict_remove (last_platform_variables, variablekey);
+      xbt_dict_remove (last_platform_variables, timekey);
+      xbt_dict_remove (last_platform_variables, valuekey);
+      xbt_dict_remove (last_platform_variables, variablekey);
     }
   }
 }
@@ -283,7 +275,7 @@ void TRACE_surf_update_action_state_cpu_resource (const char *name, smx_action_t
   return;
 }
 
-void TRACE_surf_net_link_new (char *name, double bw, double lat)
+void TRACE_surf_link_declaration (char *name, double bw, double lat)
 {
   if (!IS_TRACING) return;
   //if (IS_TRACING_PLATFORM) pajeCreateContainerWithBandwidthLatency (SIMIX_get_clock(), name, "LINK", "platform", name, bw, lat);
@@ -297,10 +289,13 @@ void TRACE_surf_net_link_new (char *name, double bw, double lat)
   xbt_dict_set (link_latency, xbt_strdup(name), lat_ptr, xbt_free);
 }
 
-void TRACE_surf_cpu_new (char *name, double power)
+void TRACE_surf_host_declaration (char *name, double power)
 {
   if (!IS_TRACING) return;
-  if (IS_TRACING_PLATFORM) pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
+  if (IS_TRACING_PLATFORM){
+       pajeCreateContainer (SIMIX_get_clock(), name, "HOST", "platform", name);
+       xbt_dict_set (host_containers, xbt_strdup(name), xbt_strdup("1"), xbt_free);
+  }
   __TRACE_surf_set_resource_variable (SIMIX_get_clock(), "power", name, power);
 }
 
@@ -333,7 +328,7 @@ void TRACE_surf_routing_full_parse_end (char *link_name, int src, int dst)
   }
 }
 
-void TRACE_surf_cpu_set_power (double date, char *resource, double power)
+void TRACE_surf_host_set_power (double date, char *resource, double power)
 {
   __TRACE_surf_set_resource_variable (date, "power", resource, power);
 }
@@ -415,4 +410,30 @@ void TRACE_surf_missing_link (void)
   THROW0(tracing_error, TRACE_ERROR_COMPLEX_ROUTES, "Tracing failed");
 }
 
+void TRACE_msg_clean (void)
+{
+  __TRACE_surf_finalize();
+
+  xbt_dict_cursor_t cursor = NULL;
+  char *key, *value;
+
+  /* get all host from host_containers */
+  xbt_dict_foreach(host_containers, cursor, key, value) {
+    if (IS_TRACING_PLATFORM) pajeDestroyContainer (MSG_get_clock(), "HOST", key);
+  }
+}
+
+void TRACE_surf_vivaldi_parse_host (char *host, double x, double y, double h)
+{
+  if (!IS_TRACING || !IS_TRACING_PLATFORM) return;
+
+  char valuestr[100];
+  snprintf (valuestr, 100, "%g", x);
+  pajeSetVariable (0, "vivaldi_x", host, valuestr);
+  snprintf (valuestr, 100, "%g", y);
+  pajeSetVariable (0, "vivaldi_y", host, valuestr);
+  snprintf (valuestr, 100, "%g", h);
+  pajeSetVariable (0, "vivaldi_h", host, valuestr);
+}
+
 #endif