X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c1b3e440de2150420b08c0bc55a125a0c9eb86bc..84402e8e2ee2a2d0bef25fdceb0a263ed8b471f6:/include/simgrid/smpi/replay.hpp diff --git a/include/simgrid/smpi/replay.hpp b/include/simgrid/smpi/replay.hpp index 045b936ba8..9001d5f3cf 100644 --- a/include/simgrid/smpi/replay.hpp +++ b/include/simgrid/smpi/replay.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2009-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2009-2020. The SimGrid Team. All rights reserved. */ /* 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. */ @@ -16,14 +16,14 @@ #define CHECK_ACTION_PARAMS(action, mandatory, optional) \ { \ - if (action.size() < static_cast(mandatory + 2)) { \ + if ((action).size() < static_cast((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 \ + << (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) { \ + for (const auto& elem : (action)) { \ ss << elem << " "; \ } \ ss << "\nPlease contact the Simgrid team if support is needed"; \ @@ -31,12 +31,10 @@ } \ } -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 unsigned char* smpi_get_tmp_sendbuffer(size_t size); +XBT_PRIVATE unsigned char* smpi_get_tmp_recvbuffer(size_t size); -XBT_PRIVATE void log_timed_action(simgrid::xbt::ReplayAction& action, double clock); +XBT_PRIVATE void log_timed_action(const simgrid::xbt::ReplayAction& action, double clock); namespace simgrid { namespace smpi { @@ -51,7 +49,7 @@ class RequestStorage; // Forward decl class ActionArgParser { public: virtual ~ActionArgParser() = default; - virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) { CHECK_ACTION_PARAMS(action, 0, 0) } + virtual void parse(xbt::ReplayAction& action, const std::string& name) { CHECK_ACTION_PARAMS(action, 0, 0) } }; class WaitTestParser : public ActionArgParser { @@ -60,7 +58,7 @@ public: int dst; int tag; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class SendRecvParser : public ActionArgParser { @@ -71,15 +69,29 @@ public: int tag; MPI_Datatype datatype1 = MPI_DEFAULT_TYPE; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class ComputeParser : public ActionArgParser { public: - /* communication partner; if we send, this is the receiver and vice versa */ double flops; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; +}; + +class SleepParser : public ActionArgParser { +public: + double time; + + void parse(xbt::ReplayAction& action, const std::string& name) override; +}; + +class LocationParser : public ActionArgParser { +public: + std::string filename; + int line; + + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class CollCommParser : public ActionArgParser { @@ -96,27 +108,27 @@ public: class BcastArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class ReduceArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class AllReduceArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class AllToAllArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class GatherArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class GatherVArgParser : public CollCommParser { @@ -124,12 +136,12 @@ public: int recv_size_sum; std::shared_ptr> recvcounts; std::vector disps; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class ScatterArgParser : public CollCommParser { public: - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class ScatterVArgParser : public CollCommParser { @@ -138,7 +150,7 @@ public: int send_size_sum; std::shared_ptr> sendcounts; std::vector disps; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class ReduceScatterArgParser : public CollCommParser { @@ -146,7 +158,7 @@ public: int recv_size_sum; std::shared_ptr> recvcounts; std::vector disps; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; class AllToAllVArgParser : public CollCommParser { @@ -159,7 +171,7 @@ public: std::vector recvdisps; int send_buf_size; int recv_buf_size; - void parse(simgrid::xbt::ReplayAction& action, std::string name) override; + void parse(xbt::ReplayAction& action, const std::string& name) override; }; /** @@ -171,14 +183,14 @@ public: template class ReplayAction { protected: const std::string name; - const aid_t my_proc_id; + const aid_t my_proc_id = s4u::this_actor::get_pid(); T args; public: - explicit ReplayAction(std::string name) : name(std::move(name)), my_proc_id(simgrid::s4u::this_actor::get_pid()) {} + explicit ReplayAction(const std::string& name) : name(name) {} virtual ~ReplayAction() = default; - void execute(simgrid::xbt::ReplayAction& action) + void execute(xbt::ReplayAction& action) { // Needs to be re-initialized for every action, hence here double start_time = smpi_process()->simulated_elapsed(); @@ -189,45 +201,50 @@ public: } 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); } + unsigned char* send_buffer(int size) { return smpi_get_tmp_sendbuffer(size); } + unsigned char* 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; + void kernel(xbt::ReplayAction& action) override; }; class SendAction : public ReplayAction { -private: RequestStorage& req_storage; public: - explicit SendAction(std::string name, RequestStorage& storage) : ReplayAction(std::move(name)), req_storage(storage) - { - } - void kernel(simgrid::xbt::ReplayAction& action) override; + explicit SendAction(const std::string& name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + void kernel(xbt::ReplayAction& action) override; }; class RecvAction : public ReplayAction { -private: RequestStorage& req_storage; public: - explicit RecvAction(std::string name, RequestStorage& storage) : ReplayAction(std::move(name)), req_storage(storage) - { - } - void kernel(simgrid::xbt::ReplayAction& action) override; + explicit RecvAction(const std::string& name, RequestStorage& storage) : ReplayAction(name), req_storage(storage) {} + void kernel(xbt::ReplayAction& action) override; }; class ComputeAction : public ReplayAction { public: explicit ComputeAction() : ReplayAction("compute") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; +}; + +class SleepAction : public ReplayAction { +public: + explicit SleepAction() : ReplayAction("sleep") {} + void kernel(xbt::ReplayAction& action) override; +}; + +class LocationAction : public ReplayAction { +public: + explicit LocationAction() : ReplayAction("location") {} + void kernel(xbt::ReplayAction& action) override; }; class TestAction : public ReplayAction { @@ -236,97 +253,97 @@ private: public: explicit TestAction(RequestStorage& storage) : ReplayAction("Test"), req_storage(storage) {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class InitAction : public ReplayAction { public: explicit InitAction() : ReplayAction("Init") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class CommunicatorAction : public ReplayAction { public: explicit CommunicatorAction() : ReplayAction("Comm") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(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; + void kernel(xbt::ReplayAction& action) override; }; class BarrierAction : public ReplayAction { public: explicit BarrierAction() : ReplayAction("barrier") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class BcastAction : public ReplayAction { public: explicit BcastAction() : ReplayAction("bcast") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class ReduceAction : public ReplayAction { public: explicit ReduceAction() : ReplayAction("reduce") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class AllReduceAction : public ReplayAction { public: explicit AllReduceAction() : ReplayAction("allreduce") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class AllToAllAction : public ReplayAction { public: explicit AllToAllAction() : ReplayAction("alltoall") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class GatherAction : public ReplayAction { public: - explicit GatherAction(std::string name) : ReplayAction(std::move(name)) {} - void kernel(simgrid::xbt::ReplayAction& action) override; + explicit GatherAction(const std::string& name) : ReplayAction(name) {} + void kernel(xbt::ReplayAction& action) override; }; class GatherVAction : public ReplayAction { public: - explicit GatherVAction(std::string name) : ReplayAction(std::move(name)) {} - void kernel(simgrid::xbt::ReplayAction& action) override; + explicit GatherVAction(const std::string& name) : ReplayAction(name) {} + void kernel(xbt::ReplayAction& action) override; }; class ScatterAction : public ReplayAction { public: explicit ScatterAction() : ReplayAction("scatter") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class ScatterVAction : public ReplayAction { public: explicit ScatterVAction() : ReplayAction("scatterv") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class ReduceScatterAction : public ReplayAction { public: explicit ReduceScatterAction() : ReplayAction("reducescatter") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; class AllToAllVAction : public ReplayAction { public: explicit AllToAllVAction() : ReplayAction("alltoallv") {} - void kernel(simgrid::xbt::ReplayAction& action) override; + void kernel(xbt::ReplayAction& action) override; }; -} -} -} + +} // namespace replay +} // namespace smpi +} // namespace simgrid #endif