X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/2effc173a50996c2b8c3885e2fa8b09c9c6cc144..5ed37babb2fa9097abe82df299c0aa259ed84d5a:/src/kernel/resource/NetworkModelFactors.hpp diff --git a/src/kernel/resource/NetworkModelFactors.hpp b/src/kernel/resource/NetworkModelFactors.hpp index 407b31bc8c..e9e4ee6a79 100644 --- a/src/kernel/resource/NetworkModelFactors.hpp +++ b/src/kernel/resource/NetworkModelFactors.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-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. */ @@ -6,23 +6,53 @@ #ifndef SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP #define SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP +#include "simgrid/sg_config.hpp" +#include "xbt/asserts.h" #include #include #include -namespace simgrid { -namespace kernel { -namespace resource { +namespace simgrid::kernel::resource { -/** @ingroup SURF_interface - * @brief Network Model interface class - */ -class XBT_PUBLIC NetworkModelIntf { -protected: - ~NetworkModelIntf() = default; +/** This Trait of NetworkModel is in charge of handling the network factors (bw and lat) */ + +class XBT_PUBLIC NetworkModelFactors { + using NetworkFactorCb = double(double size, const s4u::Host* src, const s4u::Host* dst, + const std::vector& links, + const std::unordered_set& netzones); + + std::function lat_factor_cb_; + std::function bw_factor_cb_; public: + /** + * @brief Get the right multiplicative factor for the latency. + * @details Depending on the model, the effective latency when sending a message might be different from the + * theoretical latency of the link, in function of the message size. In order to account for this, this function gets + * this factor. + */ + double get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst, + const std::vector& links, + const std::unordered_set& netzones) const; + + /** Get the right multiplicative factor for the bandwidth (only if no callback was defined) */ + double get_latency_factor() const; + + /** + * @brief Get the right multiplicative factor for the bandwidth. + * + * @details Depending on the model, the effective bandwidth when sending a message might be different from the + * theoretical bandwidth of the link, in function of the message size. In order to account for this, this function + * gets this factor. + */ + double get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst, + const std::vector& links, + const std::unordered_set& netzones) const; + + /** Get the right multiplicative factor for the bandwidth (only if no callback was defined) */ + double get_bandwidth_factor() const; + /** * @brief Callback to set the bandwidth and latency factors used in a communication * @@ -37,17 +67,16 @@ public: * @param netzones Set with NetZones involved in the comm * @return Multiply factor */ - using NetworkFactorCb = double(double size, const s4u::Host* src, const s4u::Host* dst, - const std::vector& links, - const std::unordered_set& netzones); /** @brief Configure the latency factor callback */ - virtual void set_lat_factor_cb(const std::function& cb) = 0; + void set_lat_factor_cb(const std::function& cb); + /** @brief Configure the bandwidth factor callback */ - virtual void set_bw_factor_cb(const std::function& cb) = 0; + void set_bw_factor_cb(const std::function& cb); + + /** Returns whether a callback was set for latency-factor OR bandwidth-factor */ + bool has_network_factor_cb() const { return lat_factor_cb_ || bw_factor_cb_; } }; -} // namespace resource -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::resource -#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */ +#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP */