From 9913e297eeba0983a5ff635c076e3f458b178766 Mon Sep 17 00:00:00 2001 From: Christian Heinrich Date: Tue, 29 May 2018 20:20:39 +0200 Subject: [PATCH 1/1] [REPLAY] Update replay.hpp - Remove implementation of ReplayAction::execute This fixes issues with templated classes and virtual functions - Remove 'static' attribute for log_timed_action() This function may be useful for user-defined functions as well. --- include/simgrid/smpi/replay.hpp | 31 +++++++++++++++++++++--------- src/smpi/internals/smpi_replay.cpp | 14 +------------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index b52cb32bbd..99a9f1d64e 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -5,12 +5,12 @@ #ifndef SMPI_REPLAY_HPP_ #define SMPI_REPLAY_HPP_ -#include "smpi/smpi.h" -#include -#include +#include +#include #include #include +#include #include #define CHECK_ACTION_PARAMS(action, mandatory, optional) \ @@ -30,10 +30,12 @@ } \ } -extern XBT_PRIVATE void* smpi_get_tmp_sendbuffer(int size); -extern XBT_PRIVATE void* smpi_get_tmp_recvbuffer(int size); -extern XBT_PRIVATE void smpi_free_tmp_buffer(void* buf); -extern XBT_PRIVATE void smpi_free_replay_tmp_buffers(); +XBT_PRIVATE void* smpi_get_tmp_sendbuffer(int size); +XBT_PRIVATE void* smpi_get_tmp_recvbuffer(int size); +XBT_PRIVATE void smpi_free_tmp_buffer(void* buf); +XBT_PRIVATE void smpi_free_replay_tmp_buffers(); + +XBT_PRIVATE void log_timed_action(simgrid::xbt::ReplayAction& action, double clock); namespace simgrid { namespace smpi { @@ -89,6 +91,8 @@ public: int root = 0; MPI_Datatype datatype1 = MPI_DEFAULT_TYPE; MPI_Datatype datatype2 = MPI_DEFAULT_TYPE; + + virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) = 0; }; class BcastArgParser : public CollCommParser { @@ -162,7 +166,7 @@ public: /** * Base class for all ReplayActions. * Note that this class actually implements the behavior of each action - * while the parsing of the replay arguments is done in the ActionArgParser class. + * while the parsing of the replay arguments is done in the @ActionArgParser class. * In other words: The logic goes here, the setup is done by the ActionArgParser. */ template class ReplayAction { @@ -175,7 +179,16 @@ public: explicit ReplayAction(std::string name) : name(name), my_proc_id(simgrid::s4u::this_actor::get_pid()) {} virtual ~ReplayAction() = default; - virtual void execute(simgrid::xbt::ReplayAction& action); + void execute(simgrid::xbt::ReplayAction& action) + { + // Needs to be re-initialized for every action, hence here + double start_time = smpi_process()->simulated_elapsed(); + args.parse(action, name); + kernel(action); + if (name != "Init") + log_timed_action(action, start_time); + } + virtual void kernel(simgrid::xbt::ReplayAction& action) = 0; void* send_buffer(int size) { return smpi_get_tmp_sendbuffer(size); } void* recv_buffer(int size) { return smpi_get_tmp_recvbuffer(size); } diff --git a/src/smpi/internals/smpi_replay.cpp b/src/smpi/internals/smpi_replay.cpp index c28efd1f31..8a7032f910 100644 --- a/src/smpi/internals/smpi_replay.cpp +++ b/src/smpi/internals/smpi_replay.cpp @@ -64,8 +64,7 @@ public: typedef std::tuple req_key_t; typedef std::unordered_map>> req_storage_t; - -static void log_timed_action(simgrid::xbt::ReplayAction& action, double clock) +void log_timed_action(simgrid::xbt::ReplayAction& action, double clock) { if (XBT_LOG_ISENABLED(smpi_replay, xbt_log_priority_verbose)){ std::string s = boost::algorithm::join(action, " "); @@ -393,17 +392,6 @@ void AllToAllVArgParser::parse(simgrid::xbt::ReplayAction& action, std::string n recv_size_sum = std::accumulate(recvcounts->begin(), recvcounts->end(), 0); } -template -void ReplayAction::execute(simgrid::xbt::ReplayAction& action) -{ - // Needs to be re-initialized for every action, hence here - double start_time = smpi_process()->simulated_elapsed(); - args.parse(action, name); - kernel(action); - if (name != "Init") - log_timed_action(action, start_time); -} - void WaitAction::kernel(simgrid::xbt::ReplayAction& action) { std::string s = boost::algorithm::join(action, " "); -- 2.20.1