Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[trace] make sure variable is zeroed before writing on it
[simgrid.git] / src / instr / instr_smpi.c
index d4fab07..b0e8dc1 100644 (file)
@@ -86,7 +86,7 @@ static char *TRACE_smpi_put_key(int src, int dst, char *key, int n)
   }
   //generate the key
   static unsigned long long counter = 0;
-  snprintf(key, n, "%d%d%lld", src, dst, counter++);
+  snprintf(key, n, "%d%d%llu", src, dst, counter++);
 
   //push it
   char *a = (char*)xbt_strdup(key);
@@ -141,17 +141,10 @@ void TRACE_smpi_alloc()
   process_category = xbt_dict_new_homogeneous(xbt_free);
 }
 
-void TRACE_smpi_start(void)
-{
-  TRACE_start();
-}
-
 void TRACE_smpi_release(void)
 {
-  if (!TRACE_smpi_is_enabled()) return;
-
-  TRACE_surf_release();
-  TRACE_end();
+  xbt_dict_free(&keys);
+  xbt_dict_free(&process_category);
 }
 
 void TRACE_smpi_init(int rank)
@@ -163,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)
@@ -177,8 +170,9 @@ void TRACE_smpi_finalize(int rank)
   if (!TRACE_smpi_is_enabled()) return;
 
   char str[INSTR_DEFAULT_STR_SIZE];
-  smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
-  destroyContainer(getContainer (str));
+  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)
@@ -187,11 +181,10 @@ 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_or_new (operation, color, type);
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
@@ -201,8 +194,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);
 }
@@ -214,11 +207,10 @@ 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_or_new (operation, color, type);
   new_pajePushState (SIMIX_get_clock(), container, type, value);
 }
 
@@ -228,8 +220,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);
 }
@@ -239,14 +231,15 @@ void TRACE_smpi_send(int rank, int src, int dst)
   if (!TRACE_smpi_is_enabled()) return;
 
   char key[INSTR_DEFAULT_STR_SIZE];
+  bzero (key, INSTR_DEFAULT_STR_SIZE);
   TRACE_smpi_put_key(src, dst, key, INSTR_DEFAULT_STR_SIZE);
 
   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)
@@ -254,13 +247,14 @@ void TRACE_smpi_recv(int rank, int src, int dst)
   if (!TRACE_smpi_is_enabled()) return;
 
   char key[INSTR_DEFAULT_STR_SIZE];
+  bzero (key, INSTR_DEFAULT_STR_SIZE);
   TRACE_smpi_get_key(src, dst, key, INSTR_DEFAULT_STR_SIZE);
 
   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 */