Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[REPLAY] Update replay.hpp
authorChristian Heinrich <franz-christian.heinrich@inria.fr>
Tue, 29 May 2018 18:20:39 +0000 (20:20 +0200)
committerChristian Heinrich <franz-christian.heinrich@inria.fr>
Thu, 21 Jun 2018 10:08:47 +0000 (12:08 +0200)
- Remove implementation of ReplayAction<T>::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
src/smpi/internals/smpi_replay.cpp

index b52cb32..99a9f1d 100644 (file)
@@ -5,12 +5,12 @@
 #ifndef SMPI_REPLAY_HPP_
 #define SMPI_REPLAY_HPP_
 
 #ifndef SMPI_REPLAY_HPP_
 #define SMPI_REPLAY_HPP_
 
-#include "smpi/smpi.h"
-#include <simgrid/s4u/Actor.hpp>
-#include <memory>
+#include <boost/algorithm/string/join.hpp>
+#include <src/smpi/include/smpi_process.hpp>
 #include <xbt/replay.hpp>
 #include <xbt/ex.h>
 
 #include <xbt/replay.hpp>
 #include <xbt/ex.h>
 
+#include <memory>
 #include <sstream>
 
 #define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                             \
 #include <sstream>
 
 #define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                             \
   }                                                                                                                  \
 }
 
   }                                                                                                                  \
 }
 
-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 {
 
 namespace simgrid {
 namespace smpi {
@@ -89,6 +91,8 @@ public:
   int root = 0;
   MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
   MPI_Datatype datatype2 = MPI_DEFAULT_TYPE;
   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 {
 };
 
 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
 /**
  * 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 T> class ReplayAction {
  * In other words: The logic goes here, the setup is done by the ActionArgParser.
  */
 template <class T> 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;
 
   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); }
   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); }
index c28efd1..8a7032f 100644 (file)
@@ -64,8 +64,7 @@ public:
 typedef std::tuple</*sender*/ int, /* reciever */ int, /* tag */int> req_key_t;
 typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> req_storage_t;
 
 typedef std::tuple</*sender*/ int, /* reciever */ int, /* tag */int> req_key_t;
 typedef std::unordered_map<req_key_t, MPI_Request, hash_tuple::hash<std::tuple<int,int,int>>> 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, " ");
 {
   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);
 }
 
   recv_size_sum = std::accumulate(recvcounts->begin(), recvcounts->end(), 0);
 }
 
-template<class T>
-void ReplayAction<T>::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, " ");
 void WaitAction::kernel(simgrid::xbt::ReplayAction& action)
 {
   std::string s = boost::algorithm::join(action, " ");