Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[SMPI/PAPI] Make PAPI counters compile again ;)
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Wed, 4 Jul 2018 14:07:22 +0000 (16:07 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 5 Jul 2018 06:57:53 +0000 (08:57 +0200)
This commit contains all the changes that were necessary
to reflect the changes in SimGrid/S4U since 2016.

src/smpi/include/private.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/internals/smpi_process.cpp

index 2556f4c..bac1653 100644 (file)
@@ -427,6 +427,11 @@ XBT_PRIVATE smpi_privatization_region_t smpi_init_global_memory_segment_process(
 
 #if HAVE_PAPI
 typedef std::vector<std::pair</* counter name */ std::string, /* counter value */ long long>> papi_counter_t;
+struct papi_process_data {
+  papi_counter_t counter_data;
+  int event_set;
+};
+extern std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
 #endif
 
 extern std::unordered_map<std::string, double> location2speedup;
index 57ac211..504f43c 100644 (file)
@@ -187,7 +187,7 @@ void TRACE_smpi_init(int rank)
 
   TRACE_smpi_setup_container(rank, sg_host_self());
 #if HAVE_PAPI
-  container_t container   = simgrid::instr::Container::by_name(str);
+  container_t container   = smpi_container(rank);
   papi_counter_t counters = smpi_process()->papi_counters();
 
   for (auto const& it : counters) {
@@ -195,9 +195,7 @@ void TRACE_smpi_init(int rank)
      * Check whether this variable already exists or not. Otherwise, it will be created
      * multiple times but only the last one would be used...
      */
-    if (s_type::getOrNull(it.first.c_str(), container->type_) == nullptr) {
-      Type::variableNew(it.first.c_str(), "", container->type_);
-    }
+    container->type_->by_name_or_create(it.first, "");
   }
 #endif
 }
index 56b211e..ac7f78c 100644 (file)
@@ -119,7 +119,7 @@ void smpi_bench_end()
    * An MPI function has been called and now is the right time to update
    * our PAPI counters for this process.
    */
-  if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0') {
+  if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
     papi_counter_t& counter_data        = smpi_process()->papi_counters();
     int event_set                       = smpi_process()->papi_event_set();
     std::vector<long long> event_values = std::vector<long long>(counter_data.size());
@@ -159,14 +159,14 @@ void smpi_bench_end()
   }
 
 #if HAVE_PAPI
-  if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0' && TRACE_smpi_is_enabled()) {
+  if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty() && TRACE_smpi_is_enabled()) {
     container_t container =
-        new simgrid::instr::Container(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
+        simgrid::instr::Container::by_name(std::string("rank-") + std::to_string(simgrid::s4u::this_actor::get_pid()));
     papi_counter_t& counter_data = smpi_process()->papi_counters();
 
     for (auto const& pair : counter_data) {
-      new simgrid::instr::SetVariableEvent(
-          surf_get_clock(), container, PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second);
+      simgrid::instr::VariableType* variable = static_cast<simgrid::instr::VariableType*>(container->type_->by_name(pair.first));
+      variable->set_event(surf_get_clock(), pair.second);
     }
   }
 #endif
index 9518a17..3ce72e1 100644 (file)
@@ -51,12 +51,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (ke
 
 #if HAVE_PAPI
 #include "papi.h"
-const char* papi_default_config_name = "default";
-
-struct papi_process_data {
-  papi_counter_t counter_data;
-  int event_set;
-};
+std::string papi_default_config_name = "default";
+std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
 #endif
 
 using simgrid::s4u::Actor;
@@ -279,13 +275,11 @@ void smpi_global_init()
   // This map holds for each computation unit (such as "default" or "process1" etc.)
   // the configuration as given by the user (counter data as a pair of (counter_name, counter_counter))
   // and the (computed) event_set.
-  std::map</* computation unit name */ std::string, papi_process_data> units2papi_setup;
 
   if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
     if (PAPI_library_init(PAPI_VER_CURRENT) != PAPI_VER_CURRENT)
       XBT_ERROR("Could not initialize PAPI library; is it correctly installed and linked?"
-                " Expected version is %i",
-                PAPI_VER_CURRENT);
+                " Expected version is %u", PAPI_VER_CURRENT);
 
     typedef boost::tokenizer<boost::char_separator<char>> Tokenizer;
     boost::char_separator<char> separator_units(";");
index d5edd03..661968f 100644 (file)
 #include "src/msg/msg_private.hpp"
 #include "src/simix/smx_private.hpp"
 
+#if HAVE_PAPI
+#include "papi.h"
+extern std::string papi_default_config_name;
+#endif
+
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_process, smpi, "Logging specific to SMPI (kernel)");
 
 namespace simgrid{
@@ -30,7 +35,7 @@ Process::Process(ActorPtr actor, msg_bar_t finalization_barrier)
     MC_ignore_heap(timer_, xbt_os_timer_size());
 
 #if HAVE_PAPI
-  if (simgrid::config::get_value<std::string>("smpi/papi-events")[0] != '\0') {
+  if (not simgrid::config::get_value<std::string>("smpi/papi-events").empty()) {
     // TODO: Implement host/process/thread based counters. This implementation
     // just always takes the values passed via "default", like this:
     // "default:COUNTER1:COUNTER2:COUNTER3;".
@@ -38,10 +43,10 @@ Process::Process(ActorPtr actor, msg_bar_t finalization_barrier)
     if (it != units2papi_setup.end()) {
       papi_event_set_    = it->second.event_set;
       papi_counter_data_ = it->second.counter_data;
-      XBT_DEBUG("Setting PAPI set for process %i", i);
+      XBT_DEBUG("Setting PAPI set for process %li", actor->get_pid());
     } else {
       papi_event_set_ = PAPI_NULL;
-      XBT_DEBUG("No PAPI set for process %i", i);
+      XBT_DEBUG("No PAPI set for process %li", actor->get_pid());
     }
   }
 #endif