Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Rename simgrid::kernel::lmm::s_lmm_constraint_t -> Constraint.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 7 Dec 2017 21:06:18 +0000 (22:06 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 7 Dec 2017 22:42:27 +0000 (23:42 +0100)
include/simgrid/forward.h
src/kernel/lmm/fair_bottleneck.cpp
src/kernel/lmm/lagrange.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/lmm/maxmin.hpp
src/surf/cpu_cas01.hpp
src/surf/cpu_interface.hpp

index b4773eb..83bb7b1 100644 (file)
@@ -40,8 +40,8 @@ namespace activity {
 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 {
@@ -90,8 +90,8 @@ typedef simgrid::surf::StorageImpl* surf_storage_t;
 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
index c8b02fe..c368001 100644 (file)
@@ -39,10 +39,10 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys)
   }
 
   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;
   }
@@ -61,7 +61,7 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys)
     }
     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;
@@ -103,7 +103,7 @@ void simgrid::kernel::lmm::bottleneck_solve(lmm_system_t sys)
     }
 
     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) {
index 07c8fbb..7bef962 100644 (file)
@@ -39,15 +39,14 @@ double (*func_fpi_def)(const Variable&, double);
 // 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;
@@ -132,7 +131,7 @@ static double dual_objective(const VarList& var_list, const CnstList& cnst_list)
       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;
@@ -161,7 +160,7 @@ void lagrange_solve(lmm_system_t sys)
 
   /* 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);
@@ -220,7 +219,7 @@ void lagrange_solve(lmm_system_t sys)
     }
 
     /* 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);
@@ -279,8 +278,7 @@ void lagrange_solve(lmm_system_t sys)
  *
  * @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;
@@ -380,7 +378,7 @@ static double dichotomy(double init, double diff(double, const s_lmm_constraint_
   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;
 
index 1c7da75..8c1928d 100644 (file)
@@ -30,8 +30,8 @@ namespace lmm {
 
 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
 {
@@ -69,7 +69,7 @@ void s_lmm_system_t::check_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);
@@ -179,7 +179,7 @@ void s_lmm_system_t::cnst_free(lmm_constraint_t cnst)
   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++;
 
@@ -197,7 +197,7 @@ s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value) : bou
 
 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;
 }
@@ -325,7 +325,7 @@ void s_lmm_system_t::expand_add(lmm_constraint_t cnst, lmm_variable_t var, doubl
   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
@@ -360,8 +360,8 @@ lmm_variable_t s_lmm_constraint_t::get_variable(const_lmm_element_t* elem) const
 
 // 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;
@@ -412,13 +412,13 @@ static inline void saturated_constraints_update(double usage, int cnst_light_num
   }
 }
 
-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);
@@ -454,7 +454,7 @@ void s_lmm_system_t::print() const
 
   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";
@@ -509,18 +509,18 @@ template <class CnstList> void s_lmm_system_t::solve(CnstList& cnst_list)
 
   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;
@@ -960,7 +960,7 @@ void s_lmm_system_t::remove_all_modified_set()
  *
  * \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) {
@@ -975,7 +975,7 @@ double s_lmm_constraint_t::get_usage() const
   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; });
index 3deb516..6ddbb97 100644 (file)
@@ -192,7 +192,7 @@ public:
   double consumption_weight;
 };
 
-struct s_lmm_constraint_light_t {
+struct ConstraintLight {
   double remaining_over_usage;
   lmm_constraint_t cnst;
 };
@@ -206,11 +206,11 @@ struct s_lmm_constraint_light_t {
  * \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; }
@@ -596,16 +596,14 @@ public:
   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;
@@ -616,13 +614,11 @@ private:
   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;
 };
index a7c2202..4516d98 100644 (file)
@@ -60,7 +60,7 @@ class CpuCas01Action: public CpuAction {
   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(Modelmodel, double cost, bool failed, double speed, lmm_constraint_t constraint);
   ~CpuCas01Action() override;
   int requestedCore();
 
index 4c9fa00..f8d4f25 100644 (file)
@@ -56,8 +56,8 @@ public:
    * @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
@@ -67,7 +67,7 @@ public:
    * @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();