1 /* Copyright (c) 2013-2023. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "src/kernel/resource/models/network_cm02.hpp"
7 #include "simgrid/kernel/routing/NetZoneImpl.hpp"
8 #include "simgrid/s4u/Engine.hpp"
9 #include "simgrid/s4u/Host.hpp"
10 #include "src/kernel/EngineImpl.hpp"
11 #include "src/kernel/resource/StandardLinkImpl.hpp"
12 #include "src/kernel/resource/WifiLinkImpl.hpp"
13 #include "src/kernel/resource/profile/Event.hpp"
14 #include "src/simgrid/math_utils.h"
15 #include "src/simgrid/module.hpp"
16 #include "src/simgrid/sg_config.hpp"
21 XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
26 static simgrid::config::Flag<std::string> cfg_network_solver("network/solver",
27 "Set linear equations solver used by network model",
28 "maxmin", &simgrid::kernel::lmm::System::validate_solver);
30 /******************************************************************************/
31 /* Network model based on optimizations discussed during Pedro Velho's thesis */
32 /******************************************************************************/
33 /* @techreport{VELHO:2011:HAL-00646896:1, */
34 /* url = {http://hal.inria.fr/hal-00646896/en/}, */
35 /* title = {{Flow-level network models: have we reached the limits?}}, */
36 /* author = {Velho, Pedro and Schnorr, Lucas and Casanova, Henri and Legrand, Arnaud}, */
37 /* type = {Rapport de recherche}, */
38 /* institution = {INRIA}, */
39 /* number = {RR-7821}, */
42 /* pdf = {http://hal.inria.fr/hal-00646896/PDF/rr-validity.pdf}, */
44 SIMGRID_REGISTER_NETWORK_MODEL(
46 "Realistic network analytic model (slow-start modeled by multiplying latency by 13.01, bandwidth by .97; "
47 "bottleneck sharing uses a payload of S=20537 for evaluating RTT). ",
49 auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_LegrandVelho");
50 auto* engine = simgrid::kernel::EngineImpl::get_instance();
51 engine->add_model(net_model);
52 engine->get_netzone_root()->set_network_model(net_model);
54 simgrid::config::set_default<std::string>("network/latency-factor", "13.01");
55 simgrid::config::set_default<std::string>("network/bandwidth-factor", "0.97");
56 simgrid::config::set_default<double>("network/weight-S", 20537);
59 /****************************************************************************/
60 /* The older TCP sharing model designed by Loris Marchal and Henri Casanova */
61 /****************************************************************************/
62 /* @TechReport{ rr-lip2002-40, */
63 /* author = {Henri Casanova and Loris Marchal}, */
64 /* institution = {LIP}, */
65 /* title = {A Network Model for Simulation of Grid Application}, */
66 /* number = {2002-40}, */
70 SIMGRID_REGISTER_NETWORK_MODEL(
72 "Legacy network analytic model (Very similar to LV08, but without corrective factors. The timings of "
73 "small messages are thus poorly modeled).",
75 simgrid::config::set_default<std::string>("network/latency-factor", "1.0");
76 simgrid::config::set_default<std::string>("network/bandwidth-factor", "1.0");
77 simgrid::config::set_default<double>("network/weight-S", 0.0);
79 auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_CM02");
80 auto* engine = simgrid::kernel::EngineImpl::get_instance();
81 engine->add_model(net_model);
82 engine->get_netzone_root()->set_network_model(net_model);
85 /********************************************************************/
86 /* Model based on LV08 and experimental results of MPI ping-pongs */
87 /********************************************************************/
88 /* @Inproceedings{smpi_ipdps, */
89 /* author={Pierre-Nicolas Clauss and Mark Stillwell and Stéphane Genaud and Frédéric Suter and Henri Casanova and
91 /* title={Single Node On-Line Simulation of {MPI} Applications with SMPI}, */
92 /* booktitle={25th IEEE International Parallel and Distributed Processing Symposium (IPDPS'11)}, */
93 /* address={Anchorage (Alaska) USA}, */
97 SIMGRID_REGISTER_NETWORK_MODEL(
99 "Realistic network model specifically tailored for HPC settings (accurate modeling of slow start with "
100 "correction factors on three intervals: < 1KiB, < 64 KiB, >= 64 KiB)",
102 auto net_model = std::make_shared<simgrid::kernel::resource::NetworkCm02Model>("Network_SMPI");
103 auto* engine = simgrid::kernel::EngineImpl::get_instance();
104 engine->add_model(net_model);
105 engine->get_netzone_root()->set_network_model(net_model);
107 simgrid::config::set_default<double>("network/weight-S", 8775);
108 simgrid::config::set_default<std::string>("network/bandwidth-factor",
109 "65472:0.940694;15424:0.697866;9376:0.58729;5776:1.08739;3484:0.77493;"
110 "1426:0.608902;732:0.341987;257:0.338112;0:0.812084");
111 simgrid::config::set_default<std::string>("network/latency-factor",
112 "65472:11.6436;15424:3.48845;9376:2.59299;5776:2.18796;3484:1.88101;"
113 "1426:1.61075;732:1.9503;257:1.95341;0:2.01467");
116 namespace simgrid::kernel::resource {
117 static simgrid::config::Flag<std::string>
118 network_optim_opt("network/optim", "Optimization algorithm to use for network resources. ", "Lazy",
120 std::map<std::string, std::string, std::less<>>({
121 {"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining)."},
122 {"Full", "Full update of remaining and variables. Slow but may be useful when debugging."},
125 [](std::string const&) {
126 xbt_assert(_sg_cfg_init_status < 2,
127 "Cannot change the optimization algorithm after the initialization");
130 NetworkCm02Model::NetworkCm02Model(const std::string& name) : NetworkModel(name)
132 bool select = config::get_value<bool>("network/maxmin-selective-update");
134 if (network_optim_opt == "Lazy") {
135 set_update_algorithm(Model::UpdateAlgo::LAZY);
136 xbt_assert(select || config::is_default("network/maxmin-selective-update"),
137 "You cannot disable network selective update when using the lazy update mechanism");
141 set_maxmin_system(lmm::System::build(cfg_network_solver.get(), select));
143 loopback_.reset(create_link("__loopback__", {config::get_value<double>("network/loopback-bw")}));
144 loopback_->set_sharing_policy(s4u::Link::SharingPolicy::FATPIPE, {});
145 loopback_->set_latency(config::get_value<double>("network/loopback-lat"));
146 loopback_->get_iface()->seal();
149 StandardLinkImpl* NetworkCm02Model::create_link(const std::string& name, const std::vector<double>& bandwidths)
151 xbt_assert(bandwidths.size() == 1, "Non-WIFI links must use only 1 bandwidth.");
152 auto* link = new NetworkCm02Link(name, bandwidths[0], get_maxmin_system());
153 link->set_model(this);
157 StandardLinkImpl* NetworkCm02Model::create_wifi_link(const std::string& name, const std::vector<double>& bandwidths)
159 auto* link = new WifiLinkImpl(name, bandwidths, get_maxmin_system());
160 link->set_model(this);
164 void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/)
166 while (not get_action_heap().empty() && double_equals(get_action_heap().top_date(), now, sg_precision_timing)) {
167 auto* action = static_cast<NetworkCm02Action*>(get_action_heap().pop());
168 XBT_DEBUG("Something happened to action %p", action);
170 // if I am wearing a latency hat
171 if (action->get_type() == ActionHeap::Type::latency) {
172 XBT_DEBUG("Latency paid for action %p. Activating", action);
173 get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_);
174 get_action_heap().remove(action);
175 action->set_last_update();
177 // if I am wearing a max_duration or normal hat
178 } else if (action->get_type() == ActionHeap::Type::max_duration || action->get_type() == ActionHeap::Type::normal) {
179 // no need to communicate anymore
180 // assume that flows that reached max_duration have remaining of 0
181 XBT_DEBUG("Action %p finished", action);
182 action->finish(Action::State::FINISHED);
183 get_action_heap().remove(action);
188 void NetworkCm02Model::update_actions_state_full(double /*now*/, double delta)
190 for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) {
191 auto& action = static_cast<NetworkCm02Action&>(*it);
192 ++it; // increment iterator here since the following calls to action.finish() may invalidate it
193 XBT_DEBUG("Something happened to action %p", &action);
194 if (action.latency_ > 0) {
195 if (action.latency_ > delta) {
196 double_update(&action.latency_, delta, sg_precision_timing);
198 action.latency_ = 0.0;
200 if (action.latency_ <= 0.0 && not action.is_suspended())
201 get_maxmin_system()->update_variable_penalty(action.get_variable(), action.sharing_penalty_);
204 if (not action.get_variable()->get_number_of_constraint()) {
205 /* There is actually no link used, hence an infinite bandwidth. This happens often when using models like
206 * vivaldi. In such case, just make sure that the action completes immediately.
208 action.update_remains(action.get_remains());
210 action.update_remains(action.get_rate() * delta);
212 if (action.get_max_duration() != NO_MAX_DURATION)
213 action.update_max_duration(delta);
215 if (((action.get_remains() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
216 ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
217 action.finish(Action::State::FINISHED);
222 void NetworkCm02Model::comm_action_expand_constraints(const s4u::Host* src, const s4u::Host* dst,
223 const NetworkCm02Action* action,
224 const std::vector<StandardLinkImpl*>& route,
225 const std::vector<StandardLinkImpl*>& back_route) const
227 /* expand route links constraints for route and back_route */
228 const WifiLinkImpl* src_wifi_link = nullptr;
229 const WifiLinkImpl* dst_wifi_link = nullptr;
230 if (not route.empty() && route.front()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
231 src_wifi_link = static_cast<WifiLinkImpl*>(route.front());
233 if (route.size() > 1 && route.back()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
234 dst_wifi_link = static_cast<WifiLinkImpl*>(route.back());
237 /* WI-FI links needs special treatment, do it here */
238 if (src_wifi_link != nullptr) {
239 if (src_wifi_link->get_host_rate(src) > 0)
240 get_maxmin_system()->expand(src_wifi_link->get_constraint(), action->get_variable(),
241 1.0 / src_wifi_link->get_host_rate(src));
243 get_maxmin_system()->update_variable_penalty(action->get_variable(), 0);
247 if (dst_wifi_link != nullptr) {
248 if (dst_wifi_link->get_host_rate(dst) > 0)
249 get_maxmin_system()->expand(dst_wifi_link->get_constraint(), action->get_variable(),
250 1.0 / dst_wifi_link->get_host_rate(dst));
252 get_maxmin_system()->update_variable_penalty(action->get_variable(), 0);
256 for (auto const* link : route) {
257 if (link->get_sharing_policy() != s4u::Link::SharingPolicy::WIFI)
258 get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), 1.0);
261 if (cfg_crosstraffic) {
262 XBT_DEBUG("Crosstraffic active: adding backward flow using 5%% of the available bandwidth");
263 if (dst_wifi_link != nullptr)
264 get_maxmin_system()->expand(dst_wifi_link->get_constraint(), action->get_variable(),
265 .05 / dst_wifi_link->get_host_rate(dst));
266 if (src_wifi_link != nullptr)
267 get_maxmin_system()->expand(src_wifi_link->get_constraint(), action->get_variable(),
268 .05 / src_wifi_link->get_host_rate(src));
270 for (auto const* link : back_route) {
271 if (link->get_sharing_policy() != s4u::Link::SharingPolicy::WIFI)
272 get_maxmin_system()->expand(link->get_constraint(), action->get_variable(), .05);
277 NetworkCm02Action* NetworkCm02Model::comm_action_create(s4u::Host* src, s4u::Host* dst, double size,
278 const std::vector<StandardLinkImpl*>& route, bool failed)
280 WifiLinkImpl* src_wifi_link = nullptr;
281 WifiLinkImpl* dst_wifi_link = nullptr;
282 /* many checks related to Wi-Fi links */
283 if (not route.empty() && route.front()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
284 src_wifi_link = static_cast<WifiLinkImpl*>(route.front());
285 xbt_assert(src_wifi_link->get_host_rate(src) != -1,
286 "The route from %s to %s begins with the WIFI link %s, but the host %s does not seem attached to that "
287 "WIFI link. Did you call link->set_host_rate()?",
288 src->get_cname(), dst->get_cname(), src_wifi_link->get_cname(), src->get_cname());
290 if (route.size() > 1 && route.back()->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
291 dst_wifi_link = static_cast<WifiLinkImpl*>(route.back());
292 xbt_assert(dst_wifi_link->get_host_rate(dst) != -1,
293 "The route from %s to %s ends with the WIFI link %s, but the host %s does not seem attached to that "
294 "WIFI link. Did you call link->set_host_rate()?",
295 src->get_cname(), dst->get_cname(), dst_wifi_link->get_cname(), dst->get_cname());
297 if (route.size() > 2)
298 for (unsigned i = 1; i < route.size() - 1; i++)
299 xbt_assert(route[i]->get_sharing_policy() != s4u::Link::SharingPolicy::WIFI,
300 "Link '%s' is a WIFI link. It can only be at the beginning or the end of the route from '%s' to '%s', "
301 "not in between (it is at position %u out of %zu). "
302 "Did you declare an access_point in your WIFI zones?",
303 route[i]->get_cname(), src->get_cname(), dst->get_cname(), i + 1, route.size());
305 for (auto const* link : route) {
306 if (link->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI) {
307 xbt_assert(link == src_wifi_link || link == dst_wifi_link,
308 "Wifi links can only occur at the beginning of the route (meaning that it's attached to the src) or "
309 "at its end (meaning that it's attached to the dst");
313 /* create action and do some initializations */
314 NetworkCm02Action* action;
315 if (src_wifi_link == nullptr && dst_wifi_link == nullptr)
316 action = new NetworkCm02Action(this, *src, *dst, size, failed);
318 action = new WifiLinkAction(this, *src, *dst, size, failed, src_wifi_link, dst_wifi_link);
320 if (is_update_lazy()) {
321 action->set_last_update();
327 bool NetworkCm02Model::comm_get_route_info(const s4u::Host* src, const s4u::Host* dst, double& latency,
328 std::vector<StandardLinkImpl*>& route,
329 std::vector<StandardLinkImpl*>& back_route,
330 std::unordered_set<kernel::routing::NetZoneImpl*>& netzones) const
332 kernel::routing::NetZoneImpl::get_global_route_with_netzones(src->get_netpoint(), dst->get_netpoint(), route,
335 xbt_assert(not route.empty() || latency > 0,
336 "You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
337 src->get_cname(), dst->get_cname());
339 bool failed = std::any_of(route.begin(), route.end(), [](const StandardLinkImpl* link) { return not link->is_on(); });
341 if (not failed && cfg_crosstraffic) {
342 dst->route_to(src, back_route, nullptr);
343 failed = std::any_of(back_route.begin(), back_route.end(),
344 [](const StandardLinkImpl* link) { return not link->is_on(); });
349 void NetworkCm02Model::comm_action_set_bounds(const s4u::Host* src, const s4u::Host* dst, double size,
350 NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
351 const std::unordered_set<kernel::routing::NetZoneImpl*>& netzones,
354 std::vector<s4u::Link*> s4u_route;
355 std::unordered_set<s4u::NetZone*> s4u_netzones;
357 /* transform data to user structures if necessary */
358 if (has_network_factor_cb()) {
359 std::for_each(route.begin(), route.end(),
360 [&s4u_route](StandardLinkImpl* l) { s4u_route.push_back(l->get_iface()); });
361 std::for_each(netzones.begin(), netzones.end(),
362 [&s4u_netzones](kernel::routing::NetZoneImpl* n) { s4u_netzones.insert(n->get_iface()); });
365 double bw_factor = get_bandwidth_factor(size, src, dst, s4u_route, s4u_netzones);
366 xbt_assert(bw_factor != 0, "Invalid param for comm %s -> %s. Bandwidth factor cannot be 0", src->get_cname(),
368 action->set_rate_factor(bw_factor);
370 /* get mininum bandwidth among links in the route and multiply by correct factor
371 * ignore wi-fi links, they're not considered for bw_factors */
372 double bandwidth_bound = -1.0;
373 for (const auto* l : route) {
374 if (l->get_sharing_policy() == s4u::Link::SharingPolicy::WIFI)
376 if (bandwidth_bound == -1.0 || l->get_bandwidth() < bandwidth_bound)
377 bandwidth_bound = l->get_bandwidth();
380 /* increase rate given by user considering the factor, since the actual rate will be
382 rate = rate / bw_factor;
383 /* the bandwidth is determined by the minimum between flow and user's defined rate */
384 if (rate >= 0 && rate < bandwidth_bound)
385 bandwidth_bound = rate;
386 action->set_user_bound(bandwidth_bound);
388 action->lat_current_ = action->latency_;
389 action->latency_ *= get_latency_factor(size, src, dst, s4u_route, s4u_netzones);
392 void NetworkCm02Model::comm_action_set_variable(NetworkCm02Action* action, const std::vector<StandardLinkImpl*>& route,
393 const std::vector<StandardLinkImpl*>& back_route, bool streamed)
395 size_t constraints_per_variable = route.size();
396 constraints_per_variable += back_route.size();
398 // setting the number of variable for a communication action involved in a I/O streaming operation
399 // requires to reserve some extra space for the constraints related to the source disk (global and read
400 // bandwidth) and destination disk (global and write bandwidth). We thus add 4 constraints.
401 constraints_per_variable += 4;
404 if (action->latency_ > 0) {
405 action->set_variable(get_maxmin_system()->variable_new(action, 0.0, -1.0, constraints_per_variable));
406 if (is_update_lazy()) {
407 // add to the heap the event when the latency is paid
408 double date = action->latency_ + action->get_last_update();
410 ActionHeap::Type type = route.empty() ? ActionHeap::Type::normal : ActionHeap::Type::latency;
412 XBT_DEBUG("Added action (%p) one latency event at date %f", action, date);
413 get_action_heap().insert(action, date, type);
416 action->set_variable(get_maxmin_system()->variable_new(action, 1.0, -1.0, constraints_per_variable));
418 /* after setting the variable, update the bounds depending on user configuration */
419 if (action->get_user_bound() < 0) {
420 get_maxmin_system()->update_variable_bound(
421 action->get_variable(),
422 (action->lat_current_ > 0 && cfg_tcp_gamma > 0) ? cfg_tcp_gamma / (2.0 * action->lat_current_) : -1.0);
424 get_maxmin_system()->update_variable_bound(
425 action->get_variable(), (action->lat_current_ > 0 && cfg_tcp_gamma > 0)
426 ? std::min(action->get_user_bound(), cfg_tcp_gamma / (2.0 * action->lat_current_))
427 : action->get_user_bound());
431 Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate, bool streamed)
433 double latency = 0.0;
434 std::vector<StandardLinkImpl*> back_route;
435 std::vector<StandardLinkImpl*> route;
436 std::unordered_set<kernel::routing::NetZoneImpl*> netzones;
438 XBT_IN("(%s,%s,%g,%g)", src->get_cname(), dst->get_cname(), size, rate);
440 bool failed = comm_get_route_info(src, dst, latency, route, back_route, netzones);
442 NetworkCm02Action* action = comm_action_create(src, dst, size, route, failed);
443 action->sharing_penalty_ = latency;
444 action->latency_ = latency;
446 if (cfg_weight_S_parameter > 0) {
447 action->sharing_penalty_ = std::accumulate(route.begin(), route.end(), action->sharing_penalty_,
448 [](double total, StandardLinkImpl const* link) {
449 return total + cfg_weight_S_parameter / link->get_bandwidth();
453 /* setting bandwidth and latency bounds considering route and configured bw/lat factors */
454 comm_action_set_bounds(src, dst, size, action, route, netzones, rate);
456 /* creating the maxmin variable associated to this action */
457 comm_action_set_variable(action, route, back_route, streamed);
459 /* expand maxmin system to consider this communication in bw constraint for each link in route and back_route */
460 comm_action_expand_constraints(src, dst, action, route, back_route);
469 NetworkCm02Link::NetworkCm02Link(const std::string& name, double bandwidth, kernel::lmm::System* system)
470 : StandardLinkImpl(name)
472 bandwidth_.scale = 1.0;
473 bandwidth_.peak = bandwidth;
474 this->set_constraint(system->constraint_new(this, bandwidth));
477 void NetworkCm02Link::apply_event(kernel::profile::Event* triggered, double value)
479 /* Find out which of my iterators was triggered, and react accordingly */
480 if (triggered == bandwidth_.event) {
481 set_bandwidth(value);
482 tmgr_trace_event_unref(&bandwidth_.event);
484 } else if (triggered == latency_.event) {
486 tmgr_trace_event_unref(&latency_.event);
488 } else if (triggered == get_state_event()) {
495 xbt_die("Unknown event!\n");
498 XBT_DEBUG("There was a resource state event, need to update actions related to the constraint (%p)",
502 void NetworkCm02Link::set_bandwidth(double value)
504 double old_peak = bandwidth_.peak;
505 bandwidth_.peak = value;
507 get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), (bandwidth_.peak * bandwidth_.scale));
509 StandardLinkImpl::on_bandwidth_change();
511 if (NetworkModel::cfg_weight_S_parameter > 0) {
512 double delta = NetworkModel::cfg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale) -
513 NetworkModel::cfg_weight_S_parameter / (old_peak * bandwidth_.scale);
515 const kernel::lmm::Element* elem = nullptr;
516 const kernel::lmm::Element* nextelem = nullptr;
518 while (const auto* var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem)) {
519 auto* action = static_cast<NetworkCm02Action*>(var->get_id());
520 action->sharing_penalty_ += delta;
521 if (not action->is_suspended())
522 get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_);
527 void NetworkCm02Link::set_latency(double value)
529 latency_check(value);
531 double delta = value - latency_.peak;
532 const kernel::lmm::Element* elem = nullptr;
533 const kernel::lmm::Element* nextelem = nullptr;
536 latency_.scale = 1.0;
537 latency_.peak = value;
539 while (const auto* var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem)) {
540 auto* action = static_cast<NetworkCm02Action*>(var->get_id());
541 action->lat_current_ += delta;
542 action->sharing_penalty_ += delta;
543 if (action->get_user_bound() < 0 && NetworkModel::cfg_tcp_gamma > 0)
544 get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), NetworkModel::cfg_tcp_gamma /
545 (2.0 * action->lat_current_));
546 else if (NetworkModel::cfg_tcp_gamma > 0) {
547 get_model()->get_maxmin_system()->update_variable_bound(
548 action->get_variable(),
549 std::min(action->get_user_bound(), NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)));
551 if (NetworkModel::cfg_tcp_gamma == 0 ||
552 action->get_user_bound() < NetworkModel::cfg_tcp_gamma / (2.0 * action->lat_current_)) {
553 XBT_DEBUG("Flow is limited BYBANDWIDTH");
555 XBT_DEBUG("Flow is limited BYLATENCY, latency of flow is %f", action->lat_current_);
558 if (not action->is_suspended())
559 get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), action->sharing_penalty_);
567 void NetworkCm02Action::update_remains_lazy(double now)
569 if (not is_running())
572 double delta = now - get_last_update();
574 if (get_remains_no_update() > 0) {
575 XBT_DEBUG("Updating action(%p): remains was %f, last_update was: %f", this, get_remains_no_update(),
577 update_remains(get_last_value() * delta);
579 XBT_DEBUG("Updating action(%p): remains is now %f", this, get_remains_no_update());
582 update_max_duration(delta);
584 if ((get_remains_no_update() <= 0 && (get_variable()->get_penalty() > 0)) ||
585 ((get_max_duration() != NO_MAX_DURATION) && (get_max_duration() <= 0))) {
586 finish(Action::State::FINISHED);
587 get_model()->get_action_heap().remove(this);
591 set_last_value(get_rate());
594 } // namespace simgrid::kernel::resource