From 018dbe8afafe687069d74c58fea3a2f9a15a8085 Mon Sep 17 00:00:00 2001 From: Augustin Degomme Date: Thu, 3 Oct 2019 12:11:57 +0200 Subject: [PATCH] Add call_location to ti-trace and replay as well. A new "location" event in the trace is printed --- include/simgrid/smpi/replay.hpp | 15 ++++++++++++++- src/instr/instr_paje_events.cpp | 15 +++++++++------ src/smpi/include/private.hpp | 1 + src/smpi/internals/smpi_bench.cpp | 27 +++++++++++++++------------ src/smpi/internals/smpi_replay.cpp | 15 ++++++++++++++- 5 files changed, 53 insertions(+), 20 deletions(-) diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index 169d71c95d..c0d6206869 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -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 { +public: + explicit LocationAction() : ReplayAction("location") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + class TestAction : public ReplayAction { private: RequestStorage& req_storage; diff --git a/src/instr/instr_paje_events.cpp b/src/instr/instr_paje_events.cpp index c30b301084..ba18219ff8 100644 --- a/src/instr/instr_paje_events.cpp +++ b/src/instr/instr_paje_events.cpp @@ -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("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; diff --git a/src/smpi/include/private.hpp b/src/smpi/include/private.hpp index 73a655668b..ca7e3abdf8 100644 --- a/src/smpi/include/private.hpp +++ b/src/smpi/include/private.hpp @@ -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); diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index 9b89d2424e..20e22c73fd 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -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("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::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("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::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("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 diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index b901e96926..e09343369b 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -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) { -- 2.20.1