}
set_maxmin_system(new lmm::System(select));
- loopback_ = create_link("__loopback__", std::vector<double>{config::get_value<double>("network/loopback-bw")})
- ->set_sharing_policy(s4u::Link::SharingPolicy::FATPIPE)
- ->set_latency(config::get_value<double>("network/loopback-lat"));
+ loopback_ = create_link("__loopback__", std::vector<double>{config::get_value<double>("network/loopback-bw")});
+ loopback_->set_sharing_policy(s4u::Link::SharingPolicy::FATPIPE);
+ loopback_->set_latency(config::get_value<double>("network/loopback-lat"));
loopback_->seal();
}
LinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
{
xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
- return (new NetworkCm02Link(name, bandwidths[0], get_maxmin_system()))->set_model(this);
+ auto link = new NetworkCm02Link(name, bandwidths[0], get_maxmin_system());
+ link->set_model(this);
+ return link;
}
LinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
{
- return (new NetworkWifiLink(name, bandwidths, get_maxmin_system()))->set_model(this);
+ auto link = new NetworkWifiLink(name, bandwidths, get_maxmin_system());
+ link->set_model(this);
+ return link;
}
void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
*/
action.update_remains(action.get_remains());
}
- action.update_remains(action.get_variable()->get_value() * delta);
+ action.update_remains(action.get_rate() * delta);
if (action.get_max_duration() != NO_MAX_DURATION)
action.update_max_duration(delta);
void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size,
NetworkCm02Action* action, const std::vector<LinkImpl*>& route,
- const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones)
+ const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones,
+ double rate)
{
std::vector<s4u::Link*> s4u_route;
std::unordered_set<s4u::NetZone*> s4u_netzones;
} else {
bw_factor = get_bandwidth_factor(size);
}
+ xbt_assert(bw_factor != 0, "Invalid param for comm %s -> %s. Bandwidth factor cannot be 0", src->get_cname(),
+ dst->get_cname());
+ action->set_rate_factor(bw_factor);
+
/* get mininum bandwidth among links in the route and multiply by correct factor
* ignore wi-fi links, they're not considered for bw_factors */
double bandwidth_bound = -1.0;
if (bandwidth_bound == -1.0 || l->get_bandwidth() < bandwidth_bound)
bandwidth_bound = l->get_bandwidth();
}
- bandwidth_bound *= bw_factor;
- action->set_user_bound(get_bandwidth_constraint(action->get_user_bound(), bandwidth_bound, size));
+ /* increase rate given by user considering the factor, since the actual rate will be
+ * modified by it */
+ rate = rate / bw_factor;
+ /* the bandwidth is determined by the minimum between flow and user's defined rate */
+ if (rate >= 0 && rate < bandwidth_bound)
+ bandwidth_bound = rate;
+ action->set_user_bound(bandwidth_bound);
action->lat_current_ = action->latency_;
if (lat_factor_cb_) {
NetworkCm02Action* action = comm_action_create(src, dst, size, route, failed);
action->sharing_penalty_ = latency;
action->latency_ = latency;
- action->set_user_bound(rate);
if (sg_weight_S_parameter > 0) {
action->sharing_penalty_ =
}
/* setting bandwidth and latency bounds considering route and configured bw/lat factors */
- comm_action_set_bounds(src, dst, size, action, route, netzones);
+ comm_action_set_bounds(src, dst, size, action, route, netzones, rate);
/* creating the maxmin variable associated to this action */
comm_action_set_variable(action, route, back_route);
{
bandwidth_.scale = 1.0;
bandwidth_.peak = bandwidth;
- this->set_constraint(system->constraint_new(this, sg_bandwidth_factor * bandwidth));
+ this->set_constraint(system->constraint_new(this, bandwidth));
}
void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
{
bandwidth_.peak = value;
- get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
- sg_bandwidth_factor * (bandwidth_.peak * bandwidth_.scale));
+ get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), (bandwidth_.peak * bandwidth_.scale));
LinkImpl::on_bandwidth_change();
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
- int numelem = 0;
+ size_t numelem = 0;
while (const auto* var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem)) {
auto* action = static_cast<NetworkCm02Action*>(var->get_id());
action->sharing_penalty_ += delta;
}
}
-LinkImpl* NetworkCm02Link::set_latency(double value)
+void NetworkCm02Link::set_latency(double value)
{
latency_check(value);
double delta = value - latency_.peak;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
- int numelem = 0;
+ size_t numelem = 0;
latency_.scale = 1.0;
latency_.peak = value;
if (not action->is_suspended())
get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_);
}
- return this;
}
/**********
}
set_last_update();
- set_last_value(get_variable()->get_value());
+ set_last_value(get_rate());
}
} // namespace resource