X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ecd5f7562caf1d443bf22788fa5f4fac408776ec..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/src/surf/ptask_L07.hpp diff --git a/src/surf/ptask_L07.hpp b/src/surf/ptask_L07.hpp index 3b944a36bd..85cbc0d50e 100644 --- a/src/surf/ptask_L07.hpp +++ b/src/surf/ptask_L07.hpp @@ -1,19 +1,18 @@ -/* Copyright (c) 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2013-2023. 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. */ +#include "src/kernel/resource/NetworkModel.hpp" +#include "src/surf/HostImpl.hpp" #include #include #include -#include "src/surf/HostImpl.hpp" #ifndef HOST_L07_HPP_ #define HOST_L07_HPP_ -namespace simgrid { -namespace surf { +namespace simgrid::kernel::resource { /*********** * Classes * @@ -27,96 +26,142 @@ class XBT_PRIVATE CpuL07; class XBT_PRIVATE LinkL07; class XBT_PRIVATE L07Action; -/********* - * Tools * - *********/ /********* * Model * *********/ class HostL07Model : public HostModel { public: - HostL07Model(); - ~HostL07Model(); - - double nextOccuringEvent(double now) override; - void updateActionsState(double now, double delta) override; - Action *executeParallelTask(int host_nb, sg_host_t *host_list, - double *flops_amount, double *bytes_amount, double rate) override; + HostL07Model(const std::string& name, lmm::System* sys); + HostL07Model(const HostL07Model&) = delete; + HostL07Model& operator=(const HostL07Model&) = delete; + + double next_occurring_event(double now) override; + void update_actions_state(double now, double delta) override; + Action* execute_thread(const s4u::Host* host, double flops_amount, int thread_count) override { return nullptr; } + CpuAction* execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate) override; + Action* io_stream(s4u::Host* src_host, DiskImpl* src_disk, s4u::Host* dst_host, DiskImpl* dst_disk, double size) override { return nullptr; } }; class CpuL07Model : public CpuModel { public: - CpuL07Model(HostL07Model *hmodel,lmm_system_t sys); - ~CpuL07Model(); - - Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; - HostL07Model *hostModel_; + CpuL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys); + CpuL07Model(const CpuL07Model&) = delete; + CpuL07Model& operator=(const CpuL07Model&) = delete; + ~CpuL07Model() override; + void update_actions_state(double /*now*/, double /*delta*/) override{ + /* this action is done by HostL07Model which shares the LMM system with the CPU model + * Overriding to an empty function here allows us to handle the Cpu07Model as a regular + * method in EngineImpl::presolve */ + }; + + CpuImpl* create_cpu(s4u::Host* host, const std::vector& speed_per_pstate) override; + HostL07Model* hostModel_; }; class NetworkL07Model : public NetworkModel { public: - NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys); - ~NetworkL07Model(); - LinkImpl* createLink(const std::string& name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy) override; - - Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override; - - HostL07Model *hostModel_; + NetworkL07Model(const std::string& name, HostL07Model* hmodel, lmm::System* sys); + NetworkL07Model(const NetworkL07Model&) = delete; + NetworkL07Model& operator=(const NetworkL07Model&) = delete; + ~NetworkL07Model() override; + StandardLinkImpl* create_link(const std::string& name, const std::vector& bandwidths) final; + StandardLinkImpl* create_wifi_link(const std::string& name, const std::vector& bandwidths) override; + + Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed) override; + void update_actions_state(double /*now*/, double /*delta*/) override{ + /* this action is done by HostL07Model which shares the LMM system with the CPU model + * Overriding to an empty function here allows us to handle the Cpu07Model as a regular + * method in EngineImpl::presolve */ + }; + + HostL07Model* hostModel_; }; /************ * Resource * ************/ -class CpuL07 : public Cpu { +class CpuL07 : public CpuImpl { public: - CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector * speedPerPstate, int core); - ~CpuL07() override; - bool isUsed() override; - void apply_event(tmgr_trace_event_t event, double value) override; - Action *execution_start(double size) override; - Action *sleep(double duration) override; + using CpuImpl::CpuImpl; + CpuL07(const CpuL07&) = delete; + CpuL07& operator=(const CpuL07&) = delete; + + void apply_event(profile::Event* event, double value) override; + CpuAction* execution_start(double size, double user_bound) override; + CpuAction* execution_start(double, int, double) override + { + THROW_UNIMPLEMENTED; + return nullptr; + } + CpuAction* sleep(double duration) override; + protected: - void onSpeedChange() override; + void on_speed_change() override; }; -class LinkL07 : public LinkImpl { +class LinkL07 : public StandardLinkImpl { public: - LinkL07(NetworkL07Model* model, const std::string& name, double bandwidth, double latency, - e_surf_link_sharing_policy_t policy); + LinkL07(const std::string& name, double bandwidth, lmm::System* system); + LinkL07(const LinkL07&) = delete; + LinkL07& operator=(const LinkL07&) = delete; ~LinkL07() override; - bool isUsed() override; - void apply_event(tmgr_trace_event_t event, double value) override; - void setBandwidth(double value) override; - void setLatency(double value) override; + void apply_event(profile::Event* event, double value) override; + void set_bandwidth(double value) override; + void set_latency(double value) override; }; /********** * Action * **********/ class L07Action : public CpuAction { - friend Action *CpuL07::execution_start(double size); - friend Action *CpuL07::sleep(double duration); - friend Action *HostL07Model::executeParallelTask(int host_nb, sg_host_t*host_list, - double *flops_amount, double *bytes_amount, double rate); -public: - L07Action(Model *model, int host_nb, sg_host_t *host_list, double *flops_amount, double *bytes_amount, double rate); - ~L07Action(); - - void updateBound(); - - int unref() override; - - std::vector* hostList_ = new std::vector(); - double *computationAmount_; - double *communicationAmount_; + const std::vector host_list_; + bool free_arrays_ = false; // By default, computation_amount_ and friends are freed by caller. But not for sequential + // exec and regular comms + const double* computation_amount_; /* pointer to the data that lives in s4u action -- do not free unless if + * free_arrays */ + const double* communication_amount_; /* pointer to the data that lives in s4u action -- do not free unless if + * free_arrays */ double latency_; double rate_; + + friend CpuAction* CpuL07::execution_start(double size, double user_bound); + friend CpuAction* CpuL07::sleep(double duration); + friend CpuAction* HostL07Model::execute_parallel(const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate); + friend Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed); + /** + * @brief Calculate the CPU bound for the parallel task + * + * The task is bounded by the slowest CPU running the ptask, considering the current pstate of each CPU. + * Return MAX_DOUBLE if ptask has no computation. + */ + double calculate_cpu_bound() const; + + /** + * @brief Calculate the network bound for the parallel task + * + * The network bound depends on the largest latency between the communication in the ptask. + * Return MAX_DOUBLE if latency is 0 (or ptask doesn't have any communication) + */ + double calculate_network_bound() const; + +public: + L07Action() = delete; + L07Action(Model* model, const std::vector& host_list, const double* flops_amount, + const double* bytes_amount, double rate); + L07Action(const L07Action&) = delete; + L07Action& operator=(const L07Action&) = delete; + ~L07Action() override; + + void update_bound() const; + double get_latency() const { return latency_; } + void set_latency(double latency) { latency_ = latency; } + void update_latency(double delta, double precision) { double_update(&latency_, delta, precision); } }; -} -} +} // namespace simgrid::kernel::resource #endif /* HOST_L07_HPP_ */