/* destroy all data structures of tracing (and free) */
destroyAllContainers();
+ instr_paje_free();
+ TRACE_surf_release();
+ TRACE_smpi_release();
+ xbt_dict_free(&created_categories);
/* close the trace file */
TRACE_paje_end();
rootContainer = root;
}
+void instr_paje_free (void)
+{
+ xbt_dict_free (&allContainers);
+ xbt_dict_free (&trivaNodeTypes);
+ xbt_dict_free (&trivaEdgeTypes);
+}
+
static long long int new_type_id (void)
{
static long long int type_id = 0;
return type_id++;
}
+static void destroyValue (void *value)
+{
+ xbt_free(((val_t)value)->name);
+ xbt_free(((val_t)value)->color);
+ xbt_free(((val_t)value)->id);
+ xbt_free(value);
+}
+
static val_t newValue (const char *valuename, const char *color, type_t father)
{
val_t ret = xbt_new0(s_val_t, 1);
void destroyContainer (container_t container)
{
- //remove me from my father
- if (container->father){
- xbt_dict_remove(container->father->children, container->name);
- }
-
XBT_DEBUG("destroy container %s", container->name);
//obligation to dump previous events because they might
//free
xbt_free (container->name);
xbt_free (container->id);
- xbt_free (container->children);
+ xbt_dict_free (&container->children);
xbt_free (container);
container = NULL;
}
}
xbt_free (type->name);
xbt_free (type->id);
- xbt_free (type->children);
- xbt_free (type->values);
+ xbt_free (type->color);
+ xbt_dict_free (&type->children);
+ val_t value;
+ char *value_name;
+ xbt_dict_foreach(type->values, cursor, value_name, value) {
+ destroyValue (value);
+ }
+ xbt_dict_free (&type->values);
xbt_free (type);
type = NULL;
}
{
fclose(tracing_file);
char *filename = TRACE_get_filename();
+ xbt_dynar_free (&buffer);
XBT_DEBUG("Filename %s is closed", filename);
}
static void free_paje_event (paje_event_t event)
{
XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, event->event_type, event->timestamp);
- if (event->event_type == PAJE_StartLink){
+ switch (event->event_type){
+ case PAJE_StartLink:
xbt_free (((startLink_t)(event->data))->value);
xbt_free (((startLink_t)(event->data))->key);
- }else if (event->event_type == PAJE_EndLink){
+ break;
+ case PAJE_EndLink:
xbt_free (((endLink_t)(event->data))->value);
xbt_free (((endLink_t)(event->data))->key);
+ break;
}
xbt_free (event->data);
xbt_free (event);
char *getVariableTypeIdByName (const char *name, type_t father);
container_t getRootContainer (void);
void instr_paje_init (container_t root);
+void instr_paje_free (void);
type_t getRootType (void);
type_t getContainerType (const char *name, type_t father);
type_t getEventType (const char *name, const char *color, type_t father);
const char *variable,
const char *resource)
{
- /* check if we have to set it to 0 */
- if (!xbt_dict_get_or_null(platform_variables, resource)) {
- xbt_dynar_t array = xbt_dynar_new(sizeof(char *), xbt_free);
- char *var_cpy = xbt_strdup(variable);
- xbt_dynar_push(array, &var_cpy);
+ /*
+ * To trace resource utilization, we use pajeAddVariable and pajeSubVariable only.
+ * The Paje simulator needs a pajeSetVariable in the first place so it knows
+ * the initial value of all variables for subsequent adds/subs. If we don't do
+ * so, the first pajeAddVariable is added to a non-determined value within
+ * the Paje simulator, causing analysis problems.
+ */
+
+ // create a key considering the resource and variable
+ int n = strlen(variable)+strlen(resource)+1;
+ char *key = (char*)xbt_malloc(n*sizeof(char));
+ snprintf (key, n, "%s%s", resource, variable);
+
+ // check if key exists: if it doesn't, set the variable to zero and mark this in the dict
+ if (!xbt_dict_get_or_null(platform_variables, key)) {
container_t container = getContainerByName (resource);
type_t type = getVariableType (variable, NULL, container->type);
new_pajeSetVariable (now, container, type, 0);
- xbt_dict_set(platform_variables, resource, array, NULL);
- } else {
- xbt_dynar_t array = xbt_dict_get(platform_variables, resource);
- unsigned int i;
- char *cat;
- int flag = 0;
- xbt_dynar_foreach(array, i, cat) {
- if (strcmp(variable, cat) == 0) {
- flag = 1;
- }
- }
- if (flag == 0) {
- char *var_cpy = xbt_strdup(variable);
- xbt_dynar_push(array, &var_cpy);
- if (TRACE_categorized ()){
- container_t container = getContainerByName (resource);
- type_t type = getVariableType (variable, NULL, container->type);
- new_pajeSetVariable (now, container, type, 0);
- }
- }
+ xbt_dict_set(platform_variables, key, "", NULL);
}
- /* end of check */
+ xbt_free(key);
}
-
-
/*
static void __TRACE_A_event(smx_action_t action, double now, double delta,
const char *variable, const char *resource,
void TRACE_surf_resource_utilization_alloc()
{
- platform_variables = xbt_dict_new_homogeneous(xbt_dynar_free_voidp);
+ platform_variables = xbt_dict_new_homogeneous(NULL);
}
void TRACE_surf_resource_utilization_release()
{
+ xbt_dict_free(&platform_variables);
}
#endif /* HAVE_TRACING */
void TRACE_smpi_release(void)
{
+ xbt_dict_free(&keys);
+ xbt_dict_free(&process_category);
if (!TRACE_smpi_is_enabled()) return;
TRACE_surf_release();