1 /* Copyright (c) 2009-2018. The SimGrid Team. All rights reserved. */
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. */
6 #include <xbt/replay.hpp>
10 #define CHECK_ACTION_PARAMS(action, mandatory, optional) \
12 if (action.size() < static_cast<unsigned long>(mandatory + 2)) { \
13 std::stringstream ss; \
14 for (const auto& elem : action) { \
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), \
30 extern MPI_Datatype MPI_DEFAULT_TYPE;
32 class RequestStorage; // Forward decl
35 * Base class for all parsers.
37 class ActionArgParser {
39 virtual ~ActionArgParser() = default;
40 virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) { CHECK_ACTION_PARAMS(action, 0, 0) }
43 class WaitTestParser : public ActionArgParser {
49 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
52 class SendRecvParser : public ActionArgParser {
54 /* communication partner; if we send, this is the receiver and vice versa */
58 MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
60 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
63 class ComputeParser : public ActionArgParser {
65 /* communication partner; if we send, this is the receiver and vice versa */
68 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
71 class CollCommParser : public ActionArgParser {
79 MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
80 MPI_Datatype datatype2 = MPI_DEFAULT_TYPE;
82 virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) = 0;
85 class BcastArgParser : public CollCommParser {
87 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
90 class ReduceArgParser : public CollCommParser {
92 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
95 class AllReduceArgParser : public CollCommParser {
97 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
100 class AllToAllArgParser : public CollCommParser {
102 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
105 class GatherArgParser : public CollCommParser {
107 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
110 class GatherVArgParser : public CollCommParser {
113 std::shared_ptr<std::vector<int>> recvcounts;
114 std::vector<int> disps;
115 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
118 class ScatterArgParser : public CollCommParser {
120 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
123 class ScatterVArgParser : public CollCommParser {
127 std::shared_ptr<std::vector<int>> sendcounts;
128 std::vector<int> disps;
129 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
132 class ReduceScatterArgParser : public CollCommParser {
135 std::shared_ptr<std::vector<int>> recvcounts;
136 std::vector<int> disps;
137 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;
140 class AllToAllVArgParser : public CollCommParser {
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;
150 void parse(simgrid::xbt::ReplayAction& action, std::string name) override;