/** @{ @ingroup SURF_lmm */
-/**
- * @brief Share a constraint
- * @param cnst The constraint to share
- */
-XBT_PUBLIC(void) lmm_constraint_shared(lmm_constraint_t cnst);
-
-/**
- * @brief Check if a constraint is shared (shared by default)
- * @param cnst The constraint to share
- * @return 1 if shared, 0 otherwise
- */
-XBT_PUBLIC(int) lmm_constraint_sharing_policy(lmm_constraint_t cnst);
-
-/**
- * @brief Get the usage of the constraint after the last lmm solve
- * @param cnst A constraint
- * @return The usage of the constraint
- */
-XBT_PUBLIC(double) lmm_constraint_get_usage(lmm_constraint_t cnst);
-
-XBT_PUBLIC(int) lmm_constraint_get_variable_amount(lmm_constraint_t cnst);
-
-/**
- * @brief Sets the concurrency limit for this constraint
- * @param cnst A constraint
- * @param concurrency_limit The concurrency limit to use for this constraint
- */
-XBT_PUBLIC(void) lmm_constraint_concurrency_limit_set(lmm_constraint_t cnst, int concurrency_limit);
-
-/**
- * @brief Gets the concurrency limit for this constraint
- * @param cnst A constraint
- * @return The concurrency limit used by this constraint
- */
-XBT_PUBLIC(int) lmm_constraint_concurrency_limit_get(lmm_constraint_t cnst);
-
-/**
- * @brief Reset the concurrency maximum for a given variable (we will update the maximum to reflect constraint
- * evolution).
- * @param cnst A constraint
-*/
-XBT_PUBLIC(void) lmm_constraint_concurrency_maximum_reset(lmm_constraint_t cnst);
-
-/**
- * @brief Get the concurrency maximum for a given variable (which reflects constraint evolution).
- * @param cnst A constraint
- * @return the maximum concurrency of the constraint
- */
-XBT_PUBLIC(int) lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst);
-
/**
* @brief Get the value of the variable after the last lmm solve
* @param var A variable
*/
XBT_PUBLIC(int) lmm_get_number_of_cnst_from_var(lmm_system_t sys, lmm_variable_t var);
-/**
- * @brief Get a var associated to a constraint
- * @details Get the first variable of the next variable of elem if elem is not NULL
- * @param sys The system associated to the variable (not used)
- * @param cnst A constraint
- * @param elem A element of constraint of the constraint or NULL
- * @return A variable associated to a constraint
- */
-XBT_PUBLIC(lmm_variable_t) lmm_get_var_from_cnst(lmm_system_t sys, lmm_constraint_t cnst, lmm_element_t* elem);
-
-/**
- * @brief Get a var associated to a constraint
- * @details Get the first variable of the next variable of elem if elem is not NULL
- * @param cnst A constraint
- * @param elem A element of constraint of the constraint or NULL
- * @param nextelem A element of constraint of the constraint or NULL, the one after elem
- * @param numelem parameter representing the number of elements to go
- *
- * @return A variable associated to a constraint
- */
-XBT_PUBLIC(lmm_variable_t)
-lmm_get_var_from_cnst_safe(lmm_system_t sys, lmm_constraint_t cnst, lmm_element_t* elem, lmm_element_t* nextelem,
- int* numelem);
-
-/**
- * @brief Get the data associated to a constraint
- * @param cnst A constraint
- * @return The data associated to the constraint
- */
-XBT_PUBLIC(void*) lmm_constraint_id(lmm_constraint_t cnst);
-
/**
* @brief Get the data associated to a variable
* @param var A variable
#include "simgrid/s4u/Link.hpp"
#include "simgrid/sg_config.h"
#include "simgrid/simix.hpp"
+#include "src/surf/maxmin_private.hpp"
#include "src/surf/network_interface.hpp"
#include "xbt/log.h"
double Link::getUsage()
{
- return lmm_constraint_get_usage(this->pimpl_->constraint());
+ return this->pimpl_->constraint()->get_usage();
}
void Link::turnOn()
/* iterate for all virtual machines */
for (s4u::VirtualMachine* const& ws_vm : vm::VirtualMachineImpl::allVms_) {
Cpu* cpu = ws_vm->pimpl_cpu;
- int active_tasks = lmm_constraint_get_variable_amount(cpu->constraint());
+ int active_tasks = cpu->constraint()->get_variable_amount();
/* The impact of the VM over its PM is the min between its vCPU amount and the amount of tasks it contains */
int impact = std::min(active_tasks, ws_vm->pimpl_vm_->coreAmount());
lmm_element_t elem = nullptr;
model()->getMaxminSystem()->update_constraint_bound(constraint(), coresAmount_ * speed_.scale * speed_.peak);
- while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ while ((var = constraint()->get_variable(&elem))) {
CpuCas01Action* action = static_cast<CpuCas01Action*>(lmm_variable_id(var));
model()->getMaxminSystem()->update_variable_bound(action->getVariable(),
turnOff();
- while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), cnst, &elem))) {
+ while ((var = cnst->get_variable(&elem))) {
Action *action = static_cast<Action*>(lmm_variable_id(var));
if (action->getState() == Action::State::running ||
CpuAction* action = static_cast<CpuAction*>(actionHeapPop());
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
if (TRACE_is_enabled()) {
- Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
+ Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)->get_id());
TRACE_surf_host_set_utilization(cpu->getCname(), action->getCategory(),
lmm_variable_getvalue(action->getVariable()), action->getLastUpdate(),
now - action->getLastUpdate());
CpuAction& action = static_cast<CpuAction&>(*it);
++it; // increment iterator here since the following calls to action.finish() may invalidate it
if (TRACE_is_enabled()) {
- Cpu* cpu =
- static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action.getVariable(), 0)));
-
+ Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getMaxminSystem(), action.getVariable(), 0)->get_id());
TRACE_surf_host_set_utilization(cpu->getCname(), action.getCategory(),
lmm_variable_getvalue(action.getVariable()), now - delta, delta);
TRACE_last_timestamp_to_dump = now - delta;
updateRemains(getLastValue() * delta);
if (TRACE_is_enabled()) {
- Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
+ Cpu* cpu = static_cast<Cpu*>(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)->get_id());
TRACE_surf_host_set_utilization(cpu->getCname(), getCategory(), getLastValue(), getLastUpdate(),
now - getLastUpdate());
}
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(lmm_constraint_id(lmm_get_cnst_from_var(sys, getVariable(), i)));
+ Resource* resource = static_cast<Resource*>(lmm_get_cnst_from_var(sys, getVariable(), i)->get_id());
Cpu* cpu = dynamic_cast<Cpu*>(resource);
if (cpu != nullptr)
retlist.push_back(cpu);
int sg_concurrency_limit = -1; /* Change this with --cfg=maxmin/concurrency-limit:VALUE */
static int Global_debug_id = 1;
-static int Global_const_debug_id = 1;
+int s_lmm_constraint_t::Global_debug_id = 1;
static int lmm_can_enable_var(lmm_variable_t var);
-static int lmm_concurrency_slack(lmm_constraint_t cnstr);
static int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var);
static inline int lmm_element_concurrency(lmm_element_t elem)
if(cnstr->concurrency_current > cnstr->concurrency_maximum)
cnstr->concurrency_maximum= cnstr->concurrency_current;
- xbt_assert(cnstr->concurrency_limit<0 || cnstr->concurrency_current<=cnstr->concurrency_limit,
+ xbt_assert(cnstr->get_concurrency_limit() < 0 || cnstr->concurrency_current <= cnstr->get_concurrency_limit(),
"Concurrency limit overflow!");
}
{
lmm_element_t elem = (lmm_element_t)elemIt;
// We should have staged variables only if concurrency is reached in some constraint
- xbt_assert(cnst->concurrency_limit < 0 || elem->variable->staged_weight == 0 ||
+ xbt_assert(cnst->get_concurrency_limit() < 0 || elem->variable->staged_weight == 0 ||
lmm_cnstrs_min_concurrency_slack(elem->variable) < elem->variable->concurrency_share,
"should not have staged variable!");
}
- xbt_assert(cnst->concurrency_limit < 0 || cnst->concurrency_limit >= concurrency, "concurrency check failed!");
+ xbt_assert(cnst->get_concurrency_limit() < 0 || cnst->get_concurrency_limit() >= concurrency,
+ "concurrency check failed!");
xbt_assert(cnst->concurrency_current == concurrency, "concurrency_current is out-of-date!");
}
delete cnst;
}
-lmm_constraint_t s_lmm_system_t::constraint_new(void* id, double bound_value)
+s_lmm_constraint_t::s_lmm_constraint_t(void* id_value, double bound_value)
{
- lmm_constraint_t cnst = nullptr;
s_lmm_element_t elem;
- cnst = new s_lmm_constraint_t();
- cnst->id = id;
- cnst->id_int = Global_const_debug_id++;
- xbt_swag_init(&(cnst->enabled_element_set), xbt_swag_offset(elem, enabled_element_set_hookup));
- xbt_swag_init(&(cnst->disabled_element_set), xbt_swag_offset(elem, disabled_element_set_hookup));
- xbt_swag_init(&(cnst->active_element_set), xbt_swag_offset(elem, active_element_set_hookup));
-
- cnst->bound = bound_value;
- cnst->concurrency_maximum=0;
- cnst->concurrency_current=0;
- cnst->concurrency_limit = sg_concurrency_limit;
- cnst->usage = 0;
- cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */
- insert_constraint(cnst);
-
- return cnst;
-}
-
-int lmm_constraint_concurrency_limit_get(lmm_constraint_t cnst)
-{
- return cnst->concurrency_limit;
-}
-
-void lmm_constraint_concurrency_limit_set(lmm_constraint_t cnst, int concurrency_limit)
-{
- xbt_assert(concurrency_limit<0 || cnst->concurrency_maximum<=concurrency_limit,
- "New concurrency limit should be larger than observed concurrency maximum. Maybe you want to call"
- " lmm_constraint_concurrency_maximum_reset() to reset the maximum?");
- cnst->concurrency_limit = concurrency_limit;
-}
-
-void lmm_constraint_concurrency_maximum_reset(lmm_constraint_t cnst)
-{
- cnst->concurrency_maximum = 0;
-}
-
-int lmm_constraint_concurrency_maximum_get(lmm_constraint_t cnst)
-{
- xbt_assert(cnst->concurrency_limit<0 || cnst->concurrency_maximum<=cnst->concurrency_limit,
- "Very bad: maximum observed concurrency is higher than limit. This is a bug of SURF, please report it.");
- return cnst->concurrency_maximum;
-}
-
-void lmm_constraint_shared(lmm_constraint_t cnst)
-{
- cnst->sharing_policy = 0;
+ id = id_value;
+ id_int = Global_debug_id++;
+ xbt_swag_init(&enabled_element_set, xbt_swag_offset(elem, enabled_element_set_hookup));
+ xbt_swag_init(&disabled_element_set, xbt_swag_offset(elem, disabled_element_set_hookup));
+ xbt_swag_init(&active_element_set, xbt_swag_offset(elem, active_element_set_hookup));
+
+ remaining = 0.0;
+ usage = 0.0;
+ bound = bound_value;
+ concurrency_limit = sg_concurrency_limit;
+ concurrency_current = 0;
+ concurrency_maximum = 0;
+ sharing_policy = 1; /* FIXME: don't hardcode the value */
+
+ lambda = 0.0;
+ new_lambda = 0.0;
+ cnst_light = nullptr;
}
-/** Return true if the constraint is shared, and false if it's FATPIPE */
-int lmm_constraint_sharing_policy(lmm_constraint_t cnst)
+lmm_constraint_t s_lmm_system_t::constraint_new(void* id, double bound_value)
{
- return (cnst->sharing_policy);
+ lmm_constraint_t cnst = new s_lmm_constraint_t(id, bound_value);
+ insert_constraint(cnst);
+ return cnst;
}
void* s_lmm_system_t::variable_mallocator_new_f()
}
//Check if we need to disable the variable
- if (var->sharing_weight > 0 && var->concurrency_share - current_share > lmm_concurrency_slack(cnst)) {
+ if (var->sharing_weight > 0 && var->concurrency_share - current_share > cnst->get_concurrency_slack()) {
double weight = var->sharing_weight;
disable_var(var);
for (s_lmm_element_t const& elem : var->cnsts)
//We need to check that increasing value of the element does not cross the concurrency limit
if (var->sharing_weight) {
- if (lmm_concurrency_slack(cnst) < lmm_element_concurrency(&elem)) {
+ if (cnst->get_concurrency_slack() < lmm_element_concurrency(&elem)) {
double weight = var->sharing_weight;
disable_var(var);
for (s_lmm_element_t const& elem2 : var->cnsts)
return (var->cnsts.size());
}
-lmm_variable_t lmm_get_var_from_cnst(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem)
+lmm_variable_t s_lmm_constraint_t::get_variable(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
// enabled_element_set is empty)
- *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set));
+ *elem = (lmm_element_t)xbt_swag_getFirst(&enabled_element_set);
if (*elem == nullptr)
- *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
+ *elem = (lmm_element_t)xbt_swag_getFirst(&disabled_element_set);
} else {
//elem is not null, so we carry on
- if(xbt_swag_belongs(*elem,&(cnst->enabled_element_set))){
+ if (xbt_swag_belongs(*elem, &enabled_element_set)) {
//Look at enabled_element_set, and jump to disabled_element_set when finished
- *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset);
+ *elem = (lmm_element_t)xbt_swag_getNext(*elem, enabled_element_set.offset);
if (*elem == nullptr)
- *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
+ *elem = (lmm_element_t)xbt_swag_getFirst(&disabled_element_set);
} else {
- *elem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
+ *elem = (lmm_element_t)xbt_swag_getNext(*elem, disabled_element_set.offset);
}
}
if (*elem)
//if we modify the swag between calls, normal version may loop forever
//this safe version ensures that we browse the swag elements only once
-lmm_variable_t lmm_get_var_from_cnst_safe(lmm_system_t /*sys*/, lmm_constraint_t cnst, lmm_element_t * elem,
- lmm_element_t * nextelem, int * numelem)
+lmm_variable_t s_lmm_constraint_t::get_variable_safe(lmm_element_t* elem, lmm_element_t* nextelem, int* numelem) const
{
if (*elem == nullptr) {
- *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->enabled_element_set));
- *numelem = xbt_swag_size(&(cnst->enabled_element_set))+xbt_swag_size(&(cnst->disabled_element_set))-1;
+ *elem = (lmm_element_t)xbt_swag_getFirst(&enabled_element_set);
+ *numelem = xbt_swag_size(&enabled_element_set) + xbt_swag_size(&disabled_element_set) - 1;
if (*elem == nullptr)
- *elem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
+ *elem = (lmm_element_t)xbt_swag_getFirst(&disabled_element_set);
}else{
*elem = *nextelem;
if(*numelem>0){
}
if (*elem){
//elem is not null, so we carry on
- if(xbt_swag_belongs(*elem,&(cnst->enabled_element_set))){
+ if (xbt_swag_belongs(*elem, &enabled_element_set)) {
//Look at enabled_element_set, and jump to disabled_element_set when finished
- *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->enabled_element_set.offset);
+ *nextelem = (lmm_element_t)xbt_swag_getNext(*elem, enabled_element_set.offset);
if (*nextelem == nullptr)
- *nextelem = (lmm_element_t) xbt_swag_getFirst(&(cnst->disabled_element_set));
+ *nextelem = (lmm_element_t)xbt_swag_getFirst(&disabled_element_set);
} else {
- *nextelem = (lmm_element_t) xbt_swag_getNext(*elem, cnst->disabled_element_set.offset);
+ *nextelem = (lmm_element_t)xbt_swag_getNext(*elem, disabled_element_set.offset);
}
return (*elem)->variable;
}else
return nullptr;
}
-void *lmm_constraint_id(lmm_constraint_t cnst)
-{
- return cnst->id;
-}
-
void *lmm_variable_id(lmm_variable_t var)
{
return var->id;
}
}
XBT_DEBUG("Constraint '%d' usage: %f remaining: %f concurrency: %i<=%i<=%i", cnst->id_int, cnst->usage,
- cnst->remaining,cnst->concurrency_current,cnst->concurrency_maximum,cnst->concurrency_limit);
+ cnst->remaining, cnst->concurrency_current, cnst->concurrency_maximum, cnst->get_concurrency_limit());
/* Saturated constraints update */
if(cnst->usage > 0) {
update_modified_set(var->cnsts[0].constraint);
}
-int lmm_concurrency_slack(lmm_constraint_t cnstr)
-{
- if (cnstr->concurrency_limit < 0)
- return std::numeric_limits<int>::max();
- return cnstr->concurrency_limit - cnstr->concurrency_current;
-}
-
/** \brief Measure the minimum concurrency slack across all constraints where the given var is involved */
int lmm_cnstrs_min_concurrency_slack(lmm_variable_t var)
{
int minslack = std::numeric_limits<int>::max();
for (s_lmm_element_t const& elem : var->cnsts) {
- int slack = lmm_concurrency_slack(elem.constraint);
+ int slack = elem.constraint->get_concurrency_slack();
if (slack < minslack) {
// This is only an optimization, to avoid looking at more constraints when slack is already zero
if (slack == 0)
*/
void s_lmm_system_t::on_disabled_var(lmm_constraint_t cnstr)
{
- if(cnstr->concurrency_limit<0)
+ if (cnstr->get_concurrency_limit() < 0)
return;
int numelem = xbt_swag_size(&(cnstr->disabled_element_set));
enable_var(elem->variable);
}
- xbt_assert(cnstr->concurrency_current<=cnstr->concurrency_limit,"Concurrency overflow!");
- if(cnstr->concurrency_current==cnstr->concurrency_limit)
+ xbt_assert(cnstr->concurrency_current <= cnstr->get_concurrency_limit(), "Concurrency overflow!");
+ if (cnstr->concurrency_current == cnstr->get_concurrency_limit())
break;
elem = nextelem;
*
* \param cnst the lmm_constraint_t associated to the resource
*/
-double lmm_constraint_get_usage(lmm_constraint_t cnst) {
+double s_lmm_constraint_t::get_usage() const
+{
double usage = 0.0;
- xbt_swag_t elem_list = &(cnst->enabled_element_set);
+ const_xbt_swag_t elem_list = &enabled_element_set;
void* _elem;
xbt_swag_foreach(_elem, elem_list)
{
lmm_element_t elem = (lmm_element_t)_elem;
if (elem->consumption_weight > 0) {
- if (cnst->sharing_policy)
+ if (sharing_policy)
usage += elem->consumption_weight * elem->variable->value;
else if (usage < elem->consumption_weight * elem->variable->value)
usage = std::max(usage, elem->consumption_weight * elem->variable->value);
return usage;
}
-int lmm_constraint_get_variable_amount(lmm_constraint_t cnst) {
+int s_lmm_constraint_t::get_variable_amount() const
+{
int usage = 0;
- xbt_swag_t elem_list = &(cnst->enabled_element_set);
+ const_xbt_swag_t elem_list = &enabled_element_set;
void *_elem;
xbt_swag_foreach(_elem, elem_list) {
* \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.
*
*/
-struct s_lmm_constraint_t {
- /* hookup to system */
- s_xbt_swag_hookup_t constraint_set_hookup;
- s_xbt_swag_hookup_t active_constraint_set_hookup;
- s_xbt_swag_hookup_t modified_constraint_set_hookup;
- s_xbt_swag_hookup_t saturated_constraint_set_hookup;
+class s_lmm_constraint_t {
+public:
+ s_lmm_constraint_t() = default;
+ s_lmm_constraint_t(void* id_value, double bound_value);
+
+ /** @brief Share a constraint. FIXME: name is misleading */
+ void shared() { sharing_policy = 0; }
+
+ /**
+ * @brief Check if a constraint is shared (shared by default)
+ * @return 1 if shared, 0 otherwise
+ */
+ int get_sharing_policy() const { return sharing_policy; }
+
+ /**
+ * @brief Get the usage of the constraint after the last lmm solve
+ * @return The usage of the constraint
+ */
+ double get_usage() const;
+ int get_variable_amount() const;
+
+ /**
+ * @brief Sets the concurrency limit for this constraint
+ * @param concurrency_limit The concurrency limit to use for this constraint
+ */
+ void set_concurrency_limit(int limit)
+ {
+ xbt_assert(limit < 0 || concurrency_maximum <= limit,
+ "New concurrency limit should be larger than observed concurrency maximum. Maybe you want to call"
+ " concurrency_maximum_reset() to reset the maximum?");
+ concurrency_limit = limit;
+ }
+
+ /**
+ * @brief Gets the concurrency limit for this constraint
+ * @return The concurrency limit used by this constraint
+ */
+ int get_concurrency_limit() const { return concurrency_limit; }
+
+ /**
+ * @brief Reset the concurrency maximum for a given variable (we will update the maximum to reflect constraint
+ * evolution).
+ */
+ void reset_concurrency_maximum() { concurrency_maximum = 0; }
+ /**
+ * @brief Get the concurrency maximum for a given variable (which reflects constraint evolution).
+ * @return the maximum concurrency of the constraint
+ */
+ 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.");
+ return concurrency_maximum;
+ }
+
+ int get_concurrency_slack() const
+ {
+ return concurrency_limit < 0 ? std::numeric_limits<int>::max() : concurrency_limit - concurrency_current;
+ }
+
+ /**
+ * @brief Get a var associated to a constraint
+ * @details Get the first variable of the next variable of elem if elem is not NULL
+ * @param elem A element of constraint of the constraint or NULL
+ * @return A variable associated to a constraint
+ */
+ lmm_variable_t get_variable(lmm_element_t* elem) const;
+
+ /**
+ * @brief Get a var associated to a constraint
+ * @details Get the first variable of the next variable of elem if elem is not NULL
+ * @param elem A element of constraint of the constraint or NULL
+ * @param nextelem A element of constraint of the constraint or NULL, the one after elem
+ * @param numelem parameter representing the number of elements to go
+ * @return A variable associated to a constraint
+ */
+ lmm_variable_t get_variable_safe(lmm_element_t* elem, lmm_element_t* nextelem, int* numelem) const;
+
+ /**
+ * @brief Get the data associated to a constraint
+ * @return The data associated to the constraint
+ */
+ void* get_id() const { return id; }
+
+ /* hookup to system */
+ s_xbt_swag_hookup_t constraint_set_hookup = {nullptr, nullptr};
+ s_xbt_swag_hookup_t active_constraint_set_hookup = {nullptr, nullptr};
+ s_xbt_swag_hookup_t modified_constraint_set_hookup = {nullptr, nullptr};
+ s_xbt_swag_hookup_t saturated_constraint_set_hookup = {nullptr, nullptr};
s_xbt_swag_t enabled_element_set; /* a list of lmm_element_t */
s_xbt_swag_t disabled_element_set; /* a list of lmm_element_t */
s_xbt_swag_t active_element_set; /* a list of lmm_element_t */
double remaining;
double usage;
double bound;
- int concurrency_limit; /* The maximum number of variables that may be enabled at any time (stage variables if necessary) */
//TODO MARTIN Check maximum value across resources at the end of simulation and give a warning is more than e.g. 500
int concurrency_current; /* The current concurrency */
int concurrency_maximum; /* The maximum number of (enabled and disabled) variables associated to the constraint at any given time (essentially for tracing)*/
int sharing_policy; /* see @e_surf_link_sharing_policy_t (0: FATPIPE, 1: SHARED, 2: FULLDUPLEX) */
- void *id;
int id_int;
double lambda;
double new_lambda;
lmm_constraint_light_t cnst_light;
+
+private:
+ static int Global_debug_id;
+ int concurrency_limit; /* The maximum number of variables that may be enabled at any time (stage variables if
+ * necessary) */
+ void* id;
};
/** @ingroup SURF_lmm
for (int i = 0; i < n; i++){
lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action->getVariable(), i);
- NetworkCm02Link *link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
+ NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
double value = lmm_variable_getvalue(action->getVariable())*
lmm_get_cnst_weight_from_var(maxminSystem_, action->getVariable(), i);
TRACE_surf_link_set_utilization(link->getCname(), action->getCategory(), value, action->getLastUpdate(),
for (int i = 0; i < n; i++) {
lmm_constraint_t constraint = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
- NetworkCm02Link* link = static_cast<NetworkCm02Link*>(lmm_constraint_id(constraint));
+ NetworkCm02Link* link = static_cast<NetworkCm02Link*>(constraint->get_id());
TRACE_surf_link_set_utilization(link->getCname(), action.getCategory(),
(lmm_variable_getvalue(action.getVariable()) *
lmm_get_cnst_weight_from_var(maxminSystem_, action.getVariable(), i)),
latency_.peak = latency;
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(constraint());
+ constraint()->shared();
simgrid::s4u::Link::onCreation(this->piface_);
}
double now = surf_get_clock();
turnOff();
- while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ while ((var = constraint()->get_variable(&elem))) {
Action *action = static_cast<Action*>( lmm_variable_id(var) );
if (action->getState() == Action::State::running ||
lmm_element_t elem = nullptr;
lmm_element_t nextelem = nullptr;
int numelem = 0;
- while ((var = lmm_get_var_from_cnst_safe(model()->getMaxminSystem(), constraint(), &elem, &nextelem, &numelem))) {
+ while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
action->weight_ += delta;
if (not action->isSuspended())
latency_.peak = value;
- while ((var = lmm_get_var_from_cnst_safe(model()->getMaxminSystem(), constraint(), &elem, &nextelem, &numelem))) {
+ while ((var = constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
NetworkCm02Action *action = static_cast<NetworkCm02Action*>(lmm_variable_id(var));
action->latCurrent_ += delta;
action->weight_ += delta;
int LinkImpl::sharingPolicy()
{
- return lmm_constraint_sharing_policy(constraint());
+ return constraint()->get_sharing_policy();
}
void LinkImpl::turnOn()
for (int i = 0; i < llen; i++) {
/* Beware of composite actions: ptasks put links and cpus together */
// extra pb: we cannot dynamic_cast from void*...
- Resource* resource = static_cast<Resource*>(lmm_constraint_id(lmm_get_cnst_from_var(sys, getVariable(), i)));
+ Resource* resource = static_cast<Resource*>(lmm_get_cnst_from_var(sys, getVariable(), i)->get_id());
LinkImpl* link = dynamic_cast<LinkImpl*>(resource);
if (link != nullptr)
retlist.push_back(link);
// We consider that the machine is then fully loaded. That's arbitrary but it avoids a NaN
cpu_load = 1;
else
- cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->constraint()) / current_speed;
+ cpu_load = host->pimpl_cpu->constraint()->get_usage() / current_speed;
/** Divide by the number of cores here **/
cpu_load /= host->pimpl_cpu->coreCount();
{
xbt_assert(HostEnergy::EXTENSION_ID.valid(),
"The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
- double cpu_load = lmm_constraint_get_usage(host->pimpl_cpu->constraint()) / host->getSpeed();
+ double cpu_load = host->pimpl_cpu->constraint()->get_usage() / host->getSpeed();
return host->extension<HostEnergy>()->getCurrentWattsValue(cpu_load);
}
}
: host(ptr)
, last_updated(surf_get_clock())
, last_reset(surf_get_clock())
- , current_flops(lmm_constraint_get_usage(host->pimpl_cpu->constraint()))
+ , current_flops(host->pimpl_cpu->constraint()->get_usage())
{
}
if (last_updated < now) {
/* Current flop per second computed by the cpu; current_flops = k * pstate_speed_in_flops, k \in {0, 1, ..., cores}
* number of active cores */
- current_flops = lmm_constraint_get_usage(host->pimpl_cpu->constraint());
+ current_flops = host->pimpl_cpu->constraint()->get_usage();
/* flops == pstate_speed * cores_being_currently_used */
computed_flops += (now - last_updated) * current_flops;
lmm_constraint_t cnst = lmm_get_cnst_from_var(maxminSystem_, action.getVariable(), i);
while (cnst != nullptr) {
i++;
- void *constraint_id = lmm_constraint_id(cnst);
+ void* constraint_id = cnst->get_id();
if (static_cast<simgrid::surf::Resource*>(constraint_id)->isOff()) {
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(Action::State::failed);
latency_.peak = latency;
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(constraint());
+ constraint()->shared();
s4u::Link::onCreation(this->piface_);
}
lmm_element_t elem = nullptr;
model()->getMaxminSystem()->update_constraint_bound(constraint(), speed_.peak * speed_.scale);
- while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ while ((var = constraint()->get_variable(&elem))) {
Action* action = static_cast<Action*>(lmm_variable_id(var));
model()->getMaxminSystem()->update_variable_bound(action->getVariable(), speed_.scale * speed_.peak);
lmm_element_t elem = nullptr;
latency_.peak = value;
- while ((var = lmm_get_var_from_cnst(model()->getMaxminSystem(), constraint(), &elem))) {
+ while ((var = constraint()->get_variable(&elem))) {
action = static_cast<L07Action*>(lmm_variable_id(var));
action->updateBound();
}
//Badly logarithmically random concurrency limit in [2^pw_base_limit+1,2^pw_base_limit+2^pw_max_limit]
l=(1<<pw_base_limit)+(1<<int_random(pw_max_limit));
- lmm_constraint_concurrency_limit_set(cnst[i],l );
+ cnst[i]->set_concurrency_limit(l);
}
for (int i = 0; i < nb_var; i++) {
fprintf(stderr,"Max concurrency:\n");
int l=0;
for (int i = 0; i < nb_cnst; i++) {
- int j=lmm_constraint_concurrency_maximum_get(cnst[i]);
- int k=lmm_constraint_concurrency_limit_get(cnst[i]);
+ int j = cnst[i]->get_concurrency_maximum();
+ int k = cnst[i]->get_concurrency_limit();
xbt_assert(k<0 || j<=k);
if(j>l)
l=j;
fprintf(stderr,"(%i):%i/%i ",i,j,k);
- lmm_constraint_concurrency_maximum_reset(cnst[i]);
- xbt_assert(not lmm_constraint_concurrency_maximum_get(cnst[i]));
+ cnst[i]->reset_concurrency_maximum();
+ xbt_assert(not cnst[i]->get_concurrency_maximum());
if(i%10==9)
fprintf(stderr,"\n");
}