X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c5ad8ca1a68bbaa9152471c8d0eeb99d762f0d86..d0ffc37686edcc803601f76ab51fdfed5fc2f241:/src/instr/instr_paje_containers.c diff --git a/src/instr/instr_paje_containers.c b/src/instr/instr_paje_containers.c index b1d2563756..327e57c22f 100644 --- a/src/instr/instr_paje_containers.c +++ b/src/instr/instr_paje_containers.c @@ -1,10 +1,13 @@ -/* Copyright (c) 2010. The SimGrid Team. +/* Copyright (c) 2010, 2012-2013. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ #include "instr/instr_private.h" +#include "xbt/lib.h" +#include "surf/surf.h" +#include "surf/surf_routing.h" #ifdef HAVE_TRACING @@ -12,8 +15,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_containers, instr, "Paje tracing eve static container_t rootContainer = NULL; /* the root container */ static xbt_dict_t allContainers = NULL; /* all created containers indexed by name */ -xbt_dict_t trivaNodeTypes = NULL; /* all link types defined */ -xbt_dict_t trivaEdgeTypes = NULL; /* all host types defined */ +xbt_dict_t trivaNodeTypes = NULL; /* all host types defined */ +xbt_dict_t trivaEdgeTypes = NULL; /* all link types defined */ long long int instr_new_paje_id (void) { @@ -54,6 +57,26 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe new->name = xbt_strdup (name); // name of the container new->id = xbt_strdup (id_str); // id (or alias) of the container new->father = father; + + //Search for network_element_t + switch (kind){ + case INSTR_HOST: + new->net_elm = xbt_lib_get_or_null(host_lib,name,ROUTING_HOST_LEVEL); + if(!new->net_elm) xbt_die("Element '%s' not found",name); + break; + case INSTR_ROUTER: + new->net_elm = xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); + if(!new->net_elm) xbt_die("Element '%s' not found",name); + break; + case INSTR_AS: + new->net_elm = xbt_lib_get_or_null(as_router_lib,name,ROUTING_ASR_LEVEL); + if(!new->net_elm) xbt_die("Element '%s' not found",name); + break; + default: + new->net_elm = NULL; + break; + } + // level depends on level of father if (new->father){ new->level = new->father->level+1; @@ -84,6 +107,7 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe case INSTR_ROUTER: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "ROUTER"); break; case INSTR_SMPI: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MPI"); break; case INSTR_MSG_PROCESS: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_PROCESS"); break; + case INSTR_MSG_VM: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_VM"); break; case INSTR_MSG_TASK: snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK"); break; default: THROWF (tracing_error, 0, "new container kind is unknown."); break; } @@ -104,12 +128,15 @@ container_t PJ_container_new (const char *name, e_container_types kind, containe if (xbt_dict_get_or_null(allContainers, new->name) != NULL){ THROWF(tracing_error, 1, "container %s already present in allContainers data structure", new->name); } + xbt_dict_set (allContainers, new->name, new, NULL); + XBT_DEBUG("Add container name '%s'",new->name); //register NODE types for triva configuration if (new->kind == INSTR_HOST || new->kind == INSTR_LINK || new->kind == INSTR_ROUTER) { xbt_dict_set (trivaNodeTypes, new->type->name, xbt_strdup("1"), NULL); } + return new; } @@ -124,12 +151,7 @@ container_t PJ_container_get (const char *name) container_t PJ_container_get_or_null (const char *name) { - if (name == NULL) return NULL; - container_t ret = xbt_dict_get_or_null (allContainers, name); - if (ret == NULL){ - return NULL; - } - return ret; + return name ? xbt_dict_get_or_null(allContainers, name) : NULL; } container_t PJ_container_get_root () @@ -165,8 +187,9 @@ void PJ_container_free (container_t container) TRACE_paje_dump_buffer(1); //trace my destruction - if (!TRACE_disable_destroy()){ + if (!TRACE_disable_destroy() && container != PJ_container_get_root()){ //do not trace the container destruction if user requests + //or if the container is root new_pajeDestroyContainer(container); } @@ -206,7 +229,7 @@ void PJ_container_free_all () rootContainer = NULL; //checks - if (xbt_dict_length(allContainers) != 0){ + if (!xbt_dict_is_empty(allContainers)){ THROWF(tracing_error, 0, "some containers still present even after destroying all of them"); } }