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) {
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) {
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)
return (container_t)xbt_dict_get (allContainers, name);
}
+char *getContainerIdByName (const char *name)
+{
+ return getContainerByName(name)->id;
+}
+
container_t getRootContainer ()
{
return rootContainer;
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 */
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);
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);
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;
//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);
}
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;
//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);
}
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;
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;
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);
}
/*
void TRACE_surf_release(void)
{
TRACE_surf_resource_utilization_release();
- instr_destroy_platform();
+ destroyAllContainers();
}
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);
}
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);
}
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);
}
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);
}