X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/9df3f18b909012a944b85248cc2fff8988a8f83a..e0bb806b29f88b8798d66d023263fdf49bad7464:/include/simgrid/smpi/replay.hpp diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index 0b4d32f8d8..b52cb32bbd 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -2,8 +2,14 @@ /* 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 "smpi/smpi.h" +#include +#include #include +#include #include @@ -24,6 +30,11 @@ } \ } +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(); + namespace simgrid { namespace smpi { namespace replay { @@ -78,8 +89,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 { @@ -150,7 +159,158 @@ public: void parse(simgrid::xbt::ReplayAction& action, std::string name) override; }; +/** + * 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. + * In other words: The logic goes here, the setup is done by the ActionArgParser. + */ +template class ReplayAction { +protected: + const std::string name; + const int my_proc_id; + T args; + +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); + 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); } +}; + +class WaitAction : public ReplayAction { +private: + RequestStorage& req_storage; + +public: + explicit WaitAction(RequestStorage& storage) : ReplayAction("Wait"), req_storage(storage) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class SendAction : public ReplayAction { +private: + RequestStorage& req_storage; + +public: + explicit SendAction(std::string name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class RecvAction : public ReplayAction { +private: + RequestStorage& req_storage; +public: + explicit RecvAction(std::string name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class ComputeAction : public ReplayAction { +public: + explicit ComputeAction() : ReplayAction("compute") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class TestAction : public ReplayAction { +private: + RequestStorage& req_storage; + +public: + explicit TestAction(RequestStorage& storage) : ReplayAction("Test"), req_storage(storage) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class InitAction : public ReplayAction { +public: + explicit InitAction() : ReplayAction("Init") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class CommunicatorAction : public ReplayAction { +public: + explicit CommunicatorAction() : ReplayAction("Comm") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class WaitAllAction : public ReplayAction { +private: + RequestStorage& req_storage; + +public: + explicit WaitAllAction(RequestStorage& storage) : ReplayAction("waitAll"), req_storage(storage) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class BarrierAction : public ReplayAction { +public: + explicit BarrierAction() : ReplayAction("barrier") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class BcastAction : public ReplayAction { +public: + explicit BcastAction() : ReplayAction("bcast") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class ReduceAction : public ReplayAction { +public: + explicit ReduceAction() : ReplayAction("reduce") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class AllReduceAction : public ReplayAction { +public: + explicit AllReduceAction() : ReplayAction("allReduce") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class AllToAllAction : public ReplayAction { +public: + explicit AllToAllAction() : ReplayAction("allToAll") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class GatherAction : public ReplayAction { +public: + explicit GatherAction(std::string name) : ReplayAction(name) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class GatherVAction : public ReplayAction { +public: + explicit GatherVAction(std::string name) : ReplayAction(name) {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class ScatterAction : public ReplayAction { +public: + explicit ScatterAction() : ReplayAction("scatter") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class ScatterVAction : public ReplayAction { +public: + explicit ScatterVAction() : ReplayAction("scatterV") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class ReduceScatterAction : public ReplayAction { +public: + explicit ReduceScatterAction() : ReplayAction("reduceScatter") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; + +class AllToAllVAction : public ReplayAction { +public: + explicit AllToAllVAction() : ReplayAction("allToAllV") {} + void kernel(simgrid::xbt::ReplayAction& action) override; +}; } } } + +#endif