/** @brief Seal this netzone configuration */
NetZone* seal();
- void set_latency_factor_cb(std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& /*links*/,
- const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb);
- void set_bandwidth_factor_cb(std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& /*links*/,
- const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb);
+ void
+ set_latency_factor_cb(std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
+ const std::vector<s4u::Link*>& /*links*/,
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const;
+ void
+ set_bandwidth_factor_cb(std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
+ const std::vector<s4u::Link*>& /*links*/,
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const;
};
// External constructors so that the types (and the types of their content) remain hidden
{
}
-double FactorSet::operator()()
+double FactorSet::operator()() const
{
return default_value_;
}
-double FactorSet::operator()(double size)
+double FactorSet::operator()(double size) const
{
if (factors_.empty())
return default_value_;
void parse(const std::string& string_values);
bool is_initialized() const { return initialized_; }
// Get the default value
- double operator()();
+ double operator()() const;
// Get the factor to use for the provided size
- double operator()(double size);
+ double operator()(double size) const;
};
} // namespace simgrid::kernel::resource
"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 NetworkModelFactors::get_bandwidth_factor()
+double NetworkModelFactors::get_bandwidth_factor() const
{
xbt_assert(not bw_factor_cb_,
"Cannot access the global bandwidth factor since a callback is used. Please go for the advanced API.");
return cfg_bandwidth_factor(0);
}
-double NetworkModelFactors::get_latency_factor()
+double NetworkModelFactors::get_latency_factor() const
{
xbt_assert(not lat_factor_cb_,
"Cannot access the global latency factor since a callback is used. Please go for the advanced API.");
double NetworkModelFactors::get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& links,
- const std::unordered_set<s4u::NetZone*>& netzones)
+ const std::unordered_set<s4u::NetZone*>& netzones) const
{
if (lat_factor_cb_)
return lat_factor_cb_(size, src, dst, links, netzones);
double NetworkModelFactors::get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& links,
- const std::unordered_set<s4u::NetZone*>& netzones)
+ const std::unordered_set<s4u::NetZone*>& netzones) const
{
if (bw_factor_cb_)
return bw_factor_cb_(size, src, dst, links, netzones);
* this factor.
*/
double get_latency_factor(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& links, const std::unordered_set<s4u::NetZone*>& netzones);
+ const std::vector<s4u::Link*>& links,
+ const std::unordered_set<s4u::NetZone*>& netzones) const;
/** Get the right multiplicative factor for the bandwidth (only if no callback was defined) */
- double get_latency_factor();
+ double get_latency_factor() const;
/**
* @brief Get the right multiplicative factor for the bandwidth.
* gets this factor.
*/
double get_bandwidth_factor(double size, const s4u::Host* src, const s4u::Host* dst,
- const std::vector<s4u::Link*>& links, const std::unordered_set<s4u::NetZone*>& netzones);
+ const std::vector<s4u::Link*>& links,
+ const std::unordered_set<s4u::NetZone*>& netzones) const;
/** Get the right multiplicative factor for the bandwidth (only if no callback was defined) */
- double get_bandwidth_factor();
+ double get_bandwidth_factor() const;
/**
* @brief Callback to set the bandwidth and latency factors used in a communication
void set_bw_factor_cb(const std::function<NetworkFactorCb>& cb);
/** Returns whether a callback was set for latency-factor OR bandwidth-factor */
- bool has_network_factor_cb() { return lat_factor_cb_ || bw_factor_cb_; }
+ bool has_network_factor_cb() const { return lat_factor_cb_ || bw_factor_cb_; }
};
} // namespace simgrid::kernel::resource
SECTION("Model: " + model)
{
- auto zone = e.get_netzone_root();
+ const auto* zone = e.get_netzone_root();
REQUIRE_THROWS_AS(zone->set_latency_factor_cb({}), std::invalid_argument);
REQUIRE_THROWS_AS(zone->set_latency_factor_cb(nullptr), std::invalid_argument);
REQUIRE_THROWS_AS(zone->set_bandwidth_factor_cb({}), std::invalid_argument);
SECTION("Model: " + model)
{
- auto zone = e.get_netzone_root();
+ const auto* zone = e.get_netzone_root();
REQUIRE_THROWS_AS(zone->set_latency_factor_cb(factor_cb), std::invalid_argument);
REQUIRE_THROWS_AS(zone->set_bandwidth_factor_cb(factor_cb), std::invalid_argument);
}
void NetZone::set_latency_factor_cb(
std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& /*links*/,
- const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb)
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const
{
kernel::actor::simcall_answered([this, &cb]() { pimpl_->get_network_model()->set_lat_factor_cb(cb); });
}
void NetZone::set_bandwidth_factor_cb(
std::function<double(double size, const s4u::Host* src, const s4u::Host* dst,
const std::vector<s4u::Link*>& /*links*/,
- const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb)
+ const std::unordered_set<s4u::NetZone*>& /*netzones*/)> const& cb) const
{
kernel::actor::simcall_answered([this, &cb]() { pimpl_->get_network_model()->set_bw_factor_cb(cb); });
}
void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size,
NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones,
- double rate)
+ double rate) const
{
std::vector<s4u::Link*> s4u_route;
std::unordered_set<s4u::NetZone*> s4u_netzones;
/** @brief Set communication bounds for latency and bandwidth */
void comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size, NetworkCm02Action* action,
const std::vector<StandardLinkImpl*>& route,
- const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones, double rate);
+ const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones, double rate) const;
/** @brief Create maxmin variable in communication action */
void comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
const std::vector<StandardLinkImpl*>& back_route);