Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Simplifications
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 11 Mar 2019 15:31:17 +0000 (16:31 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 11 Mar 2019 15:31:17 +0000 (16:31 +0100)
Do not use an ugly global map when each smpi process can store its own
tracing category.

src/instr/instr_smpi.hpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/include/smpi_actor.hpp
src/smpi/internals/instr_smpi.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/mpi/smpi_request.cpp

index afe5c57..4ac56a9 100644 (file)
@@ -14,8 +14,6 @@
 XBT_PRIVATE container_t smpi_container(int rank);
 XBT_PRIVATE void TRACE_smpi_setup_container(int rank, sg_host_t host);
 
-XBT_PRIVATE void TRACE_internal_smpi_set_category(const std::string& category);
-XBT_PRIVATE std::string TRACE_internal_smpi_get_category();
 XBT_PRIVATE void TRACE_smpi_computing_init(int rank);
 XBT_PRIVATE void TRACE_smpi_computing_out(int rank);
 XBT_PRIVATE void TRACE_smpi_computing_in(int rank, double amount);
index 8d8886f..49b2b37 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "private.hpp"
+#include "simgrid/instr.h"
 #include "simgrid/s4u/Engine.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "smpi_comm.hpp"
@@ -19,8 +20,11 @@ void TRACE_smpi_set_category(const char *category)
 {
   //need to end bench otherwise categories for execution tasks are wrong
   smpi_bench_end();
-  if (category != nullptr)
-    TRACE_internal_smpi_set_category(category);
+  if (category != nullptr) {
+    // declare category
+    TRACE_category(category);
+    smpi_process()->set_tracing_category(category);
+  }
   //begin bench after changing process's category
   smpi_bench_begin();
 }
index 067fe28..1314d4b 100644 (file)
@@ -33,6 +33,8 @@ private:
   s4u::ActorPtr actor_                           = nullptr;
   smpi_privatization_region_t privatized_region_ = nullptr;
   int optind                                     = 0; /*for getopt replacement */
+  std::string tracing_category_                  = "";
+
 #if HAVE_PAPI
   /** Contains hardware data as read by PAPI **/
   int papi_event_set_;
@@ -51,6 +53,8 @@ public:
   void mark_as_initialized();
   void set_replaying(bool value);
   bool replaying();
+  void set_tracing_category(const std::string& category) { tracing_category_ = category; }
+  const std::string& get_tracing_category() { return tracing_category_; }
   smpi_trace_call_location_t* call_location();
   void set_privatized_region(smpi_privatization_region_t region);
   smpi_privatization_region_t privatized_region();
index bcb4782..4d3ab5a 100644 (file)
@@ -134,29 +134,6 @@ static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
   return key;
 }
 
-static std::unordered_map<smx_actor_t, std::string> process_category;
-
-void TRACE_internal_smpi_set_category(const std::string& category)
-{
-  if (not TRACE_smpi_is_enabled())
-    return;
-
-  //declare category
-  TRACE_category(category.c_str());
-
-  if (not category.empty())
-    process_category[SIMIX_process_self()] = category;
-}
-
-std::string TRACE_internal_smpi_get_category()
-{
-  if (not TRACE_smpi_is_enabled())
-    return "";
-
-  auto it = process_category.find(SIMIX_process_self());
-  return (it == process_category.end()) ? "" : it->second.c_str();
-}
-
 void TRACE_smpi_setup_container(int rank, sg_host_t host)
 {
   container_t father = simgrid::instr::Container::get_root();
index b987d85..c6af123 100644 (file)
@@ -57,7 +57,7 @@ void smpi_execute_flops(double flops) {
   XBT_DEBUG("Handle real computation time: %f flops", flops);
   simgrid::s4u::this_actor::exec_init(flops)
       ->set_name("computation")
-      ->set_tracing_category(TRACE_internal_smpi_get_category())
+      ->set_tracing_category(smpi_process()->get_tracing_category())
       ->start()
       ->wait();
   smpi_switch_data_segment(simgrid::s4u::Actor::self());
index 3a01a16..5bbd84e 100644 (file)
@@ -516,7 +516,7 @@ void Request::start()
 
     /* FIXME: detached sends are not traceable (action_ == nullptr) */
     if (action_ != nullptr) {
-      std::string category = TRACE_internal_smpi_get_category();
+      std::string category = smpi_process()->get_tracing_category();
       simgrid::simix::simcall([this, category] { this->action_->set_category(category); });
     }