Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add some debug messages for smpi tracing
[simgrid.git] / src / smpi / instr_smpi.cpp
index 4079b4c..ee21f42 100644 (file)
@@ -5,10 +5,11 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.h"
+#include "private.hpp"
 #include <ctype.h>
-#include <wchar.h>
-#include <stdarg.h>
 #include <simgrid/sg_config.h>
+#include <stdarg.h>
+#include <wchar.h>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_smpi, instr, "Tracing SMPI");
 
@@ -170,7 +171,7 @@ void TRACE_internal_smpi_set_category (const char *category)
     xbt_dict_set (process_category, processid, xbt_strdup(category), nullptr);
 }
 
-const char *TRACE_internal_smpi_get_category (void)
+const char *TRACE_internal_smpi_get_category ()
 {
   if (!TRACE_smpi_is_enabled())
     return nullptr;
@@ -186,7 +187,7 @@ void TRACE_smpi_alloc()
   process_category = xbt_dict_new_homogeneous(xbt_free_f);
 }
 
-void TRACE_smpi_release(void)
+void TRACE_smpi_release()
 {
   xbt_dict_free(&keys);
   xbt_dict_free(&process_category);
@@ -208,7 +209,23 @@ void TRACE_smpi_init(int rank)
   }
   xbt_assert(father!=nullptr,
       "Could not find a parent for mpi rank %s at function %s", str, __FUNCTION__);
-  PJ_container_new(str, INSTR_SMPI, father);
+#if HAVE_PAPI
+  container_t container =
+#endif
+      PJ_container_new(str, INSTR_SMPI, father);
+#if HAVE_PAPI
+  papi_counter_t counters = smpi_process_papi_counters();
+
+  for (auto& it : counters) {
+    /**
+     * Check whether this variable already exists or not. Otherwise, it will be created
+     * multiple times but only the last one would be used...
+     */
+    if (PJ_type_get_or_null(it.first.c_str(), container->type) == nullptr) {
+      PJ_type_variable_new(it.first.c_str(), nullptr, container->type);
+    }
+  }
+#endif
 }
 
 void TRACE_smpi_finalize(int rank)
@@ -403,7 +420,7 @@ void TRACE_smpi_send(int rank, int src, int dst, int size)
   smpi_container(src, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
-
+  XBT_DEBUG("Send tracing from %d to %d, with key %s", src, dst, key);
   new_pajeStartLinkWithSize (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
 }
 
@@ -419,6 +436,6 @@ void TRACE_smpi_recv(int rank, int src, int dst)
   smpi_container(dst, str, INSTR_DEFAULT_STR_SIZE);
   container_t container = PJ_container_get (str);
   type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
-
+  XBT_DEBUG("Recv tracing from %d to %d, with key %s", src, dst, key);
   new_pajeEndLink (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
 }