Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] cosmetics
authorschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 22 Dec 2010 18:37:48 +0000 (18:37 +0000)
committerschnorr <schnorr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Wed, 22 Dec 2010 18:37:48 +0000 (18:37 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9310 48e7efb5-ca39-0410-a469-dd3cf9ba447f

src/instr/instr_interface.c
src/instr/instr_paje.c
src/instr/instr_private.h
src/instr/instr_resource_utilization.c
src/instr/instr_routing.c
src/instr/instr_surf.c

index 263f3c6..ee767b7 100644 (file)
@@ -103,8 +103,8 @@ void TRACE_user_link_variable(double time, const char *resource,
   if (strcmp(what, "declare") == 0) {
     instr_new_user_link_variable_type (variable, NULL);
   } else{
-    char *variable_id = instr_variable_type(variable, resource);
-    char *resource_id = instr_resource_type(resource);
+    char *variable_id = getVariableTypeIdByName(variable, getContainerByName(resource)->type);
+    char *resource_id = getContainerIdByName(resource);
     if (strcmp(what, "set") == 0) {
       pajeSetVariable(time, variable_id, resource_id, valuestr);
     } else if (strcmp(what, "add") == 0) {
@@ -131,8 +131,8 @@ void TRACE_user_host_variable(double time, const char *variable,
     instr_new_user_host_variable_type (variable, NULL);
   } else{
     char *host_name = MSG_host_self()->name;
-    char *variable_id = instr_variable_type(variable, host_name);
-    char *resource_id = instr_resource_type(host_name);
+    char *variable_id = getVariableTypeIdByName(variable, getContainerByName(host_name)->type);
+    char *resource_id = getContainerIdByName(host_name);
     if (strcmp(what, "set") == 0) {
       pajeSetVariable(time, variable_id, resource_id, valuestr);
     } else if (strcmp(what, "add") == 0) {
index d14083c..e1a22ee 100644 (file)
@@ -102,6 +102,17 @@ type_t getVariableType (const char *typename, const char *color, type_t father)
   return ret;
 }
 
+char *getVariableTypeIdByName (const char *name, type_t father)
+{
+  xbt_dict_cursor_t cursor = NULL;
+  type_t type;
+  char *key;
+  xbt_dict_foreach(father->children, cursor, key, type) {
+    if (strcmp (name, type->name) == 0) return type->id;
+  }
+  return NULL;
+}
+
 type_t getLinkType (const char *typename, type_t father, type_t source, type_t dest)
 {
   //FIXME should check using source and dest here and not by the typename (g5k example)
@@ -220,6 +231,11 @@ container_t getContainerByName (const char *name)
   return (container_t)xbt_dict_get (allContainers, name);
 }
 
+char *getContainerIdByName (const char *name)
+{
+  return getContainerByName(name)->id;
+}
+
 container_t getRootContainer ()
 {
   return rootContainer;
@@ -262,5 +278,39 @@ void destroyContainer (container_t container)
   container = NULL;
 }
 
+static void recursiveDestroyContainer (container_t container)
+{
+  xbt_dict_cursor_t cursor = NULL;
+  container_t child;
+  char *child_name;
+  xbt_dict_foreach(container->children, cursor, child_name, child) {
+    recursiveDestroyContainer (child);
+  }
+  destroyContainer (container);
+}
+
+static void recursiveDestroyType (type_t type)
+{
+  xbt_dict_cursor_t cursor = NULL;
+  type_t child;
+  char *child_name;
+  xbt_dict_foreach(type->children, cursor, child_name, child) {
+    recursiveDestroyType (child);
+  }
+  xbt_free (type->name);
+  xbt_free (type->id);
+  xbt_free (type->children);
+  xbt_free (type);
+  type = NULL;
+}
+
+void destroyAllContainers ()
+{
+  if (getRootContainer()) recursiveDestroyContainer (getRootContainer());
+  if (getRootType()) recursiveDestroyType (getRootType());
+  rootContainer = NULL;
+  rootType = NULL;
+}
+
 
 #endif /* HAVE_TRACING */
index 05d2f1e..e7d8355 100644 (file)
@@ -216,10 +216,12 @@ void TRACE_surf_resource_utilization_release(void);
 void TRACE_sd_task_create(SD_task_t task);
 void TRACE_sd_task_destroy(SD_task_t task);
 
-/* instr_routing.c */
+/* instr_paje.c */
 container_t newContainer (const char *name, e_container_types kind, container_t father);
 container_t getContainer (const char *name);
 container_t getContainerByName (const char *name);
+char *getContainerIdByName (const char *name);
+char *getVariableTypeIdByName (const char *name, type_t father);
 container_t getRootContainer (void);
 void instr_paje_init (container_t root);
 type_t getRootType (void);
@@ -230,11 +232,10 @@ type_t getLinkType (const char *name, type_t father, type_t source, type_t dest)
 type_t getStateType (const char *name, type_t father);
 type_t getType (const char *name);
 void destroyContainer (container_t container);
+void destroyAllContainers (void);
+
+/* instr_routing.c */
 void instr_routing_define_callbacks (void);
-int instr_link_is_traced (const char *name);
-char *instr_variable_type (const char *name, const char *resource);
-char *instr_resource_type (const char *resource_name);
-void instr_destroy_platform (void);
 void instr_new_user_variable_type (const char *new_typename, const char *color);
 void instr_new_user_link_variable_type  (const char *new_typename, const char *color);
 void instr_new_user_host_variable_type  (const char *new_typename, const char *color);
index aed3397..9bd1bee 100644 (file)
@@ -277,7 +277,7 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
   if (!value)
     return;
   //only trace link utilization if link is known by tracing mechanism
-  if (!instr_link_is_traced(resource))
+  if (!getContainerByName(resource))
     return;
   if (!value)
     return;
@@ -285,8 +285,8 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
   //trace uncategorized link utilization
   if (TRACE_uncategorized()){
     DEBUG4("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
-    char *variable_type = instr_variable_type ("bandwidth_used", resource);
-    char *resource_id = instr_resource_type (resource);
+    char *variable_type = getVariableTypeIdByName("bandwidth_used", getContainerByName(resource)->type);
+    char *resource_id = getContainerIdByName (resource);
     TRACE_surf_resource_utilization_event(smx_action, now, delta, variable_type, resource_id, value);
   }
 
@@ -295,8 +295,8 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
     if (!surf_action->category)
       return;
     DEBUG5("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, surf_action->category, value);
-    char *variable_type = instr_variable_type (surf_action->category, resource);
-    char *resource_id = instr_resource_type (resource);
+    char *variable_type = getVariableTypeIdByName(surf_action->category, getContainerByName(resource)->type);
+    char *resource_id = getContainerIdByName (resource);
     TRACE_surf_resource_utilization_event(smx_action, now, delta, variable_type, resource_id, value);
   }
   return;
@@ -319,8 +319,8 @@ void TRACE_surf_host_set_utilization(const char *resource,
   //trace uncategorized host utilization
   if (TRACE_uncategorized()){
     DEBUG4("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
-    char *variable_type = instr_variable_type ("power_used", resource);
-    char *resource_id = instr_resource_type (resource);
+    char *variable_type = getVariableTypeIdByName ("power_used", getContainerByName(resource)->type);
+    char *resource_id = getContainerIdByName (resource);
     TRACE_surf_resource_utilization_event(smx_action, now, delta, variable_type, resource_id, value);
   }
 
@@ -329,8 +329,8 @@ void TRACE_surf_host_set_utilization(const char *resource,
     if (!surf_action->category)
       return;
     DEBUG5("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, surf_action->category, value);
-    char *variable_type = instr_variable_type (surf_action->category, resource);
-    char *resource_id = instr_resource_type (resource);
+    char *variable_type = getVariableTypeIdByName (surf_action->category, getContainerByName(resource)->type);
+    char *resource_id = getContainerIdByName (resource);
     TRACE_surf_resource_utilization_event(smx_action, now, delta, variable_type, resource_id, value);
   }
   return;
index 9c38de1..de16ae5 100644 (file)
@@ -17,31 +17,6 @@ extern xbt_dict_t defined_types; /* from instr_interface.c */
 static int platform_created = 0;            /* indicate whether the platform file has been traced */
 static xbt_dynar_t currentContainer = NULL; /* push and pop, used only in creation */
 
-static void instr_routing_parse_start_AS (void);
-static void instr_routing_parse_end_AS (void);
-static void instr_routing_parse_start_link (void);
-static void instr_routing_parse_end_link (void);
-static void instr_routing_parse_start_host (void);
-static void instr_routing_parse_end_host (void);
-static void instr_routing_parse_start_router (void);
-static void instr_routing_parse_end_router (void);
-static void instr_routing_parse_end_platform (void);
-
-void instr_routing_define_callbacks ()
-{
-  if (!TRACE_is_active())
-    return;
-  surfxml_add_callback(STag_surfxml_AS_cb_list, &instr_routing_parse_start_AS);
-  surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS);
-  surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link);
-  surfxml_add_callback(ETag_surfxml_link_cb_list, &instr_routing_parse_end_link);
-  surfxml_add_callback(STag_surfxml_host_cb_list, &instr_routing_parse_start_host);
-  surfxml_add_callback(ETag_surfxml_host_cb_list, &instr_routing_parse_end_host);
-  surfxml_add_callback(STag_surfxml_router_cb_list, &instr_routing_parse_start_router);
-  surfxml_add_callback(ETag_surfxml_router_cb_list, &instr_routing_parse_end_router);
-  surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform);
-}
-
 static container_t findChild (container_t root, container_t a1)
 {
   if (root == a1) return root;
@@ -291,65 +266,19 @@ static void instr_routing_parse_end_platform ()
   platform_created = 1;
 }
 
-/*
- * Support functions
- */
-int instr_link_is_traced (const char *name)
-{
-  if (getContainerByName(name)){
-    return 1;
-  } else {
-    return 0;
-  }
-}
-
-char *instr_variable_type (const char *name, const char *resource)
-{
-  container_t container = getContainerByName(resource);
-  xbt_dict_cursor_t cursor = NULL;
-  type_t type;
-  char *type_name;
-  xbt_dict_foreach(container->type->children, cursor, type_name, type) {
-    if (strcmp (name, type->name) == 0) return type->id;
-  }
-  return NULL;
-}
-
-char *instr_resource_type (const char *resource_name)
-{
-  return getContainerByName(resource_name)->id;
-}
-
-static void recursiveDestroyContainer (container_t container)
-{
-  xbt_dict_cursor_t cursor = NULL;
-  container_t child;
-  char *child_name;
-  xbt_dict_foreach(container->children, cursor, child_name, child) {
-    recursiveDestroyContainer (child);
-  }
-  destroyContainer (container);
-}
-
-static void recursiveDestroyType (type_t type)
-{
-  xbt_dict_cursor_t cursor = NULL;
-  type_t child;
-  char *child_name;
-  xbt_dict_foreach(type->children, cursor, child_name, child) {
-    recursiveDestroyType (child);
-  }
-  xbt_free (type->name);
-  xbt_free (type->id);
-  xbt_free (type->children);
-  xbt_free (type);
-  type = NULL;
-}
-
-void instr_destroy_platform ()
+void instr_routing_define_callbacks ()
 {
-  if (getRootContainer()) recursiveDestroyContainer (getRootContainer());
-  if (getRootType()) recursiveDestroyType (getRootType());
+  if (!TRACE_is_active())
+    return;
+  surfxml_add_callback(STag_surfxml_AS_cb_list, &instr_routing_parse_start_AS);
+  surfxml_add_callback(ETag_surfxml_AS_cb_list, &instr_routing_parse_end_AS);
+  surfxml_add_callback(STag_surfxml_link_cb_list, &instr_routing_parse_start_link);
+  surfxml_add_callback(ETag_surfxml_link_cb_list, &instr_routing_parse_end_link);
+  surfxml_add_callback(STag_surfxml_host_cb_list, &instr_routing_parse_start_host);
+  surfxml_add_callback(ETag_surfxml_host_cb_list, &instr_routing_parse_end_host);
+  surfxml_add_callback(STag_surfxml_router_cb_list, &instr_routing_parse_start_router);
+  surfxml_add_callback(ETag_surfxml_router_cb_list, &instr_routing_parse_end_router);
+  surfxml_add_callback(ETag_surfxml_platform_cb_list, &instr_routing_parse_end_platform);
 }
 
 /*
index 4cff2e8..b32d089 100644 (file)
@@ -19,7 +19,7 @@ void TRACE_surf_alloc(void)
 void TRACE_surf_release(void)
 {
   TRACE_surf_resource_utilization_release();
-  instr_destroy_platform();
+  destroyAllContainers();
 }
 
 static void TRACE_surf_set_resource_variable(double date,
@@ -29,7 +29,7 @@ static void TRACE_surf_set_resource_variable(double date,
 {
   char value_str[INSTR_DEFAULT_STR_SIZE];
   snprintf(value_str, 100, "%f", value);
-  char *variable_type = instr_variable_type(variable, resource);
+  char *variable_type = getVariableTypeIdByName(variable, getContainerByName(resource)->type);
   pajeSetVariable(date, variable, variable_type, value_str);
 }
 
@@ -38,7 +38,7 @@ void TRACE_surf_host_set_power(double date, const char *resource, double power)
   if (!TRACE_is_active())
     return;
 
-  char *variable_type = instr_variable_type("power", resource);
+  char *variable_type = getVariableTypeIdByName("power", getContainerByName(resource)->type);
   TRACE_surf_set_resource_variable(date, variable_type, resource, power);
 }
 
@@ -47,7 +47,7 @@ void TRACE_surf_link_set_bandwidth(double date, const char *resource, double ban
   if (!TRACE_is_active())
     return;
 
-  char *variable_type = instr_variable_type("bandwidth", resource);
+  char *variable_type = getVariableTypeIdByName("bandwidth", getContainerByName(resource)->type);
   TRACE_surf_set_resource_variable(date, variable_type, resource, bandwidth);
 }
 
@@ -57,7 +57,7 @@ void TRACE_surf_link_set_latency(double date, const char *resource, double laten
   if (!TRACE_is_active())
     return;
 
-  char *variable_type = instr_variable_type("latency", resource);
+  char *variable_type = getVariableTypeIdByName("latency", getContainerByName(resource)->type);
   TRACE_surf_set_resource_variable(date, variable_type, resource, latency);
 }