*********/
namespace simgrid::kernel::resource {
-static FactorSet cfg_latency_factor("network/latency-factor");
-static FactorSet cfg_bandwidth_factor("network/bandwidth-factor");
-
-config::Flag<std::string> cfg_latency_factor_str(
- "network/latency-factor", std::initializer_list<const char*>{"smpi/lat-factor"},
- "Correction factor to apply to the provided latency (default value overridden by network model)", "1.0");
-static config::Flag<std::string> cfg_bandwidth_factor_str(
- "network/bandwidth-factor", std::initializer_list<const char*>{"smpi/bw-factor"},
- "Correction factor to apply to the provided bandwidth (default value overridden by network model)", "1.0");
-
-double NetworkModel::get_latency_factor(double size)
-{
- if (not cfg_latency_factor.is_initialized()) // lazy initiaization to avoid initialization fiasco
- cfg_latency_factor.parse(cfg_latency_factor_str.get());
-
- return cfg_latency_factor(size);
-}
-double NetworkModel::get_bandwidth_factor(double size)
-{
- if (not cfg_bandwidth_factor.is_initialized())
- cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
-
- return cfg_bandwidth_factor(size);
-}
/** @brief Command-line option 'network/TCP-gamma' -- see @ref options_model_network_gamma */
config::Flag<double> NetworkModel::cfg_tcp_gamma(
*/
virtual Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) = 0;
- /**
- * @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.
- *
- * @param size The size of the message.
- * @return The latency factor.
- */
- virtual double get_latency_factor(double size = 0);
-
- /**
- * @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.
- *
- * @param size The size of the message.
- * @return The bandwidth factor.
- */
- virtual double get_bandwidth_factor(double size = 0);
-
double next_occurring_event_full(double now) override;
std::unique_ptr<StandardLinkImpl, StandardLinkImpl::Deleter> loopback_;
*********/
namespace simgrid::kernel::resource {
-#if 0
static FactorSet cfg_latency_factor("network/latency-factor");
static FactorSet cfg_bandwidth_factor("network/bandwidth-factor");
"network/bandwidth-factor", std::initializer_list<const char*>{"smpi/bw-factor"},
"Correction factor to apply to the provided bandwidth (default value overridden by network model)", "1.0");
+#if 0
double NetworkModelFactors::get_latency_factor()
{
xbt_assert(not lat_factor_cb_,
}
#endif
+double NetworkModelFactors::get_latency_factor(double size)
+{
+ if (not cfg_latency_factor.is_initialized()) // lazy initiaization to avoid initialization fiasco
+ cfg_latency_factor.parse(cfg_latency_factor_str.get());
+
+ return cfg_latency_factor(size);
+}
+double NetworkModelFactors::get_bandwidth_factor(double size)
+{
+ if (not cfg_bandwidth_factor.is_initialized())
+ cfg_bandwidth_factor.parse(cfg_bandwidth_factor_str.get());
+
+ return cfg_bandwidth_factor(size);
+}
+
void NetworkModelFactors::set_lat_factor_cb(const std::function<NetworkFactorCb>& cb)
{
if (not cb)
namespace simgrid::kernel::resource {
-/** @ingroup SURF_interface
- * @brief Network Model interface class
- */
+/** 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<s4u::Link*>& links,
std::function<NetworkFactorCb> 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.
+ *
+ * @param size The size of the message.
+ * @return The latency factor.
+ */
+ double get_latency_factor(double size = 0);
+
+ /**
+ * @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.
+ *
+ * @param size The size of the message.
+ * @return The bandwidth factor.
+ */
+ double get_bandwidth_factor(double size = 0);
+
/**
* @brief Callback to set the bandwidth and latency factors used in a communication
*
} // namespace simgrid::kernel::resource
-#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELINTF_HPP */
+#endif /* SIMGRID_KERNEL_RESOURCE_NETWORKMODELFACTORS_HPP */