Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add call_location to ti-trace and replay as well.
authorAugustin Degomme <adegomme@gmail.com>
Thu, 3 Oct 2019 10:11:57 +0000 (12:11 +0200)
committerAugustin Degomme <adegomme@gmail.com>
Thu, 3 Oct 2019 14:27:04 +0000 (16:27 +0200)
A new "location" event in the trace is printed

include/simgrid/smpi/replay.hpp
src/instr/instr_paje_events.cpp
src/smpi/include/private.hpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_replay.cpp

index 169d71c..c0d6206 100644 (file)
@@ -74,12 +74,19 @@ public:
 
 class ComputeParser : public ActionArgParser {
 public:
-  /* communication partner; if we send, this is the receiver and vice versa */
   double flops;
 
   void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
 };
 
+class LocationParser : public ActionArgParser {
+public:
+  std::string filename;
+  int line;
+
+  void parse(simgrid::xbt::ReplayAction& action, const std::string& name) override;
+};
+
 class CollCommParser : public ActionArgParser {
 public:
   double size;
@@ -224,6 +231,12 @@ public:
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
+class LocationAction : public ReplayAction<LocationParser> {
+public:
+  explicit LocationAction() : ReplayAction("location") {}
+  void kernel(simgrid::xbt::ReplayAction& action) override;
+};
+
 class TestAction : public ReplayAction<WaitTestParser> {
 private:
   RequestStorage& req_storage;
index c30b301..ba18219 100644 (file)
@@ -105,15 +105,18 @@ void StateEvent::print()
       return;
 
     /* Unimplemented calls are: WAITANY, SENDRECV, SCAN, EXSCAN, SSEND, and ISSEND. */
-
+    std::string container_name(get_container()->get_name());
     // FIXME: dirty extract "rank-" from the name, as we want the bare process id here
-    if (get_container()->get_name().find("rank-") != 0) {
-      stream_ << get_container()->get_name() << " " << extra_->print();
-    } else {
+    if (get_container()->get_name().find("rank-") == 0) {
       /* Subtract -1 because this is the process id and we transform it to the rank id */
-      std::string container_name(get_container()->get_name());
-      stream_ << stoi(container_name.erase(0, 5)) - 1 << " " << extra_->print();
+      container_name=std::to_string(stoi(container_name.erase(0, 5)) - 1);
+    }
+    #if HAVE_SMPI
+    if (simgrid::config::get_value<bool>("smpi/trace-call-location")) {
+      stream_ << container_name << " location " << filename << " " << linenumber << std::endl ;
     }
+    #endif
+    stream_ << container_name << " " << extra_->print();
     *tracing_files.at(get_container()) << stream_.str() << std::endl;
   } else {
     THROW_IMPOSSIBLE;
index 73a6556..ca7e3ab 100644 (file)
@@ -111,6 +111,7 @@ XBT_PRIVATE void smpi_bench_destroy();
 XBT_PRIVATE void smpi_bench_begin();
 XBT_PRIVATE void smpi_bench_end();
 XBT_PRIVATE void smpi_shared_destroy();
+XBT_PRIVATE double smpi_adjust_comp_speed();
 
 XBT_PRIVATE unsigned char* smpi_get_tmp_sendbuffer(size_t size);
 XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size);
index 9b89d24..20e22c7 100644 (file)
@@ -108,12 +108,25 @@ void smpi_bench_begin()
   xbt_os_threadtimer_start(smpi_process()->timer());
 }
 
+double smpi_adjust_comp_speed(){
+  double speedup=1;
+  if (simgrid::config::get_value<std::string>("smpi/comp-adjustment-file")[0] != '\0') {
+
+    smpi_trace_call_location_t* loc                            = smpi_process()->call_location();
+    std::string key                                            = loc->get_composed_key();
+    std::unordered_map<std::string, double>::const_iterator it = location2speedup.find(key);
+    if (it != location2speedup.end()) {
+      speedup = it->second;
+    }
+  }
+  return speedup;
+}
+
 void smpi_bench_end()
 {
   if (MC_is_active() || MC_record_replay_is_active())
     return;
 
-  double speedup = 1;
   xbt_os_timer_t timer = smpi_process()->timer();
   xbt_os_threadtimer_stop(timer);
 
@@ -146,19 +159,9 @@ void smpi_bench_end()
   }
 
   // Maybe we need to artificially speed up or slow down our computation based on our statistical analysis.
-  if (simgrid::config::get_value<std::string>("smpi/comp-adjustment-file")[0] != '\0') {
-
-    smpi_trace_call_location_t* loc                            = smpi_process()->call_location();
-    std::string key                                            = loc->get_composed_key();
-    std::unordered_map<std::string, double>::const_iterator it = location2speedup.find(key);
-    if (it != location2speedup.end()) {
-      speedup = it->second;
-    }
-  }
-
   // Simulate the benchmarked computation unless disabled via command-line argument
   if (simgrid::config::get_value<bool>("smpi/simulate-computation")) {
-    smpi_execute(xbt_os_timer_elapsed(timer)/speedup);
+    smpi_execute(xbt_os_timer_elapsed(timer)/smpi_adjust_comp_speed());
   }
 
 #if HAVE_PAPI
index b901e96..e093433 100644 (file)
@@ -165,6 +165,13 @@ void ComputeParser::parse(simgrid::xbt::ReplayAction& action, const std::string&
   flops = parse_double(action[2]);
 }
 
+void LocationParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
+{
+  CHECK_ACTION_PARAMS(action, 2, 0)
+  filename = std::string(action[2]);
+  line = std::stoi(action[3]);
+}
+
 void BcastArgParser::parse(simgrid::xbt::ReplayAction& action, const std::string&)
 {
   CHECK_ACTION_PARAMS(action, 1, 2)
@@ -477,7 +484,12 @@ void RecvAction::kernel(simgrid::xbt::ReplayAction&)
 
 void ComputeAction::kernel(simgrid::xbt::ReplayAction&)
 {
-  smpi_execute_flops(args.flops);
+  smpi_execute_flops(args.flops/smpi_adjust_comp_speed());
+}
+
+void LocationAction::kernel(simgrid::xbt::ReplayAction&)
+{
+  smpi_trace_set_call_location(args.filename.c_str(), args.line);
 }
 
 void TestAction::kernel(simgrid::xbt::ReplayAction&)
@@ -746,6 +758,7 @@ void smpi_replay_init(const char* instance_id, int rank, double start_delay_flop
   xbt_replay_action_register("allgatherv", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::GatherVAction("allgatherv").execute(action); });
   xbt_replay_action_register("reducescatter", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::ReduceScatterAction().execute(action); });
   xbt_replay_action_register("compute", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::ComputeAction().execute(action); });
+  xbt_replay_action_register("location", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::replay::LocationAction().execute(action); });
 
   //if we have a delayed start, sleep here.
   if (start_delay_flops > 0) {