X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ec38e1b35a34ad8c6ce3e75506ea5bcd8d96e323..b8df87e176f27b25534f27d7e240defa32ca35bc:/src/kernel/lmm/fair_bottleneck.cpp diff --git a/src/kernel/lmm/fair_bottleneck.cpp b/src/kernel/lmm/fair_bottleneck.cpp index 83bd007663..4426ce8351 100644 --- a/src/kernel/lmm/fair_bottleneck.cpp +++ b/src/kernel/lmm/fair_bottleneck.cpp @@ -1,12 +1,12 @@ -/* Copyright (c) 2007-2011, 2013-2017. The SimGrid Team. - * All rights reserved. */ +/* Copyright (c) 2007-2019. 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. */ #include "src/kernel/lmm/maxmin.hpp" -#include "xbt/log.h" +#include "src/surf/surf_interface.hpp" #include "xbt/sysdep.h" + #include #include #include @@ -14,23 +14,25 @@ #include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_maxmin); -#define SHOW_EXPR_G(expr) XBT_DEBUG(#expr " = %g", expr); -#define SHOW_EXPR_D(expr) XBT_DEBUG(#expr " = %d", expr); -#define SHOW_EXPR_P(expr) XBT_DEBUG(#expr " = %p", expr); -void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) +simgrid::kernel::lmm::System* simgrid::kernel::lmm::make_new_fair_bottleneck_system(bool selective_update) +{ + return new simgrid::kernel::lmm::FairBottleneck(selective_update); +} + +void simgrid::kernel::lmm::FairBottleneck::bottleneck_solve() { - if (not sys->modified) + if (not modified_) return; - XBT_DEBUG("Variable set : %zu", sys->variable_set.size()); - for (Variable& var : sys->variable_set) { + XBT_DEBUG("Variable set : %zu", variable_set.size()); + for (Variable& var : variable_set) { var.value = 0.0; XBT_DEBUG("Handling variable %p", &var); if (var.sharing_weight > 0.0 && std::find_if(begin(var.cnsts), end(var.cnsts), [](Element const& x) { return x.consumption_weight != 0.0; }) != end(var.cnsts)) { - sys->saturated_variable_set.push_back(var); + saturated_variable_set.push_back(var); } else { XBT_DEBUG("Err, finally, there is no need to take care of variable %p", &var); if (var.sharing_weight > 0.0) @@ -38,11 +40,11 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) } } - XBT_DEBUG("Active constraints : %zu", sys->active_constraint_set.size()); - for (Constraint& cnst : sys->active_constraint_set) { - sys->saturated_constraint_set.push_back(cnst); + XBT_DEBUG("Active constraints : %zu", active_constraint_set.size()); + for (Constraint& cnst : active_constraint_set) { + saturated_constraint_set.push_back(cnst); } - for (Constraint& cnst : sys->saturated_constraint_set) { + for (Constraint& cnst : saturated_constraint_set) { cnst.remaining = cnst.bound; cnst.usage = 0.0; } @@ -52,12 +54,12 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) /* * Compute Usage and store the variables that reach the maximum. */ - auto& var_list = sys->saturated_variable_set; - auto& cnst_list = sys->saturated_constraint_set; + auto& var_list = saturated_variable_set; + auto& cnst_list = saturated_constraint_set; do { if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) { XBT_DEBUG("Fair bottleneck done"); - sys->print(); + print(); } XBT_DEBUG("******* Constraints to process: %zu *******", cnst_list.size()); for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) { @@ -71,7 +73,7 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) nb++; } XBT_DEBUG("\tThere are %d variables", nb); - if (nb > 0 && not cnst.sharing_policy) + if (nb > 0 && cnst.sharing_policy == s4u::Link::SharingPolicy::FATPIPE) nb = 1; if (nb == 0) { cnst.remaining = 0.0; @@ -105,7 +107,7 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) { Constraint& cnst = *iter; XBT_DEBUG("Updating cnst %p ", &cnst); - if (cnst.sharing_policy) { + if (cnst.sharing_policy != s4u::Link::SharingPolicy::FATPIPE) { for (Element& elem : cnst.enabled_element_set) { xbt_assert(elem.variable->sharing_weight > 0); XBT_DEBUG("\tUpdate constraint %p (%g) with variable %p by %g", &cnst, cnst.remaining, elem.variable, @@ -143,9 +145,9 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys) } while (not var_list.empty()); cnst_list.clear(); - sys->modified = true; + modified_ = true; if (XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug)) { XBT_DEBUG("Fair bottleneck done"); - sys->print(); + print(); } }