Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[TRACING] Rename TIT action reduceScatter -> reducescatter
[simgrid.git] / include / simgrid / smpi / replay.hpp
index 0a4f4a6..9aa7110 100644 (file)
@@ -2,9 +2,15 @@
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
-#include "private.hpp"
+#ifndef SMPI_REPLAY_HPP_
+#define SMPI_REPLAY_HPP_
+
+#include <boost/algorithm/string/join.hpp>
+#include <src/smpi/include/smpi_process.hpp>
 #include <xbt/replay.hpp>
+#include <xbt/ex.h>
 
+#include <memory>
 #include <sstream>
 
 #define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                             \
   }                                                                                                                  \
 }
 
+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 replay {
@@ -78,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 {
@@ -164,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); }
@@ -229,7 +253,7 @@ private:
   RequestStorage& req_storage;
 
 public:
-  explicit WaitAllAction(RequestStorage& storage) : ReplayAction("waitAll"), req_storage(storage) {}
+  explicit WaitAllAction(RequestStorage& storage) : ReplayAction("waitall"), req_storage(storage) {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
@@ -253,7 +277,7 @@ public:
 
 class AllReduceAction : public ReplayAction<AllReduceArgParser> {
 public:
-  explicit AllReduceAction() : ReplayAction("allReduce") {}
+  explicit AllReduceAction() : ReplayAction("allreduce") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
@@ -283,13 +307,13 @@ public:
 
 class ScatterVAction : public ReplayAction<ScatterVArgParser> {
 public:
-  explicit ScatterVAction() : ReplayAction("scatterV") {}
+  explicit ScatterVAction() : ReplayAction("scatterv") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
 class ReduceScatterAction : public ReplayAction<ReduceScatterArgParser> {
 public:
-  explicit ReduceScatterAction() : ReplayAction("reduceScatter") {}
+  explicit ReduceScatterAction() : ReplayAction("reducescatter") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
@@ -301,3 +325,5 @@ public:
 }
 }
 }
+
+#endif