-/* Copyright (c) 2013-2022. 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. */
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;
/* transform data to user structures if necessary */
- if (lat_factor_cb_ || bw_factor_cb_) {
+ if (has_network_factor_cb()) {
std::for_each(route.begin(), route.end(),
[&s4u_route](StandardLinkImpl* l) { s4u_route.push_back(l->get_iface()); });
std::for_each(netzones.begin(), netzones.end(),
[&s4u_netzones](kernel::routing::NetZoneImpl* n) { s4u_netzones.insert(n->get_iface()); });
}
- double bw_factor;
- if (bw_factor_cb_) {
- bw_factor = bw_factor_cb_(size, src, dst, s4u_route, s4u_netzones);
- } else {
- bw_factor = get_bandwidth_factor(size);
- }
+
+ double bw_factor = get_bandwidth_factor(size, src, dst, s4u_route, s4u_netzones);
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);
action->set_user_bound(bandwidth_bound);
action->lat_current_ = action->latency_;
- if (lat_factor_cb_) {
- action->latency_ *= lat_factor_cb_(size, src, dst, s4u_route, s4u_netzones);
- } else {
- action->latency_ *= get_latency_factor(size);
- }
+ action->latency_ *= get_latency_factor(size, src, dst, s4u_route, s4u_netzones);
}
void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
- const std::vector<StandardLinkImpl*>& back_route)
+ const std::vector<StandardLinkImpl*>& back_route, bool streamed)
{
size_t constraints_per_variable = route.size();
constraints_per_variable += back_route.size();
+ if (streamed) {
+ // setting the number of variable for a communication action involved in a I/O streaming operation
+ // requires to reserve some extra space for the constraints related to the source disk (global and read
+ // bandwidth) and destination disk (global and write bandwidth). We thus add 4 constraints.
+ constraints_per_variable += 4;
+ }
if (action->latency_ > 0) {
action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
}
}
-Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
+Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed)
{
double latency = 0.0;
std::vector<StandardLinkImpl*> back_route;
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);
+ comm_action_set_variable(action, route, back_route, streamed);
/* expand maxmin system to consider this communication in bw constraint for each link in route and back_route */
comm_action_expand_constraints(src, dst, action, route, back_route);