Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
0b4d32f8d8edd301160b21d43a80104e7105407b
[simgrid.git] / include / simgrid / smpi / replay.hpp
1 /* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5 #include "private.hpp"
6 #include <xbt/replay.hpp>
7
8 #include <sstream>
9
10 #define CHECK_ACTION_PARAMS(action, mandatory, optional)                                                             \
11 {                                                                                                                    \
12   if (action.size() < static_cast<unsigned long>(mandatory + 2)) {                                                   \
13     std::stringstream ss;                                                                                            \
14     for (const auto& elem : action) {                                                                                \
15       ss << elem << " ";                                                                                             \
16     }                                                                                                                \
17     THROWF(arg_error, 0, "%s replay failed.\n"                                                                       \
18                          "%zu items were given on the line. First two should be process_id and action.  "            \
19                          "This action needs after them %lu mandatory arguments, and accepts %lu optional ones. \n"   \
20                          "The full line that was given is:\n   %s\n"                                                 \
21                          "Please contact the Simgrid team if support is needed",                                     \
22            __func__, action.size(), static_cast<unsigned long>(mandatory), static_cast<unsigned long>(optional),     \
23            ss.str().c_str());                                                                                        \
24   }                                                                                                                  \
25 }
26
27 namespace simgrid {
28 namespace smpi {
29 namespace replay {
30 extern MPI_Datatype MPI_DEFAULT_TYPE;
31
32 class RequestStorage; // Forward decl
33
34 /**
35  * Base class for all parsers.
36  */
37 class ActionArgParser {
38 public:
39   virtual ~ActionArgParser() = default;
40   virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) { CHECK_ACTION_PARAMS(action, 0, 0) }
41 };
42
43 class WaitTestParser : public ActionArgParser {
44 public:
45   int src;
46   int dst;
47   int tag;
48
49   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
50 };
51
52 class SendRecvParser : public ActionArgParser {
53 public:
54   /* communication partner; if we send, this is the receiver and vice versa */
55   int partner;
56   double size;
57   int tag;
58   MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
59
60   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
61 };
62
63 class ComputeParser : public ActionArgParser {
64 public:
65   /* communication partner; if we send, this is the receiver and vice versa */
66   double flops;
67
68   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
69 };
70
71 class CollCommParser : public ActionArgParser {
72 public:
73   double size;
74   double comm_size;
75   double comp_size;
76   int send_size;
77   int recv_size;
78   int root = 0;
79   MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
80   MPI_Datatype datatype2 = MPI_DEFAULT_TYPE;
81
82   virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) = 0;
83 };
84
85 class BcastArgParser : public CollCommParser {
86 public:
87   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
88 };
89
90 class ReduceArgParser : public CollCommParser {
91 public:
92   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
93 };
94
95 class AllReduceArgParser : public CollCommParser {
96 public:
97   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
98 };
99
100 class AllToAllArgParser : public CollCommParser {
101 public:
102   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
103 };
104
105 class GatherArgParser : public CollCommParser {
106 public:
107   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
108 };
109
110 class GatherVArgParser : public CollCommParser {
111 public:
112   int recv_size_sum;
113   std::shared_ptr<std::vector<int>> recvcounts;
114   std::vector<int> disps;
115   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
116 };
117
118 class ScatterArgParser : public CollCommParser {
119 public:
120   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
121 };
122
123 class ScatterVArgParser : public CollCommParser {
124 public:
125   int recv_size_sum;
126   int send_size_sum;
127   std::shared_ptr<std::vector<int>> sendcounts;
128   std::vector<int> disps;
129   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
130 };
131
132 class ReduceScatterArgParser : public CollCommParser {
133 public:
134   int recv_size_sum;
135   std::shared_ptr<std::vector<int>> recvcounts;
136   std::vector<int> disps;
137   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
138 };
139
140 class AllToAllVArgParser : public CollCommParser {
141 public:
142   int recv_size_sum;
143   int send_size_sum;
144   std::shared_ptr<std::vector<int>> recvcounts;
145   std::shared_ptr<std::vector<int>> sendcounts;
146   std::vector<int> senddisps;
147   std::vector<int> recvdisps;
148   int send_buf_size;
149   int recv_buf_size;
150   void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
151 };
152
153
154 }
155 }
156 }