namespace lmm {
class s_lmm_element_t;
class Variable;
-class s_lmm_constraint_t;
-class s_lmm_constraint_light_t;
+class Constraint;
+class ConstraintLight;
class s_lmm_system_t;
}
namespace routing {
typedef simgrid::kernel::lmm::s_lmm_element_t* lmm_element_t;
typedef const simgrid::kernel::lmm::s_lmm_element_t* const_lmm_element_t;
typedef simgrid::kernel::lmm::Variable* lmm_variable_t;
-typedef simgrid::kernel::lmm::s_lmm_constraint_t* lmm_constraint_t;
-typedef simgrid::kernel::lmm::s_lmm_constraint_light_t* lmm_constraint_light_t;
+typedef simgrid::kernel::lmm::Constraint* lmm_constraint_t;
+typedef simgrid::kernel::lmm::ConstraintLight* lmm_constraint_light_t;
typedef simgrid::kernel::lmm::s_lmm_system_t* lmm_system_t;
#else
}
XBT_DEBUG("Active constraints : %zu", sys->active_constraint_set.size());
- for (s_lmm_constraint_t& cnst : sys->active_constraint_set) {
+ for (Constraint& cnst : sys->active_constraint_set) {
sys->saturated_constraint_set.push_back(cnst);
}
- for (s_lmm_constraint_t& cnst : sys->saturated_constraint_set) {
+ for (Constraint& cnst : sys->saturated_constraint_set) {
cnst.remaining = cnst.bound;
cnst.usage = 0.0;
}
}
XBT_DEBUG("******* Constraints to process: %zu *******", cnst_list.size());
for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) {
- s_lmm_constraint_t& cnst = *iter;
+ Constraint& cnst = *iter;
int nb = 0;
XBT_DEBUG("Processing cnst %p ", &cnst);
cnst.usage = 0.0;
}
for (auto iter = std::begin(cnst_list); iter != std::end(cnst_list);) {
- s_lmm_constraint_t& cnst = *iter;
+ Constraint& cnst = *iter;
XBT_DEBUG("Updating cnst %p ", &cnst);
if (cnst.sharing_policy) {
for (s_lmm_element_t& elem : cnst.enabled_element_set) {
// solves the proportional fairness using a Lagrangian optimization with dichotomy step
void lagrange_solve(lmm_system_t sys);
// computes the value of the dichotomy using a initial values, init, with a specific variable or constraint
-static double dichotomy(double init, double diff(double, const s_lmm_constraint_t&), const s_lmm_constraint_t& cnst,
- double min_error);
+static double dichotomy(double init, double diff(double, const Constraint&), const Constraint& cnst, double min_error);
// computes the value of the differential of constraint cnst applied to lambda
-static double partial_diff_lambda(double lambda, const s_lmm_constraint_t& cnst);
+static double partial_diff_lambda(double lambda, const Constraint& cnst);
template <class CnstList, class VarList>
static int __check_feasible(const CnstList& cnst_list, const VarList& var_list, int warn)
{
- for (s_lmm_constraint_t const& cnst : cnst_list) {
+ for (Constraint const& cnst : cnst_list) {
double tmp = 0;
for (s_lmm_element_t const& elem : cnst.enabled_element_set) {
lmm_variable_t var = elem.variable;
obj += var.mu * var.bound;
}
- for (s_lmm_constraint_t const& cnst : cnst_list)
+ for (Constraint const& cnst : cnst_list)
obj += cnst.lambda * cnst.bound;
return obj;
/* Initialize lambda. */
auto& cnst_list = sys->active_constraint_set;
- for (s_lmm_constraint_t& cnst : cnst_list) {
+ for (Constraint& cnst : cnst_list) {
cnst.lambda = 1.0;
cnst.new_lambda = 2.0;
XBT_DEBUG("#### cnst(%p)->lambda : %e", &cnst, cnst.lambda);
}
/* Improve the value of lambda_i */
- for (s_lmm_constraint_t& cnst : cnst_list) {
+ for (Constraint& cnst : cnst_list) {
XBT_DEBUG("Working on cnst (%p)", &cnst);
cnst.new_lambda = dichotomy(cnst.lambda, partial_diff_lambda, cnst, dichotomy_min_error);
XBT_DEBUG("Updating lambda : cnst->lambda (%p) : %1.20f -> %1.20f", &cnst, cnst.lambda, cnst.new_lambda);
*
* @return a double corresponding to the result of the dichotomy process
*/
-static double dichotomy(double init, double diff(double, const s_lmm_constraint_t&), const s_lmm_constraint_t& cnst,
- double min_error)
+static double dichotomy(double init, double diff(double, const Constraint&), const Constraint& cnst, double min_error)
{
double min = init;
double max = init;
return ((min + max) / 2.0);
}
-static double partial_diff_lambda(double lambda, const s_lmm_constraint_t& cnst)
+static double partial_diff_lambda(double lambda, const Constraint& cnst)
{
double diff = 0.0;
typedef std::vector<int> dyn_light_t;
-int Variable::Global_debug_id = 1;
-int s_lmm_constraint_t::Global_debug_id = 1;
+int Variable::Global_debug_id = 1;
+int Constraint::Global_debug_id = 1;
int s_lmm_element_t::get_concurrency() const
{
if (not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug))
return;
- for (s_lmm_constraint_t const& cnst : constraint_set) {
+ for (Constraint const& cnst : constraint_set) {
int concurrency = 0;
for (s_lmm_element_t const& elem : cnst.enabled_element_set) {
xbt_assert(elem.variable->sharing_weight > 0);
delete cnst;
}
-s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value) : bound(bound_value), id(id_value)
+Constraint::Constraint(void* id_value, double bound_value) : bound(bound_value), id(id_value)
{
id_int = Global_debug_id++;
lmm_constraint_t s_lmm_system_t::constraint_new(void* id, double bound_value)
{
- lmm_constraint_t cnst = new s_lmm_constraint_t(id, bound_value);
+ lmm_constraint_t cnst = new Constraint(id, bound_value);
insert_constraint(cnst);
return cnst;
}
check_concurrency();
}
-lmm_variable_t s_lmm_constraint_t::get_variable(const_lmm_element_t* elem) const
+lmm_variable_t Constraint::get_variable(const_lmm_element_t* elem) const
{
if (*elem == nullptr) {
// That is the first call, pick the first element among enabled_element_set (or disabled_element_set if
// if we modify the list between calls, normal version may loop forever
// this safe version ensures that we browse the list elements only once
-lmm_variable_t s_lmm_constraint_t::get_variable_safe(const_lmm_element_t* elem, const_lmm_element_t* nextelem,
- int* numelem) const
+lmm_variable_t Constraint::get_variable_safe(const_lmm_element_t* elem, const_lmm_element_t* nextelem,
+ int* numelem) const
{
if (*elem == nullptr) {
*numelem = enabled_element_set.size() + disabled_element_set.size() - 1;
}
}
-static inline void saturated_variable_set_update(s_lmm_constraint_light_t* cnst_light_tab,
+static inline void saturated_variable_set_update(ConstraintLight* cnst_light_tab,
const dyn_light_t& saturated_constraints, lmm_system_t sys)
{
/* Add active variables (i.e. variables that need to be set) from the set of constraints to saturate
* (cnst_light_tab)*/
for (int const& saturated_cnst : saturated_constraints) {
- s_lmm_constraint_light_t& cnst = cnst_light_tab[saturated_cnst];
+ ConstraintLight& cnst = cnst_light_tab[saturated_cnst];
for (s_lmm_element_t const& elem : cnst.cnst->active_element_set) {
// Visiting active_element_set, so, by construction, should never get a zero weight, correct?
xbt_assert(elem.variable->sharing_weight > 0);
XBT_DEBUG("Constraints");
/* Printing Constraints */
- for (s_lmm_constraint_t const& cnst : active_constraint_set) {
+ for (Constraint const& cnst : active_constraint_set) {
double sum = 0.0;
// Show the enabled variables
buf += "\t";
XBT_DEBUG("Active constraints : %zu", cnst_list.size());
/* Init: Only modified code portions: reset the value of active variables */
- for (s_lmm_constraint_t const& cnst : cnst_list) {
+ for (Constraint const& cnst : cnst_list) {
for (s_lmm_element_t const& elem : cnst.enabled_element_set) {
xbt_assert(elem.variable->sharing_weight > 0.0);
elem.variable->value = 0.0;
}
}
- s_lmm_constraint_light_t* cnst_light_tab = new s_lmm_constraint_light_t[cnst_list.size()]();
- int cnst_light_num = 0;
+ ConstraintLight* cnst_light_tab = new ConstraintLight[cnst_list.size()]();
+ int cnst_light_num = 0;
dyn_light_t saturated_constraints;
- for (s_lmm_constraint_t& cnst : cnst_list) {
+ for (Constraint& cnst : cnst_list) {
/* INIT: Collect constraints that actually need to be saturated (i.e remaining and usage are strictly positive)
* into cnst_light_tab. */
cnst.remaining = cnst.bound;
*
* \param cnst the lmm_constraint_t associated to the resource
*/
-double s_lmm_constraint_t::get_usage() const
+double Constraint::get_usage() const
{
double result = 0.0;
if (sharing_policy) {
return result;
}
-int s_lmm_constraint_t::get_variable_amount() const
+int Constraint::get_variable_amount() const
{
return std::count_if(std::begin(enabled_element_set), std::end(enabled_element_set),
[](const s_lmm_element_t& elem) { return elem.consumption_weight > 0; });
double consumption_weight;
};
-struct s_lmm_constraint_light_t {
+struct ConstraintLight {
double remaining_over_usage;
lmm_constraint_t cnst;
};
* \li Active elements which variable's weight is non-zero (i.e. it is enabled) AND its element value is non-zero.
* LMM_solve iterates over active elements during resolution, dynamically making them active or unactive.
*/
-XBT_PUBLIC_CLASS s_lmm_constraint_t
+XBT_PUBLIC_CLASS Constraint
{
public:
- s_lmm_constraint_t() = default;
- s_lmm_constraint_t(void* id_value, double bound_value);
+ Constraint() = default;
+ Constraint(void* id_value, double bound_value);
/** @brief Unshare a constraint. */
void unshare() { sharing_policy = 0; }
boost::intrusive::list<Variable, boost::intrusive::member_hook<Variable, boost::intrusive::list_member_hook<>,
&Variable::variable_set_hook>>
variable_set;
- boost::intrusive::list<s_lmm_constraint_t,
- boost::intrusive::member_hook<s_lmm_constraint_t, boost::intrusive::list_member_hook<>,
- &s_lmm_constraint_t::active_constraint_set_hook>>
+ boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
+ &Constraint::active_constraint_set_hook>>
active_constraint_set;
boost::intrusive::list<Variable, boost::intrusive::member_hook<Variable, boost::intrusive::list_member_hook<>,
&Variable::saturated_variable_set_hook>>
saturated_variable_set;
- boost::intrusive::list<s_lmm_constraint_t,
- boost::intrusive::member_hook<s_lmm_constraint_t, boost::intrusive::list_member_hook<>,
- &s_lmm_constraint_t::saturated_constraint_set_hook>>
+ boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
+ &Constraint::saturated_constraint_set_hook>>
saturated_constraint_set;
simgrid::surf::ActionLmmListPtr keep_track;
bool selective_update_active; /* flag to update partially the system only selecting changed portions */
unsigned visited_counter; /* used by lmm_update_modified_set and lmm_remove_modified_set to cleverly (un-)flag the
* constraints (more details in these functions) */
- boost::intrusive::list<s_lmm_constraint_t,
- boost::intrusive::member_hook<s_lmm_constraint_t, boost::intrusive::list_member_hook<>,
- &s_lmm_constraint_t::constraint_set_hook>>
+ boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
+ &Constraint::constraint_set_hook>>
constraint_set;
- boost::intrusive::list<s_lmm_constraint_t,
- boost::intrusive::member_hook<s_lmm_constraint_t, boost::intrusive::list_member_hook<>,
- &s_lmm_constraint_t::modified_constraint_set_hook>>
+ boost::intrusive::list<Constraint, boost::intrusive::member_hook<Constraint, boost::intrusive::list_member_hook<>,
+ &Constraint::modified_constraint_set_hook>>
modified_constraint_set;
xbt_mallocator_t variable_mallocator;
};
friend CpuAction *CpuCas01::sleep(double duration);
public:
CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, int coreAmount);
- CpuCas01Action(Model *model, double cost, bool failed, double speed, lmm_constraint_t constraint);
+ CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint);
~CpuCas01Action() override;
int requestedCore();
* @param speedPerPstate Processor speed (in flop per second) for each pstate
* @param core The number of core of this Cpu
*/
- Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, lmm_constraint_t constraint,
- std::vector<double> *speedPerPstate, int core);
+ Cpu(simgrid::surf::Model* model, simgrid::s4u::Host* host, lmm_constraint_t constraint,
+ std::vector<double>* speedPerPstate, int core);
/**
* @brief Cpu constructor
* @param speedPerPstate Processor speed (in flop per second) for each pstate
* @param core The number of core of this Cpu
*/
- Cpu(simgrid::surf::Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
+ Cpu(simgrid::surf::Model* model, simgrid::s4u::Host* host, std::vector<double>* speedPerPstate, int core);
~Cpu();