Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] re-writing some tracing functions
authorLucas Schnorr <Lucas.Schnorr@imag.fr>
Sun, 22 Jan 2012 23:15:22 +0000 (00:15 +0100)
committerLucas Schnorr <Lucas.Schnorr@imag.fr>
Sun, 22 Jan 2012 23:55:24 +0000 (00:55 +0100)
13 files changed:
buildtools/Cmake/DefinePackages.cmake
src/instr/instr_config.c
src/instr/instr_interface.c
src/instr/instr_msg_process.c
src/instr/instr_msg_task.c
src/instr/instr_paje.c
src/instr/instr_paje_types.c [new file with mode: 0644]
src/instr/instr_paje_values.c [new file with mode: 0644]
src/instr/instr_private.h
src/instr/instr_resource_utilization.c
src/instr/instr_routing.c
src/instr/instr_smpi.c
src/instr/instr_surf.c

index 352a0fc..263691c 100644 (file)
@@ -343,6 +343,8 @@ set(TRACING_SRC
        src/instr/instr_interface.c
        src/instr/instr_paje.c
        src/instr/instr_paje_trace.c
+       src/instr/instr_paje_types.c
+       src/instr/instr_paje_values.c
        src/instr/instr_msg_task.c
        src/instr/instr_msg_process.c
        src/instr/instr_surf.c
index 4025598..e91a964 100644 (file)
@@ -104,8 +104,10 @@ int TRACE_end()
   TRACE_paje_dump_buffer(1);
 
   /* destroy all data structures of tracing (and free) */
-  destroyAllContainers();
-  instr_paje_free();
+  PJ_container_free_all();
+  PJ_type_free_all();
+  PJ_container_release();
+  PJ_type_release();
   TRACE_surf_release();
   TRACE_smpi_release();
   xbt_dict_free(&created_categories);
index df21be5..9c82256 100644 (file)
@@ -66,7 +66,7 @@ void TRACE_declare_mark(const char *mark_type)
   if (!mark_type) return;
 
   XBT_DEBUG("MARK,declare %s", mark_type);
-  getEventType(mark_type, NULL, getRootType());
+  PJ_type_event_new(mark_type, NULL, PJ_type_get_root());
 }
 
 void TRACE_mark(const char *mark_type, const char *mark_value)
@@ -77,9 +77,15 @@ void TRACE_mark(const char *mark_type, const char *mark_value)
   if (!mark_type || !mark_value) return;
 
   XBT_DEBUG("MARK %s %s", mark_type, mark_value);
-  type_t type = getEventType (mark_type, NULL, getRootContainer()->type);
-  val_t value = getValue (mark_value, NULL, type);
-  new_pajeNewEvent (MSG_get_clock(), getRootContainer(), type, value);
+  type_t type = PJ_type_get (mark_type, PJ_type_get_root());
+  if (type == NULL){
+    THROWF (tracing_error, 1, "mark_type with name (%s) not declared before", mark_type);
+  }
+  val_t value = PJ_value_get (mark_value, type);
+  if (value == NULL){
+    value = PJ_value_new (mark_value, NULL, type);
+  }
+  new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
 }
 
 static void instr_user_variable(double time,
@@ -105,22 +111,22 @@ static void instr_user_variable(double time,
     break;
   case INSTR_US_SET:
   {
-    container_t container = getContainerByName(resource);
-    type_t type = getVariableType (variable, NULL, container->type);
+    container_t container = PJ_container_get(resource);
+    type_t type = PJ_type_get (variable, container->type);
     new_pajeSetVariable(time, container, type, value);
     break;
   }
   case INSTR_US_ADD:
   {
-    container_t container = getContainerByName(resource);
-    type_t type = getVariableType (variable, NULL, container->type);
+    container_t container = PJ_container_get(resource);
+    type_t type = PJ_type_get (variable, container->type);
     new_pajeAddVariable(time, container, type, value);
     break;
   }
   case INSTR_US_SUB:
   {
-    container_t container = getContainerByName(resource);
-    type_t type = getVariableType (variable, NULL, container->type);
+    container_t container = PJ_container_get(resource);
+    type_t type = PJ_type_get (variable, container->type);
     new_pajeSubVariable(time, container, type, value);
     break;
   }
index ec0d9b4..428cb43 100644 (file)
@@ -20,7 +20,7 @@ void TRACE_msg_set_process_category(m_process_t process, const char *category, c
 
 char *instr_process_id (m_process_t proc, char *str, int len)
 {
-  return instr_process_id_2 (MSG_process_get_name(proc), MSG_process_get_PID(proc), str, len);
+  return instr_process_id_2 (proc->name, proc->pid, str, len);//MSG_process_get_name(proc), MSG_process_get_PID(proc), str, len);
 }
 
 char *instr_process_id_2 (const char *process_name, int process_pid, char *str, int len)
@@ -43,27 +43,27 @@ void TRACE_msg_process_change_host(m_process_t process, m_host_t old_host, m_hos
     char str[INSTR_DEFAULT_STR_SIZE];
 
     //start link
-    container_t msg = getContainer(instr_process_id(process, str, len));
-    type_t type = getType ("MSG_PROCESS_LINK", getRootType());
-    new_pajeStartLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
+    container_t msg = PJ_container_get (instr_process_id(process, str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
+    new_pajeStartLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
 
     //destroy existing container of this process
-    container_t existing_container = getContainer(instr_process_id(process, str, len));
-    removeContainerFromParent (existing_container);
-    destroyContainer(existing_container);
+    container_t existing_container = PJ_container_get(instr_process_id(process, str, len));
+    PJ_container_remove_from_parent (existing_container);
+    PJ_container_free(existing_container);
 
     //create new container on the new_host location
-    msg = newContainer(instr_process_id(process, str, len), INSTR_MSG_PROCESS, getContainer(new_host->name));
+    msg = PJ_container_new(instr_process_id(process, str, len), INSTR_MSG_PROCESS, PJ_container_get(new_host->name));
 
     //set the state of this new container
-    type = getType ("MSG_PROCESS_STATE", msg->type);
-    val_t value = getValueByName ("executing", type);
+    type = PJ_type_get ("MSG_PROCESS_STATE", msg->type);
+    val_t value = PJ_value_get ("executing", type);
     new_pajeSetState (MSG_get_clock(), msg, type, value);
 
     //end link
-    msg = getContainer(instr_process_id(process, str, len));
-    type = getType ("MSG_PROCESS_LINK", getRootType());
-    new_pajeEndLink (MSG_get_clock(), getRootContainer(), type, msg, "M", key);
+    msg = PJ_container_get(instr_process_id(process, str, len));
+    type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
+    new_pajeEndLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
   }
 }
 
@@ -73,11 +73,11 @@ void TRACE_msg_process_create (const char *process_name, int process_pid, m_host
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t host_container = getContainer(host->name);
-    container_t msg = newContainer(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
+    container_t host_container = PJ_container_get (host->name);
+    container_t msg = PJ_container_new(instr_process_id_2(process_name, process_pid, str, len), INSTR_MSG_PROCESS, host_container);
 
-    type_t type = getType ("MSG_PROCESS_STATE", msg->type);
-    val_t value = getValueByName ("executing", type);
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", msg->type);
+    val_t value = PJ_value_get ("executing", type);
     new_pajeSetState (MSG_get_clock(), msg, type, value);
   }
 }
@@ -89,7 +89,7 @@ void TRACE_msg_process_kill(m_process_t process)
     char str[INSTR_DEFAULT_STR_SIZE];
 
     //kill means that this process no longer exists, let's destroy it
-    destroyContainer (getContainer(instr_process_id(process, str, len)));
+    PJ_container_free (PJ_container_get (instr_process_id(process, str, len)));
   }
 }
 
@@ -99,9 +99,9 @@ void TRACE_msg_process_suspend(m_process_t process)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(process, str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    val_t value = getValueByName ("suspend", type);
+    container_t process_container = PJ_container_get (instr_process_id(process, str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
+    val_t value = PJ_value_get ("suspend", type);
     new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
@@ -112,8 +112,8 @@ void TRACE_msg_process_resume(m_process_t process)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(process, str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
+    container_t process_container = PJ_container_get (instr_process_id(process, str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     new_pajePopState (MSG_get_clock(), process_container, type);
   }
 }
@@ -124,9 +124,9 @@ void TRACE_msg_process_sleep_in(m_process_t process)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(process, str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    val_t value = getValueByName ("sleep", type);
+    container_t process_container = PJ_container_get (instr_process_id(process, str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
+    val_t value = PJ_value_get ("sleep", type);
     new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
@@ -137,8 +137,8 @@ void TRACE_msg_process_sleep_out(m_process_t process)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(process, str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
+    container_t process_container = PJ_container_get (instr_process_id(process, str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     new_pajePopState (MSG_get_clock(), process_container, type);
   }
 }
@@ -150,9 +150,9 @@ void TRACE_msg_process_end(m_process_t process)
     char str[INSTR_DEFAULT_STR_SIZE];
 
     //that's the end, let's destroy it
-    container_t container = getContainer(instr_process_id(process, str, len));
-    removeContainerFromParent (container);
-    destroyContainer (container);
+    container_t container = PJ_container_get (instr_process_id(process, str, len));
+    PJ_container_remove_from_parent (container);
+    PJ_container_free (container);
   }
 }
 
index 423eab3..fbef5e4 100644 (file)
@@ -49,9 +49,9 @@ void TRACE_msg_task_execute_start(m_task_t task)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    val_t value = getValueByName ("task_execute", type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
+    val_t value = PJ_value_get ("task_execute", type);
     new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
@@ -64,8 +64,8 @@ void TRACE_msg_task_execute_end(m_task_t task)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     new_pajePopState (MSG_get_clock(), process_container, type);
   }
 }
@@ -90,9 +90,9 @@ void TRACE_msg_task_get_start(void)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    val_t value = getValueByName ("receive", type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
+    val_t value = PJ_value_get ("receive", type);
     new_pajePushState (MSG_get_clock(), process_container, type, value);
   }
 }
@@ -105,14 +105,14 @@ void TRACE_msg_task_get_end(double start_time, m_task_t task)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     new_pajePopState (MSG_get_clock(), process_container, type);
 
     char key[INSTR_DEFAULT_STR_SIZE];
     snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
-    type = getType ("MSG_PROCESS_TASK_LINK", getRootType());
-    new_pajeEndLink(MSG_get_clock(), getRootContainer(), type, process_container, "SR", key);
+    type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
+    new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
   }
 }
 
@@ -125,15 +125,15 @@ int TRACE_msg_task_put_start(m_task_t task)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
-    val_t value = getValueByName ("send", type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
+    val_t value = PJ_value_get ("send", type);
     new_pajePushState (MSG_get_clock(), process_container, type, value);
 
     char key[INSTR_DEFAULT_STR_SIZE];
     snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
-    type = getType ("MSG_PROCESS_TASK_LINK", getRootType());
-    new_pajeStartLink(MSG_get_clock(), getRootContainer(), type, process_container, "SR", key);
+    type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
+    new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
   }
 
   return 1;
@@ -147,8 +147,8 @@ void TRACE_msg_task_put_end(void)
     int len = INSTR_DEFAULT_STR_SIZE;
     char str[INSTR_DEFAULT_STR_SIZE];
 
-    container_t process_container = getContainer (instr_process_id(MSG_process_self(), str, len));
-    type_t type = getType ("MSG_PROCESS_STATE", process_container->type);
+    container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
+    type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
     new_pajePopState (MSG_get_clock(), process_container, type);
   }
 }
index adf490c..0ea9147 100644 (file)
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje, instr, "Paje tracing event system (data structures)");
 
-static type_t rootType = NULL;              /* the root type */
 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 */
 
-void instr_paje_init (void)
+long long int instr_new_paje_id (void)
 {
-  allContainers = xbt_dict_new_homogeneous(NULL);
-  trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free);
-  trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free);
+  static long long int type_id = 0;
+  return type_id++;
 }
 
-void instr_paje_set_root (container_t root)
+void PJ_container_alloc (void)
 {
-  rootContainer = root;
+  allContainers = xbt_dict_new_homogeneous(NULL);
+  trivaNodeTypes = xbt_dict_new_homogeneous(xbt_free);
+  trivaEdgeTypes = xbt_dict_new_homogeneous(xbt_free);
 }
 
-void instr_paje_free (void)
+void PJ_container_release (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);
-  ret->name = xbt_strdup (valuename);
-  ret->father = father;
-  ret->color = xbt_strdup (color);
-
-  char str_id[INSTR_DEFAULT_STR_SIZE];
-  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", new_type_id());
-  ret->id = xbt_strdup (str_id);
-
-  xbt_dict_set (father->values, valuename, ret, NULL);
-  XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
-  return ret;
-}
-
-val_t getValue (const char *valuename, const char *color, type_t father)
-{
-  if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
-
-  val_t ret = (val_t)xbt_dict_get_or_null (father->values, valuename);
-  if (ret == NULL){
-    ret = newValue (valuename, color, father);
-    XBT_DEBUG("EntityValue %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    new_pajeDefineEntityValue(ret);
-  }
-  return ret;
-}
-
-val_t getValueByName (const char *valuename, type_t father)
+void PJ_container_set_root (container_t root)
 {
-  return getValue (valuename, NULL, father);
-}
-
-static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
-{
-  type_t ret = xbt_new0(s_type_t, 1);
-  ret->name = xbt_strdup (typename);
-  ret->father = father;
-  ret->kind = kind;
-  ret->children = xbt_dict_new_homogeneous(NULL);
-  ret->values = xbt_dict_new_homogeneous(NULL);
-  ret->color = xbt_strdup (color);
-
-  char str_id[INSTR_DEFAULT_STR_SIZE];
-  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", new_type_id());
-  ret->id = xbt_strdup (str_id);
-
-  if (father != NULL){
-    xbt_dict_set (father->children, key, ret, NULL);
-    XBT_DEBUG("new type %s, child of %s", typename, father->name);
-  }
-  return ret;
-}
-
-type_t getRootType ()
-{
-  return rootType;
-}
-
-type_t getContainerType (const char *typename, type_t father)
-{
-  type_t ret;
-  if (father == NULL){
-    ret = newType (typename, typename, NULL, TYPE_CONTAINER, father);
-    if (father) new_pajeDefineContainerType (ret);
-    rootType = ret;
-  }else{
-    //check if my father type already has my typename
-    ret = (type_t)xbt_dict_get_or_null (father->children, typename);
-    if (ret == NULL){
-      ret = newType (typename, typename, NULL, TYPE_CONTAINER, father);
-      new_pajeDefineContainerType (ret);
-    }
-  }
-  return ret;
-}
-
-type_t getEventType (const char *typename, const char *color, type_t father)
-{
-  type_t ret = xbt_dict_get_or_null (father->children, typename);
-  if (ret == NULL){
-    char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
-    if (!color){
-      ret = newType (typename, typename, white, TYPE_EVENT, father);
-    }else{
-      ret = newType (typename, typename, color, TYPE_EVENT, father);
-    }
-    XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    new_pajeDefineEventType(ret);
-  }
-  return ret;
-}
-
-type_t getVariableType (const char *typename, const char *color, type_t father)
-{
-  type_t ret = xbt_dict_get_or_null (father->children, typename);
-  if (ret == NULL){
-    char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
-    if (!color){
-      ret = newType (typename, typename, white, TYPE_VARIABLE, father);
-    }else{
-      ret = newType (typename, typename, color, TYPE_VARIABLE, father);
-    }
-    XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    new_pajeDefineVariableType (ret);
-  }
-  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)
-{
-  char key[INSTR_DEFAULT_STR_SIZE];
-  snprintf (key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", typename, source->id, dest->id);
-  type_t ret = xbt_dict_get_or_null (father->children, key);
-  if (ret == NULL){
-    ret = newType (typename, key, NULL, TYPE_LINK, father);
-    XBT_DEBUG("LinkType %s(%s), child of %s(%s)  %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, source->name, source->id, dest->name, dest->id);
-    new_pajeDefineLinkType(ret, source, dest);
-  }
-  return ret;
-}
-
-type_t getStateType (const char *typename, type_t father)
-{
-  type_t ret = xbt_dict_get_or_null (father->children, typename);
-  if (ret == NULL){
-    ret = newType (typename, typename, NULL, TYPE_STATE, father);
-    XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
-    new_pajeDefineStateType(ret);
-  }
-  return ret;
+  rootContainer = root;
 }
 
-container_t newContainer (const char *name, e_container_types kind, container_t father)
+container_t PJ_container_new (const char *name, e_container_types kind, container_t father)
 {
   static long long int container_id = 0;
   char id_str[INSTR_DEFAULT_STR_SIZE];
@@ -218,21 +64,31 @@ container_t newContainer (const char *name, e_container_types kind, container_t
     char as_typename[INSTR_DEFAULT_STR_SIZE];
     snprintf (as_typename, INSTR_DEFAULT_STR_SIZE, "L%d", new->level);
     if (new->father){
-      new->type = getContainerType (as_typename, new->father->type);
+      new->type = PJ_type_get (as_typename, new->father->type);
+      if (new->type == NULL){
+        new->type = PJ_type_container_new (as_typename, new->father->type);
+      }
     }else{
-      new->type = getContainerType ("0", NULL);
+      new->type = PJ_type_container_new ("0", NULL);
     }
   }else{
     //otherwise, the name is its kind
+    char typename[INSTR_DEFAULT_STR_SIZE];
     switch (new->kind){
-      case INSTR_HOST: new->type = getContainerType ("HOST", new->father->type); break;
-      case INSTR_LINK: new->type = getContainerType ("LINK", new->father->type); break;
-      case INSTR_ROUTER: new->type = getContainerType ("ROUTER", new->father->type); break;
-      case INSTR_SMPI: new->type = getContainerType ("MPI", new->father->type); break;
-      case INSTR_MSG_PROCESS: new->type = getContainerType ("MSG_PROCESS", new->father->type); break;
-      case INSTR_MSG_TASK: new->type = getContainerType ("MSG_TASK", new->father->type); break;
+      case INSTR_HOST:        snprintf (typename, INSTR_DEFAULT_STR_SIZE, "HOST");        break;
+      case INSTR_LINK:        snprintf (typename, INSTR_DEFAULT_STR_SIZE, "LINK");        break;
+      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_TASK:    snprintf (typename, INSTR_DEFAULT_STR_SIZE, "MSG_TASK");    break;
       default: xbt_die ("Congratulations, you have found a bug on newContainer function of instr_routing.c"); break;
     }
+    type_t type = PJ_type_get (typename, new->father->type);
+    if (type == NULL){
+      new->type = PJ_type_container_new (typename, new->father->type);
+    }else{
+      new->type = type;
+    }
   }
   new->children = xbt_dict_new_homogeneous(NULL);
   if (new->father){
@@ -240,92 +96,44 @@ container_t newContainer (const char *name, e_container_types kind, container_t
     new_pajeCreateContainer (new);
   }
 
-  //register hosts, routers, links containers
-  if (new->kind == INSTR_HOST || new->kind == INSTR_LINK || new->kind == INSTR_ROUTER) {
-    xbt_dict_set (allContainers, new->name, new, NULL);
+  //register all kinds by name
+  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);
 
-    //register NODE types for triva configuration
+  //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;
 }
 
-static container_t recursiveGetContainer (const char *name, container_t root)
+container_t PJ_container_get (const char *name)
 {
-  if (name == NULL || root == NULL) return NULL;
-  if (strcmp (root->name, name) == 0) return root;
-
-  xbt_dict_cursor_t cursor = NULL;
-  container_t child;
-  char *child_name;
-  xbt_dict_foreach(root->children, cursor, child_name, child) {
-    container_t ret = recursiveGetContainer(name, child);
-    if (ret) return ret;
+  container_t ret = PJ_container_get_or_null (name);
+  if (ret == NULL){
+    THROWF(tracing_error, 1, "container with name %s not found", name);
   }
-  return NULL;
+  return ret;
 }
 
-container_t getContainer (const char *name)
+container_t PJ_container_get_or_null (const char *name)
 {
   if (name == NULL) return NULL;
-  return getContainerByName(name);
-}
-
-int knownContainerWithName (const char *name)
-{
-  if (xbt_dict_get_or_null (allContainers, name) == NULL){
-    return 0;
-  }else{
-    return 1;
-  }
-}
-
-container_t getContainerByName (const char *name)
-{
   container_t ret = xbt_dict_get_or_null (allContainers, name);
   if (ret == NULL){
-    XBT_CRITICAL("container with name %s not found", name);
+    return NULL;
   }
   return ret;
 }
 
-char *getContainerIdByName (const char *name)
-{
-  return getContainerByName(name)->id;
-}
-
-container_t getRootContainer ()
+container_t PJ_container_get_root ()
 {
   return rootContainer;
 }
 
-static type_t recursiveGetType (const char *name, type_t root)
-{
-  if (strcmp (root->name, name) == 0) return root;
-
-  xbt_dict_cursor_t cursor = NULL;
-  type_t child;
-  char *child_name;
-  type_t ret = NULL;
-  xbt_dict_foreach(root->children, cursor, child_name, child) {
-    type_t found = recursiveGetType(name, child);
-    if (found){
-      if (ret == NULL){
-        ret = found;
-      }else{
-        XBT_CRITICAL("[tracing] found two types with the same name");
-      }
-    }
-  }
-  return ret;
-}
-
-type_t getType (const char *name, type_t father)
-{
-  return recursiveGetType (name, father);
-}
-
-void removeContainerFromParent (container_t child)
+void PJ_container_remove_from_parent (container_t child)
 {
   container_t parent = child->father;
   if (parent){
@@ -336,7 +144,7 @@ void removeContainerFromParent (container_t child)
   }
 }
 
-void destroyContainer (container_t container)
+void PJ_container_free (container_t container)
 {
   XBT_DEBUG("destroy container %s", container->name);
 
@@ -371,44 +179,18 @@ static void recursiveDestroyContainer (container_t container)
   xbt_dict_foreach(container->children, cursor, child_name, child) {
     recursiveDestroyContainer (child);
   }
-  destroyContainer (container);
+  PJ_container_free (container);
 }
 
-static void recursiveDestroyType (type_t type)
+void PJ_container_free_all ()
 {
-  XBT_DEBUG("recursiveDestroyType %s", type->name);
-  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->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;
-}
-
-void destroyAllContainers ()
-{
-  if (getRootContainer()) recursiveDestroyContainer (getRootContainer());
-  if (getRootType()) recursiveDestroyType (getRootType());
+  if (PJ_container_get_root()) recursiveDestroyContainer (PJ_container_get_root());
   rootContainer = NULL;
-  rootType = NULL;
 
   //checks
   if (xbt_dict_length(allContainers) != 0){
-    XBT_CRITICAL("some containers still present even after destroying all of them");
+    THROWF(tracing_error, 0, "some containers still present even after destroying all of them");
   }
 }
 
-
 #endif /* HAVE_TRACING */
diff --git a/src/instr/instr_paje_types.c b/src/instr/instr_paje_types.c
new file mode 100644 (file)
index 0000000..5bf0a6c
--- /dev/null
@@ -0,0 +1,206 @@
+/* Copyright (c) 2012. 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"
+
+#ifdef HAVE_TRACING
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_types, instr, "Paje tracing event system (types)");
+
+static type_t rootType = NULL;        /* the root type */
+static xbt_dict_t allTypes = NULL;    /* all declared types indexed by name */
+
+void PJ_type_alloc ()
+{
+  allTypes = xbt_dict_new_homogeneous (NULL);
+}
+
+void PJ_type_release ()
+{
+  xbt_dict_free (&allTypes);
+  rootType = NULL;
+  allTypes = NULL;
+}
+
+type_t PJ_type_get_root ()
+{
+  return rootType;
+}
+
+static type_t newType (const char *typename, const char *key, const char *color, e_entity_types kind, type_t father)
+{
+  type_t ret = xbt_new0(s_type_t, 1);
+  ret->name = xbt_strdup (typename);
+  ret->father = father;
+  ret->kind = kind;
+  ret->children = xbt_dict_new_homogeneous(NULL);
+  ret->values = xbt_dict_new_homogeneous(NULL);
+  ret->color = xbt_strdup (color);
+
+  char str_id[INSTR_DEFAULT_STR_SIZE];
+  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
+  ret->id = xbt_strdup (str_id);
+
+  if (father != NULL){
+    xbt_dict_set (father->children, key, ret, NULL);
+    XBT_DEBUG("new type %s, child of %s", typename, father->name);
+  }
+
+  xbt_dict_set (allTypes, typename, ret, NULL);
+  return ret;
+}
+
+void PJ_type_free (type_t type)
+{
+  xbt_dict_remove (allTypes, type->name);
+
+  val_t value;
+  char *value_name;
+  xbt_dict_cursor_t cursor = NULL;
+  xbt_dict_foreach(type->values, cursor, value_name, value) {
+    PJ_value_free (value);
+  }
+  xbt_dict_free (&type->values);
+  xbt_free (type->name);
+  xbt_free (type->id);
+  xbt_free (type->color);
+  xbt_dict_free (&type->children);
+  xbt_free (type);
+  type = NULL;
+}
+
+static void recursiveDestroyType (type_t type)
+{
+  XBT_DEBUG("recursiveDestroyType %s", type->name);
+  xbt_dict_cursor_t cursor = NULL;
+  type_t child;
+  char *child_name;
+  xbt_dict_foreach(type->children, cursor, child_name, child) {
+    recursiveDestroyType (child);
+  }
+  PJ_type_free(type);
+}
+
+void PJ_type_free_all (void)
+{
+  recursiveDestroyType (PJ_type_get_root());
+  rootType = NULL;
+
+  //checks
+  if (xbt_dict_length(allTypes) != 0){
+    THROWF(tracing_error, 0, "some types still present even after destroying all of them");
+  }
+}
+
+static type_t recursiveGetType (const char *name, type_t root)
+{
+  if (strcmp (root->name, name) == 0) return root;
+
+  xbt_dict_cursor_t cursor = NULL;
+  type_t child;
+  char *child_name;
+  type_t ret = NULL;
+  xbt_dict_foreach(root->children, cursor, child_name, child) {
+    type_t found = recursiveGetType(name, child);
+    if (found){
+      if (ret == NULL){
+        ret = found;
+      }else{
+        THROWF(tracing_error, 0, "found two types with the same name");
+      }
+    }
+  }
+  return ret;
+}
+
+type_t PJ_type_get (const char *name, type_t father)
+{
+  return recursiveGetType (name, father);
+}
+
+type_t PJ_type_container_new (const char *name, type_t father)
+{
+  type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
+  if (ret){
+    THROWF(tracing_error, 1, "container type with name %s already exists", name);
+  }
+
+  ret = newType (name, name, NULL, TYPE_CONTAINER, father);
+  if (father == NULL){
+    rootType = ret;
+  }
+
+  if(father){
+    XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+    new_pajeDefineContainerType (ret);
+  }
+  return ret;
+}
+
+type_t PJ_type_event_new (const char *name, const char *color, type_t father)
+{
+  type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
+  if (ret){
+    THROWF(tracing_error, 1, "event type with name %s already exists", name);
+  }
+
+  char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
+  if (!color){
+    ret = newType (name, name, white, TYPE_EVENT, father);
+  }else{
+    ret = newType (name, name, color, TYPE_EVENT, father);
+  }
+  XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+  new_pajeDefineEventType(ret);
+  return ret;
+}
+
+type_t PJ_type_variable_new (const char *name, const char *color, type_t father)
+{
+  type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
+  if (ret){
+    THROWF(tracing_error, 1, "variable type with name %s already exists", name);
+  }
+
+  char white[INSTR_DEFAULT_STR_SIZE] = "1 1 1";
+  if (!color){
+    ret = newType (name, name, white, TYPE_VARIABLE, father);
+  }else{
+    ret = newType (name, name, color, TYPE_VARIABLE, father);
+  }
+  XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+  new_pajeDefineVariableType (ret);
+  return ret;
+}
+
+type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest)
+{
+  type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
+  if (ret){
+    THROWF(tracing_error, 1, "link type with name %s already exists", name);
+  }
+
+  char key[INSTR_DEFAULT_STR_SIZE];
+  snprintf (key, INSTR_DEFAULT_STR_SIZE, "%s-%s-%s", name, source->id, dest->id);
+  ret = newType (name, key, NULL, TYPE_LINK, father);
+  XBT_DEBUG("LinkType %s(%s), child of %s(%s)  %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id, source->name, source->id, dest->name, dest->id);
+  new_pajeDefineLinkType(ret, source, dest);
+  return ret;
+}
+
+type_t PJ_type_state_new (const char *name, type_t father)
+{
+  type_t ret = (type_t)xbt_dict_get_or_null (allTypes, name);
+  if (ret){
+    THROWF(tracing_error, 1, "state type with name %s already exists", name);
+  }
+
+  ret = newType (name, name, NULL, TYPE_STATE, father);
+  XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
+  new_pajeDefineStateType(ret);
+  return ret;
+}
+
+#endif
diff --git a/src/instr/instr_paje_values.c b/src/instr/instr_paje_values.c
new file mode 100644 (file)
index 0000000..da52f14
--- /dev/null
@@ -0,0 +1,49 @@
+/* Copyright (c) 2012. 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"
+
+#ifdef HAVE_TRACING
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY (instr_paje_values, instr, "Paje tracing event system (values)");
+
+val_t PJ_value_new (const char *name, const char *color, type_t father)
+{
+  val_t ret = xbt_new0(s_val_t, 1);
+  ret->name = xbt_strdup (name);
+  ret->father = father;
+  ret->color = xbt_strdup (color);
+
+  char str_id[INSTR_DEFAULT_STR_SIZE];
+  snprintf (str_id, INSTR_DEFAULT_STR_SIZE, "%lld", instr_new_paje_id());
+  ret->id = xbt_strdup (str_id);
+
+  xbt_dict_set (father->values, name, ret, NULL);
+  XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
+  new_pajeDefineEntityValue(ret);
+  return ret;
+}
+
+val_t PJ_value_get (const char *name, type_t father)
+{
+  if (father->kind == TYPE_VARIABLE) return NULL; //Variables can't have different values
+  val_t ret = (val_t)xbt_dict_get_or_null (father->values, name);
+  if (ret == NULL){
+    return NULL;
+  }
+  return ret;
+}
+
+void PJ_value_free (val_t value)
+{
+  XBT_DEBUG("free value %s, child of %s", value->name, value->father->name);
+  xbt_free(((val_t)value)->name);
+  xbt_free(((val_t)value)->color);
+  xbt_free(((val_t)value)->id);
+  xbt_free(value);
+}
+
+
+#endif
index 38afb48..cd3be85 100644 (file)
@@ -199,28 +199,35 @@ void TRACE_sd_task_destroy(SD_task_t task);
 /* instr_paje.c */
 extern xbt_dict_t trivaNodeTypes;
 extern xbt_dict_t trivaEdgeTypes;
-container_t newContainer (const char *name, e_container_types kind, container_t father);
-container_t getContainer (const char *name);
-int knownContainerWithName (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 (void);
-void instr_paje_set_root (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);
-type_t getVariableType (const char *name, const char *color, type_t father);
-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, type_t father);
-val_t getValue (const char *valuename, const char *color, type_t father);
-val_t getValueByName (const char *valuename, type_t father);
-void removeContainerFromParent (container_t child);
-void destroyContainer (container_t container);
-void destroyAllContainers (void);
+long long int instr_new_paje_id (void);
+void PJ_container_alloc (void);
+void PJ_container_release (void);
+container_t PJ_container_new (const char *name, e_container_types kind, container_t father);
+container_t PJ_container_get (const char *name);
+container_t PJ_container_get_or_null (const char *name);
+container_t PJ_container_get_root (void);
+void PJ_container_set_root (container_t root);
+void PJ_container_free (container_t container);
+void PJ_container_free_all (void);
+void PJ_container_remove_from_parent (container_t container);
+
+/* instr_paje_types.c */
+void PJ_type_alloc (void);
+void PJ_type_release (void);
+type_t PJ_type_get_root (void);
+type_t PJ_type_container_new (const char *name, type_t father);
+type_t PJ_type_event_new (const char *name, const char *color, type_t father);
+type_t PJ_type_variable_new (const char *name, const char *color, type_t father);
+type_t PJ_type_link_new (const char *name, type_t father, type_t source, type_t dest);
+type_t PJ_type_state_new (const char *name, type_t father);
+type_t PJ_type_get (const char *name, const type_t father);
+void PJ_type_free (type_t type);
+void PJ_type_free_all (void);
+
+/* instr_paje_values.c */
+val_t PJ_value_new (const char *name, const char *color, type_t father);
+val_t PJ_value_get (const char *name, const type_t father);
+void PJ_value_free (val_t value);
 
 /* instr_routing.c */
 void instr_routing_define_callbacks (void);
index acf1a4c..02fb2db 100644 (file)
@@ -33,8 +33,8 @@ static void __TRACE_surf_check_variable_set_to_zero(double now,
 
   // 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);
+    container_t container = PJ_container_get (resource);
+    type_t type = PJ_type_get (variable, container->type);
     new_pajeSetVariable (now, container, type, 0);
     xbt_dict_set(platform_variables, key, (char*)"", NULL);
   }
@@ -50,7 +50,7 @@ static void __TRACE_A_event(smx_action_t action, double now, double delta,
   snprintf(valuestr, 100, "%f", value);
 
   __TRACE_surf_check_variable_set_to_zero(now, variable, resource);
-  container_t container = getContainerByName (resource);
+  container_t container = PJ_container_get (resource);
   type_t type = getVariableType (variable, NULL, container->type);
   new_pajeAddVariable(now, container, type, value);
   new_pajeSubVariable(now + delta, container, type, value);
@@ -73,7 +73,7 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
                                      double delta)
 {
   //only trace link utilization if link is known by tracing mechanism
-  if (!knownContainerWithName(resource))
+  if (!PJ_container_get_or_null(resource))
     return;
   if (!value)
     return;
@@ -81,8 +81,8 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
   //trace uncategorized link utilization
   if (TRACE_uncategorized()){
     XBT_DEBUG("UNCAT LINK [%f - %f] %s bandwidth_used %f", now, now+delta, resource, value);
-    container_t container = getContainerByName (resource);
-    type_t type = getVariableType("bandwidth_used", NULL, container->type);
+    container_t container = PJ_container_get (resource);
+    type_t type = PJ_type_get ("bandwidth_used", container->type);
     instr_event (now, delta, type, container, value);
   }
 
@@ -94,8 +94,8 @@ void TRACE_surf_link_set_utilization(const char *resource, smx_action_t smx_acti
     char category_type[INSTR_DEFAULT_STR_SIZE];
     snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "b%s", surf_action->category);
     XBT_DEBUG("CAT LINK [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
-    container_t container = getContainerByName (resource);
-    type_t type = getVariableType(category_type, NULL, container->type);
+    container_t container = PJ_container_get (resource);
+    type_t type = PJ_type_get (category_type, container->type);
     instr_event (now, delta, type, container, value);
   }
   return;
@@ -111,7 +111,7 @@ void TRACE_surf_host_set_utilization(const char *resource,
                                      double delta)
 {
   //only trace host utilization if host is known by tracing mechanism
-  if (!knownContainerWithName(resource))
+  if (!PJ_container_get_or_null(resource))
     return;
   if (!value)
     return;
@@ -119,8 +119,8 @@ void TRACE_surf_host_set_utilization(const char *resource,
   //trace uncategorized host utilization
   if (TRACE_uncategorized()){
     XBT_DEBUG("UNCAT HOST [%f - %f] %s power_used %f", now, now+delta, resource, value);
-    container_t container = getContainerByName (resource);
-    type_t type = getVariableType("power_used", NULL, container->type);
+    container_t container = PJ_container_get (resource);
+    type_t type = PJ_type_get ("power_used", container->type);
     instr_event (now, delta, type, container, value);
   }
 
@@ -132,8 +132,8 @@ void TRACE_surf_host_set_utilization(const char *resource,
     char category_type[INSTR_DEFAULT_STR_SIZE];
     snprintf (category_type, INSTR_DEFAULT_STR_SIZE, "p%s", surf_action->category);
     XBT_DEBUG("CAT HOST [%f - %f] %s %s %f", now, now+delta, resource, category_type, value);
-    container_t container = getContainerByName (resource);
-    type_t type = getVariableType(category_type, NULL, container->type);
+    container_t container = PJ_container_get (resource);
+    type_t type = PJ_type_get (category_type, container->type);
     instr_event (now, delta, type, container, value);
   }
   return;
index 5482547..ac379d7 100644 (file)
@@ -70,7 +70,10 @@ static void linkContainers (container_t father, container_t src, container_t dst
   //declare type
   char link_typename[INSTR_DEFAULT_STR_SIZE];
   snprintf (link_typename, INSTR_DEFAULT_STR_SIZE, "%s-%s", src->type->name, dst->type->name);
-  type_t link_type = getLinkType (link_typename, father->type, src->type, dst->type);
+  type_t link_type = PJ_type_get (link_typename, father->type);
+  if (link_type == NULL){
+    link_type = PJ_type_link_new (link_typename, father->type, src->type, dst->type);
+  }
 
   //register EDGE types for triva configuration
   xbt_dict_set (trivaEdgeTypes, link_type->name, xbt_strdup("1"), NULL);
@@ -127,7 +130,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
         for (i = 0; i < xbt_dynar_length(route); i++){
           link_CM02_t *link = ((link_CM02_t*)xbt_dynar_get_ptr (route, i));
           char *link_name = (*link)->lmm_resource.generic_resource.name;
-          container_t current = getContainerByName(link_name);
+          container_t current = PJ_container_get(link_name);
           linkContainers(container, previous, current, filter);
           previous = current;
         }
@@ -142,14 +145,14 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
         rc->get_route_and_latency (rc, child1_name, child2_name, route,NULL);
         unsigned int cpt;
         void *link;
-        container_t previous = getContainerByName(route->src_gateway);
+        container_t previous = PJ_container_get(route->src_gateway);
         xbt_dynar_foreach (route->link_list, cpt, link) {
           char *link_name = ((link_CM02_t)link)->lmm_resource.generic_resource.name;
-          container_t current = getContainerByName(link_name);
+          container_t current = PJ_container_get(link_name);
           linkContainers (container, previous, current, filter);
           previous = current;
         }
-        container_t last = getContainerByName(route->dst_gateway);
+        container_t last = PJ_container_get(route->dst_gateway);
         linkContainers (container, previous, last, filter);
         generic_free_route(route);
       }
@@ -162,17 +165,20 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
  */
 static void instr_routing_parse_start_AS (const char*id,const char*routing)
 {
-  if (getRootContainer() == NULL){
-    instr_paje_init ();
-    container_t root = newContainer (id, INSTR_AS, NULL);
-    instr_paje_set_root (root);
-
+  if (PJ_container_get_root() == NULL){
+    PJ_container_alloc ();
+    PJ_type_alloc();
+    container_t root = PJ_container_new (id, INSTR_AS, NULL);
+    PJ_container_set_root (root);
 
     if (TRACE_smpi_is_enabled()) {
       if (!TRACE_smpi_is_grouped()){
-        type_t mpi = getContainerType("MPI", root->type);
-        getStateType ("MPI_STATE", mpi);
-        getLinkType ("MPI_LINK", getRootType(), mpi, mpi);
+        type_t mpi = PJ_type_get ("MPI", root->type);
+        if (mpi == NULL){
+          mpi = PJ_type_container_new("MPI", root->type);
+          PJ_type_state_new ("MPI_STATE", mpi);
+          PJ_type_link_new ("MPI_LINK", PJ_type_get_root(), mpi, mpi);
+        }
       }
     }
 
@@ -185,7 +191,7 @@ static void instr_routing_parse_start_AS (const char*id,const char*routing)
 
   if (TRACE_needs_platform()){
     container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
-    container_t new = newContainer (id, INSTR_AS, father);
+    container_t new = PJ_container_new (id, INSTR_AS, father);
     xbt_dynar_push (currentContainer, &new);
   }
 }
@@ -220,16 +226,25 @@ static void instr_routing_parse_start_link (sg_platf_link_cbarg_t link)
   unsigned int i;
   xbt_dynar_foreach (links_to_create, i, link_name){
 
-    container_t new = newContainer (link_name, INSTR_LINK, father);
+    container_t new = PJ_container_new (link_name, INSTR_LINK, father);
 
     if (TRACE_categorized() || TRACE_uncategorized()){
-      type_t bandwidth = getVariableType ("bandwidth", NULL, new->type);
-      type_t latency = getVariableType ("latency", NULL, new->type);
+      type_t bandwidth = PJ_type_get ("bandwidth", new->type);
+      if (bandwidth == NULL){
+        bandwidth = PJ_type_variable_new ("bandwidth", NULL, new->type);
+      }
+      type_t latency = PJ_type_get ("latency", new->type);
+      if (latency == NULL){
+        latency = PJ_type_variable_new ("latency", NULL, new->type);
+      }
       new_pajeSetVariable (0, new, bandwidth, bandwidth_value);
       new_pajeSetVariable (0, new, latency, latency_value);
     }
     if (TRACE_uncategorized()){
-      getVariableType ("bandwidth_used", "0.5 0.5 0.5", new->type);
+      type_t bandwidth_used = PJ_type_get ("bandwidth_used", new->type);
+      if (bandwidth_used == NULL){
+        bandwidth_used = PJ_type_variable_new ("bandwidth_used", "0.5 0.5 0.5", new->type);
+      }
     }
   }
 
@@ -239,40 +254,52 @@ static void instr_routing_parse_start_link (sg_platf_link_cbarg_t link)
 static void instr_routing_parse_start_host (sg_platf_host_cbarg_t host)
 {
   container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
-  container_t new = newContainer (host->id, INSTR_HOST, father);
+  container_t new = PJ_container_new (host->id, INSTR_HOST, father);
 
   if (TRACE_categorized() || TRACE_uncategorized()) {
-    type_t power = getVariableType ("power", NULL, new->type);
+    type_t power = PJ_type_get ("power", new->type);
+    if (power == NULL){
+      power = PJ_type_variable_new ("power", NULL, new->type);
+    }
     new_pajeSetVariable (0, new, power, host->power_peak);
   }
   if (TRACE_uncategorized()){
-    getVariableType ("power_used", "0.5 0.5 0.5", new->type);
+    type_t power_used = PJ_type_get ("power_used", new->type);
+    if (power_used == NULL){
+      power_used = PJ_type_variable_new ("power_used", "0.5 0.5 0.5", new->type);
+    }
   }
 
   if (TRACE_smpi_is_enabled() && TRACE_smpi_is_grouped()){
-    type_t mpi = getContainerType("MPI", new->type);
-    getStateType ("MPI_STATE", mpi);
-    getLinkType ("MPI_LINK", getRootType(), mpi, mpi);
+    type_t mpi = PJ_type_get ("MPI", new->type);
+    if (mpi == NULL){
+      mpi = PJ_type_container_new("MPI", new->type);
+      PJ_type_state_new ("MPI_STATE", mpi);
+      PJ_type_link_new ("MPI_LINK", PJ_type_get_root(), mpi, mpi);
+    }
   }
 
   if (TRACE_msg_process_is_enabled()) {
-    type_t msg_process = getContainerType("MSG_PROCESS", new->type);
-    type_t state = getStateType ("MSG_PROCESS_STATE", msg_process);
-    getValue ("executing", "0 1 0", state);
-    getValue ("suspend", "1 0 1", state);
-    getValue ("sleep", "1 1 0", state);
-    getValue ("receive", "1 0 0", state);
-    getValue ("send", "0 0 1", state);
-    getValue ("task_execute", "0 1 1", state);
-    getLinkType ("MSG_PROCESS_LINK", getRootType(), msg_process, msg_process);
-    getLinkType ("MSG_PROCESS_TASK_LINK", getRootType(), msg_process, msg_process);
+    type_t msg_process = PJ_type_get ("MSG_PROCESS", new->type);
+    if (msg_process == NULL){
+      msg_process = PJ_type_container_new("MSG_PROCESS", new->type);
+      type_t state = PJ_type_state_new ("MSG_PROCESS_STATE", msg_process);
+      PJ_value_new ("executing", "0 1 0", state);
+      PJ_value_new ("suspend", "1 0 1", state);
+      PJ_value_new ("sleep", "1 1 0", state);
+      PJ_value_new ("receive", "1 0 0", state);
+      PJ_value_new ("send", "0 0 1", state);
+      PJ_value_new ("task_execute", "0 1 1", state);
+      PJ_type_link_new ("MSG_PROCESS_LINK", PJ_type_get_root(), msg_process, msg_process);
+      PJ_type_link_new ("MSG_PROCESS_TASK_LINK", PJ_type_get_root(), msg_process, msg_process);
+    }
   }
 }
 
 static void instr_routing_parse_start_router (sg_platf_router_cbarg_t router)
 {
   container_t father = *(container_t*)xbt_dynar_get_ptr(currentContainer, xbt_dynar_length(currentContainer)-1);
-  newContainer (router->id, INSTR_ROUTER, father);
+  PJ_container_new (router->id, INSTR_ROUTER, father);
 }
 
 static void instr_routing_parse_end_platform ()
@@ -280,7 +307,7 @@ static void instr_routing_parse_end_platform ()
   xbt_dynar_free(&currentContainer);
   currentContainer = NULL;
   xbt_dict_t filter = xbt_dict_new_homogeneous(xbt_free);
-  recursiveGraphExtraction (global_routing->root, getRootContainer(), filter);
+  recursiveGraphExtraction (global_routing->root, PJ_container_get_root(), filter);
   xbt_dict_free(&filter);
   platform_created = 1;
   TRACE_paje_dump_buffer(1);
@@ -309,12 +336,12 @@ static void recursiveNewVariableType (const char *new_typename, const char *colo
   if (!strcmp (root->name, "HOST")){
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "p%s", new_typename);
-    getVariableType(tnstr, color, root);
+    PJ_type_variable_new (tnstr, color, root);
   }
   if (!strcmp (root->name, "LINK")){
     char tnstr[INSTR_DEFAULT_STR_SIZE];
     snprintf (tnstr, INSTR_DEFAULT_STR_SIZE, "b%s", new_typename);
-    getVariableType(tnstr, color, root);
+    PJ_type_variable_new (tnstr, color, root);
   }
   xbt_dict_cursor_t cursor = NULL;
   type_t child_type;
@@ -326,13 +353,13 @@ static void recursiveNewVariableType (const char *new_typename, const char *colo
 
 void instr_new_variable_type (const char *new_typename, const char *color)
 {
-  recursiveNewVariableType (new_typename, color, getRootType());
+  recursiveNewVariableType (new_typename, color, PJ_type_get_root());
 }
 
 static void recursiveNewUserVariableType (const char *father_type, const char *new_typename, const char *color, type_t root)
 {
   if (!strcmp (root->name, father_type)){
-    getVariableType(new_typename, color, root);
+    PJ_type_variable_new (new_typename, color, root);
   }
   xbt_dict_cursor_t cursor = NULL;
   type_t child_type;
@@ -344,7 +371,7 @@ static void recursiveNewUserVariableType (const char *father_type, const char *n
 
 void instr_new_user_variable_type  (const char *father_type, const char *new_typename, const char *color)
 {
-  recursiveNewUserVariableType (father_type, new_typename, color, getRootType());
+  recursiveNewUserVariableType (father_type, new_typename, color, PJ_type_get_root());
 }
 
 
@@ -464,7 +491,7 @@ xbt_graph_t instr_routing_platform_graph (void)
   xbt_graph_t ret = xbt_graph_new_graph (0, NULL);
   xbt_dict_t nodes = xbt_dict_new_homogeneous(NULL);
   xbt_dict_t edges = xbt_dict_new_homogeneous(NULL);
-  recursiveXBTGraphExtraction (ret, nodes, edges, global_routing->root, getRootContainer());
+  recursiveXBTGraphExtraction (ret, nodes, edges, global_routing->root, PJ_container_get_root());
   return ret;
 }
 
index 0b9fe0d..ea8d33b 100644 (file)
@@ -156,13 +156,13 @@ void TRACE_smpi_init(int rank)
 
   container_t father;
   if (TRACE_smpi_is_grouped()){
-    father = getContainer (SIMIX_host_self_get_name());
+    father = PJ_container_get (SIMIX_host_self_get_name());
   }else{
-    father = getRootContainer ();
+    father = PJ_container_get_root ();
   }
   xbt_assert(father!=NULL,
       "Could not find a parent for mpi rank %s at function %s", str, __FUNCTION__);
-  newContainer(str, INSTR_SMPI, father);
+  PJ_container_new(str, INSTR_SMPI, father);
 }
 
 void TRACE_smpi_finalize(int rank)
@@ -170,9 +170,9 @@ void TRACE_smpi_finalize(int rank)
   if (!TRACE_smpi_is_enabled()) return;
 
   char str[INSTR_DEFAULT_STR_SIZE];
-  container_t container = getContainer(smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE));
-  removeContainerFromParent (container);
-  destroyContainer (container);
+  container_t container = PJ_container_get(smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE));
+  PJ_container_remove_from_parent (container);
+  PJ_container_free (container);
 }
 
 void TRACE_smpi_collective_in(int rank, int root, const char *operation)
@@ -181,11 +181,13 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_STATE", container->type);
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
-  val_t value = getValue (operation, color, type);
-
+  val_t value = PJ_value_get (operation, type);
+  if (value == NULL){
+    value = PJ_value_new (operation, color, type);
+  }
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
@@ -195,8 +197,8 @@ void TRACE_smpi_collective_out(int rank, int root, const char *operation)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_STATE", container->type);
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_STATE", container->type);
 
   new_pajePopState (SIMIX_get_clock(), container, type);
 }
@@ -208,11 +210,13 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_STATE", container->type);
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_STATE", container->type);
   const char *color = instr_find_color (operation);
-  val_t value = getValue (operation, color, type);
-
+  val_t value = PJ_value_get (operation, type);
+  if (value == NULL){
+    value = PJ_value_new (operation, color, type);
+  }
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
@@ -222,8 +226,8 @@ void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_STATE", container->type);
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_STATE", container->type);
 
   new_pajePopState (SIMIX_get_clock(), container, type);
 }
@@ -237,10 +241,10 @@ void TRACE_smpi_send(int rank, int src, int dst)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(src, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_LINK", getRootType());
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
 
-  new_pajeStartLink (SIMIX_get_clock(), getRootContainer(), type, container, "PTP", key);
+  new_pajeStartLink (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
 }
 
 void TRACE_smpi_recv(int rank, int src, int dst)
@@ -252,9 +256,9 @@ void TRACE_smpi_recv(int rank, int src, int dst)
 
   char str[INSTR_DEFAULT_STR_SIZE];
   smpi_container(dst, str, INSTR_DEFAULT_STR_SIZE);
-  container_t container = getContainer (str);
-  type_t type = getType ("MPI_LINK", getRootType());
+  container_t container = PJ_container_get (str);
+  type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
 
-  new_pajeEndLink (SIMIX_get_clock(), getRootContainer(), type, container, "PTP", key);
+  new_pajeEndLink (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
 }
 #endif /* HAVE_TRACING */
index 73926c9..2b489c2 100644 (file)
@@ -27,8 +27,8 @@ void TRACE_surf_host_set_power(double date, const char *resource, double power)
   if (!TRACE_is_enabled())
     return;
 
-  container_t container = getContainerByName(resource);
-  type_t type = getVariableType("power", NULL, container->type);
+  container_t container = PJ_container_get(resource);
+  type_t type = PJ_type_get ("power", container->type);
   new_pajeSetVariable(date, container, type, power);
 }
 
@@ -37,8 +37,8 @@ void TRACE_surf_link_set_bandwidth(double date, const char *resource, double ban
   if (!TRACE_is_enabled())
     return;
 
-  container_t container = getContainerByName(resource);
-  type_t type = getVariableType("bandwidth", NULL, container->type);
+  container_t container = PJ_container_get(resource);
+  type_t type = PJ_type_get ("bandwidth", container->type);
   new_pajeSetVariable(date, container, type, bandwidth);
 }
 
@@ -48,8 +48,8 @@ void TRACE_surf_link_set_latency(double date, const char *resource, double laten
   if (!TRACE_is_enabled())
     return;
 
-  container_t container = getContainerByName(resource);
-  type_t type = getVariableType("latency", NULL, container->type);
+  container_t container = PJ_container_get(resource);
+  type_t type = PJ_type_get ("latency", container->type);
   new_pajeSetVariable(date, container, type, latency);
 }