X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/cb7b420897349dc09ef02bf64ca98dc5153864b6..8c6bbb14f44b8daed5ea43d80880c6bf2155118b:/src/kernel/lmm/System.hpp diff --git a/src/kernel/lmm/System.hpp b/src/kernel/lmm/System.hpp index fbc5a7da73..bfbe7d224e 100644 --- a/src/kernel/lmm/System.hpp +++ b/src/kernel/lmm/System.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2004-2022. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2004-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. */ @@ -8,23 +8,24 @@ #include "simgrid/kernel/resource/Action.hpp" #include "simgrid/kernel/resource/Model.hpp" -#include "simgrid/s4u/Link.hpp" -#include "src/surf/surf_interface.hpp" #include "xbt/asserts.h" -#include "xbt/ex.h" #include "xbt/mallocator.h" #include #include #include #include +#include #include -namespace simgrid { -namespace kernel { -namespace lmm { +/* user-visible parameters */ +XBT_PUBLIC_DATA double sg_precision_workamount; +XBT_PUBLIC_DATA double sg_precision_timing; +XBT_PUBLIC_DATA int sg_concurrency_limit; -/** @addtogroup SURF_lmm +namespace simgrid::kernel::lmm { + +/** @addtogroup Model_lmm * @details * A linear maxmin solver to resolve inequations systems. * @@ -126,14 +127,15 @@ namespace lmm { * - concurrency_current which is the current concurrency * - concurrency_maximum which is the observed maximum concurrency * - * Variables also have one field related to concurrency: concurrency_share. - * In effect, in some cases, one variable is involved multiple times (i.e. two elements) in a constraint. - * For example, cross-traffic is modeled using 2 elements per constraint. - * concurrency_share formally corresponds to the maximum number of elements that associate the variable and any given - * constraint. + * Variables consumes the concurrency_limit of each constraint they are using. + * Each pair variable/constrainst is linked by a *single* Element object. Through this + * object and the respective methods (get_concurrency(), increase_concurrency() and decrease_concurrency()), + * the variable changes the constraint's concurrency. + * The amount of concurrency slack taken by each variable is determined by the Element::get_concurrency() method. + * At the current state, each variable counts as 1 if its consumption weight is greater than 1. */ -/** @{ @ingroup SURF_lmm */ +/** @{ @ingroup Model_lmm */ /** * @brief LMM element @@ -150,7 +152,19 @@ public: Element(const Element&) = default; ~Element() = default; + /** + * @brief Gets the "weight" of this element for concurrency checks. + * + * This is the amount taken by this variable of the constraint's concurrency slack + * + * @return 1 if consumption_weight greater than 1, 0 otherwise + */ int get_concurrency() const; + /** + * @brief Decreases the constraint's concurrency + * + * Decreases the equivalent of get_concurrency() from the constraint related to this element + */ void decrease_concurrency(); /** * @brief Increase constraint concurrency @@ -194,7 +208,7 @@ public: */ class XBT_PUBLIC Constraint { public: - enum class SharingPolicy { NONLINEAR = 2, SHARED = 1, FATPIPE = 0 }; + enum class SharingPolicy { WIFI = 3, NONLINEAR = 2, SHARED = 1, FATPIPE = 0 }; Constraint(resource::Resource* id_value, double bound_value); @@ -208,7 +222,6 @@ public: /** @brief Get the usage of the constraint after the last lmm solve */ double get_usage() const; - int get_variable_amount() const; /** @brief Sets the concurrency limit for this constraint */ void set_concurrency_limit(int limit) @@ -232,10 +245,18 @@ public: int get_concurrency_maximum() const { xbt_assert(concurrency_limit_ < 0 || concurrency_maximum_ <= concurrency_limit_, - "Very bad: maximum observed concurrency is higher than limit. This is a bug of SURF, please report it."); + "Very bad: maximum observed concurrency is higher than limit. This is a bug, please report it."); return concurrency_maximum_; } + /** + * @brief Get constraint current concurrency slack + * + * This represents the "space" available for new variables in this contraint. + * A variable can be enabled and use this constraint if its get_concurrency() <= slack + * + * @return Constraint's slack + */ int get_concurrency_slack() const { return concurrency_limit_ < 0 ? std::numeric_limits::max() : concurrency_limit_ - concurrency_current_; @@ -400,7 +421,7 @@ public: * @param selective_update Enables lazy updates * @return pointer to System instance */ - static System* build(const std::string& solver_name, bool selective_update); + static System* build(std::string_view solver_name, bool selective_update); /** @brief Validates solver configuration */ static void validate_solver(const std::string& solver_name); @@ -446,8 +467,11 @@ public: * @param cnst A constraint * @param var A variable * @param value The coefficient associated to the variable in the constraint + * @param force_creation Force the creation of new element linking the variable to the constraint. Should be used only + * by the model ptask_L07 to cope with ptasks composed of flows running on the same resource (see + * https://framagit.org/simgrid/simgrid/-/issues/111) */ - void expand(Constraint * cnst, Variable * var, double value); + void expand(Constraint* cnst, Variable* var, double value, bool force_creation = false); /** @brief Update the bound of a variable */ void update_variable_bound(Variable * var, double bound); @@ -566,7 +590,7 @@ public: saturated_constraint_set; protected: - bool selective_update_active; /* flag to update partially the system only selecting changed portions */ + const bool selective_update_active; /* flag to update partially the system only selecting changed portions */ boost::intrusive::list, &Constraint::modified_constraint_set_hook_>> modified_constraint_set; @@ -585,8 +609,6 @@ private: }; /** @} */ -} // namespace lmm -} // namespace kernel -} // namespace simgrid +} // namespace simgrid::kernel::lmm -#endif \ No newline at end of file +#endif