Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix multiple memleaks in the replay of multiple SMPI instances
[simgrid.git] / include / simgrid / smpi / replay.hpp
index 99a9f1d..21e09f7 100644 (file)
@@ -5,35 +5,35 @@
 #ifndef SMPI_REPLAY_HPP_
 #define SMPI_REPLAY_HPP_
 
+#include "src/smpi/include/smpi_actor.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)                                                             \
-{                                                                                                                    \
-  if (action.size() < static_cast<unsigned long>(mandatory + 2)) {                                                   \
-    std::stringstream ss;                                                                                            \
-    for (const auto& elem : action) {                                                                                \
-      ss << elem << " ";                                                                                             \
-    }                                                                                                                \
-    THROWF(arg_error, 0, "%s replay failed.\n"                                                                       \
-                         "%zu items were given on the line. First two should be process_id and action.  "            \
-                         "This action needs after them %lu mandatory arguments, and accepts %lu optional ones. \n"   \
-                         "The full line that was given is:\n   %s\n"                                                 \
-                         "Please contact the Simgrid team if support is needed",                                     \
-           __func__, action.size(), static_cast<unsigned long>(mandatory), static_cast<unsigned long>(optional),     \
-           ss.str().c_str());                                                                                        \
-  }                                                                                                                  \
-}
+#define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                               \
+  {                                                                                                                    \
+    if (action.size() < static_cast<unsigned long>(mandatory + 2)) {                                                   \
+      std::stringstream ss;                                                                                            \
+      ss << __func__ << " replay failed.\n"                                                                            \
+         << action.size() << " items were given on the line. First two should be process_id and action.  "             \
+         << "This action needs after them " << mandatory << " mandatory arguments, and accepts " << optional           \
+         << " optional ones. \n"                                                                                       \
+         << "The full line that was given is:\n   ";                                                                   \
+      for (const auto& elem : action) {                                                                                \
+        ss << elem << " ";                                                                                             \
+      }                                                                                                                \
+      ss << "\nPlease contact the Simgrid team if support is needed";                                                  \
+      throw std::invalid_argument(ss.str());                                                                           \
+    }                                                                                                                  \
+  }
 
 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);
 
@@ -91,8 +91,6 @@ 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 {
@@ -166,13 +164,13 @@ 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 @ref ActionArgParser class.
  * In other words: The logic goes here, the setup is done by the ActionArgParser.
  */
 template <class T> class ReplayAction {
 protected:
   const std::string name;
-  const int my_proc_id;
+  const aid_t my_proc_id;
   T args;
 
 public:
@@ -253,7 +251,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;
 };
 
@@ -277,13 +275,13 @@ public:
 
 class AllReduceAction : public ReplayAction<AllReduceArgParser> {
 public:
-  explicit AllReduceAction() : ReplayAction("allReduce") {}
+  explicit AllReduceAction() : ReplayAction("allreduce") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
 class AllToAllAction : public ReplayAction<AllToAllArgParser> {
 public:
-  explicit AllToAllAction() : ReplayAction("allToAll") {}
+  explicit AllToAllAction() : ReplayAction("alltoall") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 
@@ -307,19 +305,19 @@ 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;
 };
 
 class AllToAllVAction : public ReplayAction<AllToAllVArgParser> {
 public:
-  explicit AllToAllVAction() : ReplayAction("allToAllV") {}
+  explicit AllToAllVAction() : ReplayAction("alltoallv") {}
   void kernel(simgrid::xbt::ReplayAction& action) override;
 };
 }