From 7f3527d281baac664d10ce7086e0d0138e1389d7 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sat, 10 Mar 2018 11:03:48 +0100 Subject: [PATCH 1/1] kill some internal C type aliases --- include/simgrid/forward.h | 2 - src/kernel/lmm/lagrange.cpp | 2 +- src/kernel/lmm/maxmin.cpp | 55 +++++++++-------- src/kernel/lmm/maxmin.hpp | 62 ++++++++++---------- src/surf/StorageImpl.hpp | 6 +- src/surf/cpu_cas01.cpp | 13 ++-- src/surf/cpu_cas01.hpp | 5 +- src/surf/cpu_interface.cpp | 4 +- src/surf/cpu_interface.hpp | 6 +- src/surf/network_cm02.cpp | 10 ++-- src/surf/network_interface.cpp | 2 +- src/surf/network_interface.hpp | 4 +- src/surf/ptask_L07.cpp | 6 +- src/surf/surf_interface.cpp | 8 +-- src/surf/surf_interface.hpp | 14 ++--- teshsuite/surf/lmm_usage/lmm_usage.cpp | 28 ++++----- teshsuite/surf/maxmin_bench/maxmin_bench.cpp | 4 +- 17 files changed, 115 insertions(+), 116 deletions(-) diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 932705ac43..156c99355a 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -92,8 +92,6 @@ typedef simgrid::surf::StorageImpl* surf_storage_t; typedef simgrid::kernel::lmm::Element* lmm_element_t; typedef const simgrid::kernel::lmm::Element* const_lmm_element_t; -typedef simgrid::kernel::lmm::Variable* lmm_variable_t; -typedef simgrid::kernel::lmm::Constraint* lmm_constraint_t; typedef simgrid::kernel::lmm::ConstraintLight* lmm_constraint_light_t; typedef simgrid::kernel::lmm::System* lmm_system_t; diff --git a/src/kernel/lmm/lagrange.cpp b/src/kernel/lmm/lagrange.cpp index f9d999d821..d08d85c9b9 100644 --- a/src/kernel/lmm/lagrange.cpp +++ b/src/kernel/lmm/lagrange.cpp @@ -49,7 +49,7 @@ static int __check_feasible(const CnstList& cnst_list, const VarList& var_list, for (Constraint const& cnst : cnst_list) { double tmp = 0; for (Element const& elem : cnst.enabled_element_set) { - lmm_variable_t var = elem.variable; + Variable* var = elem.variable; xbt_assert(var->sharing_weight > 0); tmp += var->value; } diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index 633dc21b66..e859c9e717 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -109,7 +109,7 @@ void System::check_concurrency() const } } -void System::var_free(lmm_variable_t var) +void System::var_free(Variable* var) { XBT_IN("(sys=%p, var=%p)", this, var); modified = true; @@ -158,8 +158,8 @@ System::System(bool selective_update) : selective_update_active(selective_update System::~System() { - lmm_variable_t var; - lmm_constraint_t cnst; + Variable* var; + Constraint* cnst; while ((var = extract_variable())) { auto demangled = simgrid::xbt::demangle(typeid(*var->id).name()); @@ -173,7 +173,7 @@ System::~System() xbt_mallocator_free(variable_mallocator); } -void System::cnst_free(lmm_constraint_t cnst) +void System::cnst_free(Constraint* cnst) { make_constraint_inactive(cnst); delete cnst; @@ -195,9 +195,9 @@ Constraint::Constraint(void* id_value, double bound_value) : bound(bound_value), cnst_light = nullptr; } -lmm_constraint_t System::constraint_new(void* id, double bound_value) +Constraint* System::constraint_new(void* id, double bound_value) { - lmm_constraint_t cnst = new Constraint(id, bound_value); + Constraint* cnst = new Constraint(id, bound_value); insert_constraint(cnst); return cnst; } @@ -209,15 +209,15 @@ void* System::variable_mallocator_new_f() void System::variable_mallocator_free_f(void* var) { - delete static_cast(var); + delete static_cast(var); } -lmm_variable_t System::variable_new(simgrid::surf::Action* id, double sharing_weight, double bound, - int number_of_constraints) +Variable* System::variable_new(simgrid::surf::Action* id, double sharing_weight, double bound, + int number_of_constraints) { XBT_IN("(sys=%p, id=%p, weight=%f, bound=%f, num_cons =%d)", this, id, sharing_weight, bound, number_of_constraints); - lmm_variable_t var = static_cast(xbt_mallocator_get(variable_mallocator)); + Variable* var = static_cast(xbt_mallocator_get(variable_mallocator)); var->initialize(id, sharing_weight, bound, number_of_constraints, visited_counter - 1); if (sharing_weight) variable_set.push_front(*var); @@ -228,13 +228,13 @@ lmm_variable_t System::variable_new(simgrid::surf::Action* id, double sharing_we return var; } -void System::variable_free(lmm_variable_t var) +void System::variable_free(Variable* var) { remove_variable(var); var_free(var); } -void System::expand(lmm_constraint_t cnst, lmm_variable_t var, double consumption_weight) +void System::expand(Constraint* cnst, Variable* var, double consumption_weight) { modified = true; @@ -287,7 +287,7 @@ void System::expand(lmm_constraint_t cnst, lmm_variable_t var, double consumptio check_concurrency(); } -void System::expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value) +void System::expand_add(Constraint* cnst, Variable* var, double value) { modified = true; @@ -325,7 +325,7 @@ void System::expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value) check_concurrency(); } -lmm_variable_t Constraint::get_variable(const_lmm_element_t* elem) const +Variable* 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,7 @@ lmm_variable_t Constraint::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 Constraint::get_variable_safe(const_lmm_element_t* elem, const_lmm_element_t* nextelem, - int* numelem) const +Variable* 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; @@ -602,7 +601,7 @@ template void System::solve(CnstList& cnst_list) /* Update the usage of contraints where this variable is involved */ for (Element& elem : var.cnsts) { - lmm_constraint_t cnst = elem.constraint; + Constraint* cnst = elem.constraint; if (cnst->sharing_policy) { // Remember: shared constraints require that sum(elem.value * var.value) < cnst->bound double_update(&(cnst->remaining), elem.consumption_weight * var.value, cnst->bound * sg_maxmin_precision); @@ -698,13 +697,13 @@ void lmm_solve(lmm_system_t sys) /** \brief Attribute the value bound to var->bound. * - * \param var the lmm_variable_t + * \param var the Variable* * \param bound the new bound to associate with var * * Makes var->bound equal to bound. Whenever this function is called a change is signed in the system. To * avoid false system changing detection it is a good idea to test (bound != 0) before calling it. */ -void System::update_variable_bound(lmm_variable_t var, double bound) +void System::update_variable_bound(Variable* var, double bound) { modified = true; var->bound = bound; @@ -754,7 +753,7 @@ int Variable::get_min_concurrency_slack() const // with var when running System::update_modified_set(). // A priori not a big performance issue, but we might do better by calling System::update_modified_set() within the for // loops (after doing the first for enabling==1, and before doing the last for disabling==1) -void System::enable_var(lmm_variable_t var) +void System::enable_var(Variable* var) { xbt_assert(not XBT_LOG_ISENABLED(surf_maxmin, xbt_log_priority_debug) || var->can_enable()); @@ -779,7 +778,7 @@ void System::enable_var(lmm_variable_t var) // Anyway, caller functions all call check_concurrency() in the end. } -void System::disable_var(lmm_variable_t var) +void System::disable_var(Variable* var) { xbt_assert(not var->staged_weight, "Staged weight should have been cleared"); // Disabling the variable, move to var to list tail. Subtlety is: here, we need to call update_modified_set @@ -809,7 +808,7 @@ void System::disable_var(lmm_variable_t var) * If yes, check that none of the constraints that this variable is involved in is at the limit of its concurrency * And then add it to enabled variables */ -void System::on_disabled_var(lmm_constraint_t cnstr) +void System::on_disabled_var(Constraint* cnstr) { if (cnstr->get_concurrency_limit() < 0) return; @@ -853,7 +852,7 @@ void System::on_disabled_var(lmm_constraint_t cnstr) /* \brief update the weight of a variable, and enable/disable it. * @return Returns whether a change was made */ -void System::update_variable_weight(lmm_variable_t var, double weight) +void System::update_variable_weight(Variable* var, double weight) { xbt_assert(weight >= 0, "Variable weight should not be negative!"); @@ -891,7 +890,7 @@ void System::update_variable_weight(lmm_variable_t var, double weight) XBT_OUT(); } -void System::update_constraint_bound(lmm_constraint_t cnst, double bound) +void System::update_constraint_bound(Constraint* cnst, double bound) { modified = true; update_modified_set(cnst); @@ -901,15 +900,15 @@ void System::update_constraint_bound(lmm_constraint_t cnst, double bound) /** \brief Update the constraint set propagating recursively to other constraints so the system should not be entirely * computed. * - * \param cnst the lmm_constraint_t affected by the change + * \param cnst the Constraint* affected by the change * * A recursive algorithm to optimize the system recalculation selecting only constraints that have changed. Each * constraint change is propagated to the list of constraints for each variable. */ -void System::update_modified_set_rec(lmm_constraint_t cnst) +void System::update_modified_set_rec(Constraint* cnst) { for (Element const& elem : cnst->enabled_element_set) { - lmm_variable_t var = elem.variable; + Variable* var = elem.variable; for (Element const& elem2 : var->cnsts) { if (var->visited == visited_counter) break; @@ -923,7 +922,7 @@ void System::update_modified_set_rec(lmm_constraint_t cnst) } } -void System::update_modified_set(lmm_constraint_t cnst) +void System::update_modified_set(Constraint* cnst) { /* nothing to do if selective update isn't active */ if (selective_update_active && not cnst->modified_constraint_set_hook.is_linked()) { diff --git a/src/kernel/lmm/maxmin.hpp b/src/kernel/lmm/maxmin.hpp index e5efd9d646..f3ea120a37 100644 --- a/src/kernel/lmm/maxmin.hpp +++ b/src/kernel/lmm/maxmin.hpp @@ -183,8 +183,8 @@ public: boost::intrusive::list_member_hook<> disabled_element_set_hook; boost::intrusive::list_member_hook<> active_element_set_hook; - lmm_constraint_t constraint; - lmm_variable_t variable; + Constraint* constraint; + Variable* variable; // consumption_weight: impact of 1 byte or flop of your application onto the resource (in byte or flop) // - if CPU, then probably 1. @@ -194,7 +194,7 @@ public: struct ConstraintLight { double remaining_over_usage; - lmm_constraint_t cnst; + Constraint* cnst; }; /** @@ -274,7 +274,7 @@ public: * @param elem A element of constraint of the constraint or NULL * @return A variable associated to a constraint */ - lmm_variable_t get_variable(const_lmm_element_t* elem) const; + Variable* get_variable(const_lmm_element_t * elem) const; /** * @brief Get a var associated to a constraint @@ -284,7 +284,7 @@ public: * @param numelem parameter representing the number of elements to go * @return A variable associated to a constraint */ - lmm_variable_t get_variable_safe(const_lmm_element_t* elem, const_lmm_element_t* nextelem, int* numelem) const; + Variable* get_variable_safe(const_lmm_element_t * elem, const_lmm_element_t * nextelem, int* numelem) const; /** * @brief Get the data associated to a constraint @@ -362,7 +362,7 @@ public: * @param num The rank of constraint we want to get * @return The numth constraint */ - lmm_constraint_t get_constraint(unsigned num) const { return num < cnsts.size() ? cnsts[num].constraint : nullptr; } + Constraint* get_constraint(unsigned num) const { return num < cnsts.size() ? cnsts[num].constraint : nullptr; } /** * @brief Get the weigth of the numth constraint associated to the variable @@ -458,7 +458,7 @@ public: * @param id Data associated to the constraint (e.g.: a network link) * @param bound_value The bound value of the constraint */ - lmm_constraint_t constraint_new(void* id, double bound_value); + Constraint* constraint_new(void* id, double bound_value); /** * @brief Create a new Linear MaxMin variable @@ -467,13 +467,13 @@ public: * @param bound The maximum value of the variable (-1.0 if no maximum value) * @param number_of_constraints The maximum number of constraint to associate to the variable */ - lmm_variable_t variable_new(simgrid::surf::Action* id, double weight_value, double bound, int number_of_constraints); + Variable* variable_new(simgrid::surf::Action * id, double weight_value, double bound, int number_of_constraints); /** * @brief Free a variable * @param var The variable to free */ - void variable_free(lmm_variable_t var); + void variable_free(Variable * var); /** * @brief Associate a variable to a constraint with a coefficient @@ -481,7 +481,7 @@ public: * @param var A variable * @param value The coefficient associated to the variable in the constraint */ - void expand(lmm_constraint_t cnst, lmm_variable_t var, double value); + void expand(Constraint * cnst, Variable * var, double value); /** * @brief Add value to the coefficient between a constraint and a variable or create one @@ -489,35 +489,35 @@ public: * @param var A variable * @param value The value to add to the coefficient associated to the variable in the constraint */ - void expand_add(lmm_constraint_t cnst, lmm_variable_t var, double value); + void expand_add(Constraint * cnst, Variable * var, double value); /** * @brief Update the bound of a variable * @param var A constraint * @param bound The new bound */ - void update_variable_bound(lmm_variable_t var, double bound); + void update_variable_bound(Variable * var, double bound); /** * @brief Update the weight of a variable * @param var A variable * @param weight The new weight of the variable */ - void update_variable_weight(lmm_variable_t var, double weight); + void update_variable_weight(Variable * var, double weight); /** * @brief Update a constraint bound * @param cnst A constraint * @param bound The new bound of the consrtaint */ - void update_constraint_bound(lmm_constraint_t cnst, double bound); + void update_constraint_bound(Constraint * cnst, double bound); /** * @brief [brief description] * @param cnst A constraint * @return [description] */ - int constraint_used(lmm_constraint_t cnst) { return cnst->active_constraint_set_hook.is_linked(); } + int constraint_used(Constraint * cnst) { return cnst->active_constraint_set_hook.is_linked(); } /** @brief Print the lmm system */ void print() const; @@ -529,38 +529,38 @@ private: static void* variable_mallocator_new_f(); static void variable_mallocator_free_f(void* var); - void var_free(lmm_variable_t var); - void cnst_free(lmm_constraint_t cnst); - lmm_variable_t extract_variable() + void var_free(Variable * var); + void cnst_free(Constraint * cnst); + Variable* extract_variable() { if (variable_set.empty()) return nullptr; - lmm_variable_t res = &variable_set.front(); + Variable* res = &variable_set.front(); variable_set.pop_front(); return res; } - lmm_constraint_t extract_constraint() + Constraint* extract_constraint() { if (constraint_set.empty()) return nullptr; - lmm_constraint_t res = &constraint_set.front(); + Constraint* res = &constraint_set.front(); constraint_set.pop_front(); return res; } - void insert_constraint(lmm_constraint_t cnst) { constraint_set.push_back(*cnst); } - void remove_variable(lmm_variable_t var) + void insert_constraint(Constraint * cnst) { constraint_set.push_back(*cnst); } + void remove_variable(Variable * var) { if (var->variable_set_hook.is_linked()) simgrid::xbt::intrusive_erase(variable_set, *var); if (var->saturated_variable_set_hook.is_linked()) simgrid::xbt::intrusive_erase(saturated_variable_set, *var); } - void make_constraint_active(lmm_constraint_t cnst) + void make_constraint_active(Constraint * cnst) { if (not cnst->active_constraint_set_hook.is_linked()) active_constraint_set.push_back(*cnst); } - void make_constraint_inactive(lmm_constraint_t cnst) + void make_constraint_inactive(Constraint * cnst) { if (cnst->active_constraint_set_hook.is_linked()) simgrid::xbt::intrusive_erase(active_constraint_set, *cnst); @@ -568,9 +568,9 @@ private: simgrid::xbt::intrusive_erase(modified_constraint_set, *cnst); } - void enable_var(lmm_variable_t var); - void disable_var(lmm_variable_t var); - void on_disabled_var(lmm_constraint_t cnstr); + void enable_var(Variable * var); + void disable_var(Variable * var); + void on_disabled_var(Constraint * cnstr); /** * @brief Update the value of element linking the constraint and the variable @@ -578,10 +578,10 @@ private: * @param var A variable * @param value The new value */ - void update(lmm_constraint_t cnst, lmm_variable_t var, double value); + void update(Constraint * cnst, Variable * var, double value); - void update_modified_set(lmm_constraint_t cnst); - void update_modified_set_rec(lmm_constraint_t cnst); + void update_modified_set(Constraint * cnst); + void update_modified_set_rec(Constraint * cnst); /** @brief Remove all constraints of the modified_constraint_set. */ void remove_all_modified_set(); diff --git a/src/surf/StorageImpl.hpp b/src/surf/StorageImpl.hpp index 17036c1d7e..e0b4112dd1 100644 --- a/src/surf/StorageImpl.hpp +++ b/src/surf/StorageImpl.hpp @@ -119,8 +119,8 @@ public: static std::unordered_map* storagesMap() { return StorageImpl::storages; } - lmm_constraint_t constraintWrite_; /* Constraint for maximum write bandwidth*/ - lmm_constraint_t constraintRead_; /* Constraint for maximum write bandwidth*/ + kernel::lmm::Constraint* constraintWrite_; /* Constraint for maximum write bandwidth*/ + kernel::lmm::Constraint* constraintRead_; /* Constraint for maximum write bandwidth*/ std::string typeId_; std::string content_name; // Only used at parsing time then goes to the FileSystemExtension @@ -172,7 +172,7 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(Model* model, double cost, bool failed, lmm_variable_t var, StorageImpl* storage, + StorageAction(Model* model, double cost, bool failed, kernel::lmm::Variable* var, StorageImpl* storage, e_surf_action_storage_type_t type) : Action(model, cost, failed, var), type_(type), storage_(storage){}; diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 6d8ca3cc7c..c6bbc3512d 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -97,7 +97,7 @@ bool CpuCas01::isUsed() /** @brief take into account changes of speed (either load or max) */ void CpuCas01::onSpeedChange() { - lmm_variable_t var = nullptr; + kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; model()->getMaxminSystem()->update_constraint_bound(constraint(), coresAmount_ * speed_.scale * speed_.peak); @@ -130,8 +130,8 @@ void CpuCas01::apply_event(tmgr_trace_event_t event, double value) host_that_restart.push_back(getHost()); turnOn(); } else { - lmm_constraint_t cnst = constraint(); - lmm_variable_t var = nullptr; + kernel::lmm::Constraint* cnst = constraint(); + kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; double date = surf_get_clock(); @@ -199,8 +199,8 @@ CpuAction *CpuCas01::sleep(double duration) /********** * Action * **********/ -CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint, - int requestedCore) +CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint, int requestedCore) : CpuAction(model, cost, failed, model->getMaxminSystem()->variable_new(this, 1.0 / requestedCore, requestedCore * speed, 1)) , requestedCore_(requestedCore) @@ -212,7 +212,8 @@ CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double sp model->getMaxminSystem()->expand(constraint, getVariable(), 1.0); } -CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, lmm_constraint_t constraint) +CpuCas01Action::CpuCas01Action(Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint) : CpuCas01Action(model, cost, failed, speed, constraint, 1) { } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index 938c39e0ba..b256781e7a 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -59,8 +59,9 @@ class CpuCas01Action: public CpuAction { friend CpuAction *CpuCas01::execution_start(double size); 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, kernel::lmm::Constraint* constraint, + int coreAmount); + CpuCas01Action(Model* model, double cost, bool failed, double speed, kernel::lmm::Constraint* constraint); ~CpuCas01Action() override; int requestedCore(); diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 6708124afe..5a02c5b3b5 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -85,8 +85,8 @@ Cpu::Cpu(Model *model, simgrid::s4u::Host *host, std::vector *speedPerPs { } -Cpu::Cpu(Model* model, simgrid::s4u::Host* host, lmm_constraint_t constraint, std::vector* speedPerPstate, - int core) +Cpu::Cpu(Model* model, simgrid::s4u::Host* host, kernel::lmm::Constraint* constraint, + std::vector* speedPerPstate, int core) : Resource(model, host->getCname(), constraint), coresAmount_(core), host_(host) { xbt_assert(core > 0, "Host %s must have at least one core, not 0.", host->getCname()); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index f8d4f258d9..757bb99133 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -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* speedPerPstate, int core); + Cpu(simgrid::surf::Model * model, simgrid::s4u::Host * host, kernel::lmm::Constraint * constraint, + std::vector * speedPerPstate, int core); /** * @brief Cpu constructor @@ -157,7 +157,7 @@ public: static simgrid::xbt::signal onShareChange; CpuAction(simgrid::surf::Model* model, double cost, bool failed) : Action(model, cost, failed) {} - CpuAction(simgrid::surf::Model* model, double cost, bool failed, lmm_variable_t var) + CpuAction(simgrid::surf::Model * model, double cost, bool failed, kernel::lmm::Variable* var) : Action(model, cost, failed, var) { } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index c440d22dbe..615c4ea548 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -182,7 +182,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) int n = action->getVariable()->get_number_of_constraint(); for (int i = 0; i < n; i++){ - lmm_constraint_t constraint = action->getVariable()->get_constraint(i); + kernel::lmm::Constraint* constraint = action->getVariable()->get_constraint(i); NetworkCm02Link* link = static_cast(constraint->get_id()); double value = action->getVariable()->get_value() * action->getVariable()->get_constraint_weight(i); TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), value, action->getLastUpdate(), @@ -231,7 +231,7 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) if (TRACE_is_enabled()) { int n = action.getVariable()->get_number_of_constraint(); for (int i = 0; i < n; i++) { - lmm_constraint_t constraint = action.getVariable()->get_constraint(i); + kernel::lmm::Constraint* constraint = action.getVariable()->get_constraint(i); NetworkCm02Link* link = static_cast(constraint->get_id()); TRACE_surf_link_set_utilization( link->getCname(), action.getCategory(), @@ -380,7 +380,7 @@ void NetworkCm02Link::apply_event(tmgr_trace_event_t triggered, double value) if (value > 0) turnOn(); else { - lmm_variable_t var = nullptr; + kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; double now = surf_get_clock(); @@ -414,7 +414,7 @@ void NetworkCm02Link::setBandwidth(double value) if (sg_weight_S_parameter > 0) { double delta = sg_weight_S_parameter / value - sg_weight_S_parameter / (bandwidth_.peak * bandwidth_.scale); - lmm_variable_t var; + kernel::lmm::Variable* var; const_lmm_element_t elem = nullptr; const_lmm_element_t nextelem = nullptr; int numelem = 0; @@ -430,7 +430,7 @@ void NetworkCm02Link::setBandwidth(double value) void NetworkCm02Link::setLatency(double value) { double delta = value - latency_.peak; - lmm_variable_t var = nullptr; + kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; const_lmm_element_t nextelem = nullptr; int numelem = 0; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 1774956a6f..59da83b254 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -100,7 +100,7 @@ namespace simgrid { * Resource * ************/ - LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint) + LinkImpl::LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, kernel::lmm::Constraint* constraint) : Resource(model, name, constraint), piface_(this) { diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 4122c5512c..dab1d629c1 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -115,7 +115,7 @@ public: */ class LinkImpl : public simgrid::surf::Resource, public simgrid::surf::PropertyHolder { protected: - LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, lmm_constraint_t constraint); + LinkImpl(simgrid::surf::NetworkModel* model, const std::string& name, kernel::lmm::Constraint* constraint); ~LinkImpl() override; public: @@ -204,7 +204,7 @@ public: * @param failed [description] * @param var The lmm variable associated to this Action if it is part of a LMM component */ - NetworkAction(simgrid::surf::Model* model, double cost, bool failed, lmm_variable_t var) + NetworkAction(simgrid::surf::Model* model, double cost, bool failed, kernel::lmm::Variable* var) : simgrid::surf::Action(model, cost, failed, var){}; void setState(simgrid::surf::Action::State state) override; diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 8dcaf9b950..069dc37556 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -120,7 +120,7 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) } else { /* Need to check that none of the model has failed */ int i = 0; - lmm_constraint_t cnst = action.getVariable()->get_constraint(i); + kernel::lmm::Constraint* cnst = action.getVariable()->get_constraint(i); while (cnst != nullptr) { i++; void* constraint_id = cnst->get_id(); @@ -289,7 +289,7 @@ bool CpuL07::isUsed(){ /** @brief take into account changes of speed (either load or max) */ void CpuL07::onSpeedChange() { - lmm_variable_t var = nullptr; + kernel::lmm::Variable* var = nullptr; const_lmm_element_t elem = nullptr; model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale); @@ -358,7 +358,7 @@ void LinkL07::setBandwidth(double value) void LinkL07::setLatency(double value) { - lmm_variable_t var = nullptr; + kernel::lmm::Variable* var = nullptr; L07Action *action; const_lmm_element_t elem = nullptr; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index fa9aaa2a73..684d22a961 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -518,7 +518,7 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/) namespace simgrid { namespace surf { -Resource::Resource(Model* model, const std::string& name, lmm_constraint_t constraint) +Resource::Resource(Model* model, const std::string& name, kernel::lmm::Constraint* constraint) : name_(name), model_(model), constraint_(constraint) {} @@ -565,9 +565,9 @@ bool Resource::operator==(const Resource &other) const { return name_ == other.name_; } -lmm_constraint_t Resource::constraint() const +kernel::lmm::Constraint* Resource::constraint() const { - return constraint_; + return const_cast(constraint_); } } @@ -584,7 +584,7 @@ Action::Action(simgrid::surf::Model* model, double cost, bool failed) : Action(m { } -Action::Action(simgrid::surf::Model* model, double cost, bool failed, lmm_variable_t var) +Action::Action(simgrid::surf::Model* model, double cost, bool failed, kernel::lmm::Variable* var) : remains_(cost), start_(surf_get_clock()), cost_(cost), model_(model), variable_(var) { if (failed) diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index a2c9467c3b..6722a2d000 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -136,7 +136,7 @@ public: * @param failed If the action is impossible (e.g.: execute something on a switched off host) * @param var The lmm variable associated to this Action if it is part of a LMM component */ - Action(simgrid::surf::Model* model, double cost, bool failed, lmm_variable_t var); + Action(simgrid::surf::Model * model, double cost, bool failed, kernel::lmm::Variable* var); /** @brief Destructor */ virtual ~Action(); @@ -251,7 +251,7 @@ private: /* LMM */ double lastUpdate_ = 0; double lastValue_ = 0; - lmm_variable_t variable_ = nullptr; + kernel::lmm::Variable* variable_ = nullptr; Action::Type hat_ = Action::Type::NOTSET; boost::optional heapHandle_ = boost::none; @@ -261,8 +261,8 @@ public: void heapRemove(heap_type& heap); void heapUpdate(heap_type & heap, double key, Action::Type hat); void clearHeapHandle() { heapHandle_ = boost::none; } - lmm_variable_t getVariable() const { return variable_; } - void setVariable(lmm_variable_t var) { variable_ = var; } + kernel::lmm::Variable* getVariable() const { return variable_; } + void setVariable(kernel::lmm::Variable * var) { variable_ = var; } double getLastUpdate() const { return lastUpdate_; } void refreshLastUpdate() {lastUpdate_ = surf_get_clock();} double getLastValue() const { return lastValue_; } @@ -398,7 +398,7 @@ public: * @param name The name of the Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(Model * model, const std::string& name, lmm_constraint_t constraint); + Resource(Model * model, const std::string& name, kernel::lmm::Constraint* constraint); virtual ~Resource(); @@ -442,10 +442,10 @@ private: public: /* LMM */ /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */ - lmm_constraint_t constraint() const; + kernel::lmm::Constraint* constraint() const; protected: - const lmm_constraint_t constraint_ = nullptr; + const kernel::lmm::Constraint* constraint_ = nullptr; }; } diff --git a/teshsuite/surf/lmm_usage/lmm_usage.cpp b/teshsuite/surf/lmm_usage/lmm_usage.cpp index 47e16abedd..c4ea52e51f 100644 --- a/teshsuite/surf/lmm_usage/lmm_usage.cpp +++ b/teshsuite/surf/lmm_usage/lmm_usage.cpp @@ -1,6 +1,6 @@ /* A few tests for the maxmin library */ -/* Copyright (c) 2007-2017. The SimGrid Team. +/* Copyright (c) 2007-2018s. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -99,14 +99,14 @@ static void test1(method_t method) simgrid::kernel::lmm::func_reno_fpi); lmm_system_t Sys = new simgrid::kernel::lmm::System(true); - lmm_constraint_t L1 = Sys->constraint_new(nullptr, a); - lmm_constraint_t L2 = Sys->constraint_new(nullptr, b); - lmm_constraint_t L3 = Sys->constraint_new(nullptr, a); + simgrid::kernel::lmm::Constraint* L1 = Sys->constraint_new(nullptr, a); + simgrid::kernel::lmm::Constraint* L2 = Sys->constraint_new(nullptr, b); + simgrid::kernel::lmm::Constraint* L3 = Sys->constraint_new(nullptr, a); - lmm_variable_t R_1_2_3 = Sys->variable_new(nullptr, 1.0, -1.0, 3); - lmm_variable_t R_1 = Sys->variable_new(nullptr, 1.0, -1.0, 1); - lmm_variable_t R_2 = Sys->variable_new(nullptr, 1.0, -1.0, 1); - lmm_variable_t R_3 = Sys->variable_new(nullptr, 1.0, -1.0, 1); + simgrid::kernel::lmm::Variable* R_1_2_3 = Sys->variable_new(nullptr, 1.0, -1.0, 3); + simgrid::kernel::lmm::Variable* R_1 = Sys->variable_new(nullptr, 1.0, -1.0, 1); + simgrid::kernel::lmm::Variable* R_2 = Sys->variable_new(nullptr, 1.0, -1.0, 1); + simgrid::kernel::lmm::Variable* R_3 = Sys->variable_new(nullptr, 1.0, -1.0, 1); Sys->update_variable_weight(R_1_2_3, 1.0); Sys->update_variable_weight(R_1, 1.0); @@ -187,11 +187,11 @@ static void test2(method_t method) simgrid::kernel::lmm::func_reno_fpi); lmm_system_t Sys = new simgrid::kernel::lmm::System(true); - lmm_constraint_t CPU1 = Sys->constraint_new(nullptr, 200.0); - lmm_constraint_t CPU2 = Sys->constraint_new(nullptr, 100.0); + simgrid::kernel::lmm::Constraint* CPU1 = Sys->constraint_new(nullptr, 200.0); + simgrid::kernel::lmm::Constraint* CPU2 = Sys->constraint_new(nullptr, 100.0); - lmm_variable_t T1 = Sys->variable_new(nullptr, 1.0, -1.0, 1); - lmm_variable_t T2 = Sys->variable_new(nullptr, 1.0, -1.0, 1); + simgrid::kernel::lmm::Variable* T1 = Sys->variable_new(nullptr, 1.0, -1.0, 1); + simgrid::kernel::lmm::Variable* T2 = Sys->variable_new(nullptr, 1.0, -1.0, 1); Sys->update_variable_weight(T1, 1.0); Sys->update_variable_weight(T2, 1.0); @@ -262,12 +262,12 @@ static void test3(method_t method) lmm_system_t Sys = new simgrid::kernel::lmm::System(true); /* Creates the constraints */ - lmm_constraint_t* tmp_cnst = new lmm_constraint_t[15]; + simgrid::kernel::lmm::Constraint** tmp_cnst = new simgrid::kernel::lmm::Constraint*[15]; for (int i = 0; i < 15; i++) tmp_cnst[i] = Sys->constraint_new(nullptr, B[i]); /* Creates the variables */ - lmm_variable_t* tmp_var = new lmm_variable_t[16]; + simgrid::kernel::lmm::Variable** tmp_var = new simgrid::kernel::lmm::Variable*[16]; for (int j = 0; j < 16; j++) { tmp_var[j] = Sys->variable_new(nullptr, 1.0, -1.0, 15); Sys->update_variable_weight(tmp_var[j], 1.0); diff --git a/teshsuite/surf/maxmin_bench/maxmin_bench.cpp b/teshsuite/surf/maxmin_bench/maxmin_bench.cpp index 6490cf2d2b..108223882f 100644 --- a/teshsuite/surf/maxmin_bench/maxmin_bench.cpp +++ b/teshsuite/surf/maxmin_bench/maxmin_bench.cpp @@ -40,8 +40,8 @@ static unsigned int int_random(int max) static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limit, unsigned int pw_max_limit, float rate_no_limit, int max_share, int mode) { - lmm_constraint_t cnst[nb_cnst]; - lmm_variable_t var[nb_var]; + simgrid::kernel::lmm::Constraint* cnst[nb_cnst]; + simgrid::kernel::lmm::Variable* var[nb_var]; int used[nb_cnst]; lmm_system_t Sys = new simgrid::kernel::lmm::System(true); -- 2.20.1