<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<?fileVersion 5.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage2">
+<?fileVersion 5.0.0?>
+
+<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage2">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="cdt.managedbuild.toolchain.gnu.base.1053321950">
<storageModule externalCElementFile="cdt.managedbuild.toolchain.gnu.base.1053321950_org.eclipse.cdt.core.settings" id="cdt.managedbuild.toolchain.gnu.base.1053321950" name="Default"/>
<resource resourceType="PROJECT" workspacePath="/simgrid"/>
</configuration>
</storageModule>
+ <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
p_cpuRunningActionSetThatDoesNotNeedBeingChecked =
xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
- if (p_updateMechanism == UM_LAZY) {
+ if (getUpdateMechanism() == UM_LAZY) {
shareResources = &CpuCas01Model::shareResourcesLazy;
updateActionsState = &CpuCas01Model::updateActionsStateLazy;
- } else if (p_updateMechanism == UM_FULL) {
+ } else if (getUpdateMechanism() == UM_FULL) {
shareResources = &CpuCas01Model::shareResourcesFull;
updateActionsState = &CpuCas01Model::updateActionsStateFull;
} else
p_maxminSystem = lmm_system_new(m_selectiveUpdate);
}
- if (p_updateMechanism == UM_LAZY) {
+ if (getUpdateMechanism() == UM_LAZY) {
p_actionHeap = xbt_heap_new(8, NULL);
xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
p_modifiedSet = xbt_swag_new(xbt_swag_offset(*actionlmm, p_actionListHookup));
double CpuCas01Model::shareResourcesFull(double /*now*/)
{
- return Model::shareResourcesMaxMin(p_runningActionSet,
+ return Model::shareResourcesMaxMin(getRunningActionSet(),
p_maxminSystem, lmm_solve);
}
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
- host->p_stateEvent =
- tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
+ host->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, static_cast<ResourcePtr>(host));
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
/************
* Resource *
************/
-CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak,
+CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model_, const char *name, xbt_dynar_t powerPeak,
int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
xbt_dict_t properties)
-: Resource(model, name, properties)
-, CpuLmm(model, name, properties, core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
+: Resource(model_, name, properties)
+, CpuLmm(lmm_constraint_new(getModel()->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
+ core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
p_powerEvent = NULL;
p_powerPeakList = powerPeak;
m_pstate = pstate;
XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
m_core = core;
- p_stateCurrent = stateInitial;
+ m_stateCurrent = stateInitial;
if (powerTrace)
p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
if (stateTrace)
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
-
- p_constraint = lmm_constraint_new(p_model->p_maxminSystem, this, m_core * m_powerScale * m_powerPeak);
}
CpuCas01Lmm::~CpuCas01Lmm(){
bool CpuCas01Lmm::isUsed()
{
- return lmm_constraint_used(p_model->p_maxminSystem, p_constraint);
+ return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
}
void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, double date)
xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
m_powerScale = value;
- lmm_update_constraint_bound(surf_cpu_model_pm->p_maxminSystem, p_constraint,
+ lmm_update_constraint_bound(surf_cpu_model_pm->getMaxminSystem(), constraint(),
m_core * m_powerScale *
m_powerPeak);
#ifdef HAVE_TRACING
- TRACE_surf_host_set_power(date, m_name,
+ TRACE_surf_host_set_power(date, getName(),
m_core * m_powerScale *
m_powerPeak);
#endif
while ((var = lmm_get_var_from_cnst
- (surf_cpu_model_pm->p_maxminSystem, p_constraint, &elem))) {
+ (surf_cpu_model_pm->getMaxminSystem(), constraint(), &elem))) {
CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
- lmm_update_variable_bound(surf_cpu_model_pm->p_maxminSystem,
- action->p_variable,
+ lmm_update_variable_bound(surf_cpu_model_pm->getMaxminSystem(),
+ action->getVariable(),
m_powerScale * m_powerPeak);
}
if (tmgr_trace_event_free(event_type))
xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
if (value > 0) {
- if(p_stateCurrent == SURF_RESOURCE_OFF)
- xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
- p_stateCurrent = SURF_RESOURCE_ON;
+ if(m_stateCurrent == SURF_RESOURCE_OFF)
+ xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
+ m_stateCurrent = SURF_RESOURCE_ON;
} else {
- lmm_constraint_t cnst = p_constraint;
+ lmm_constraint_t cnst = constraint();
- p_stateCurrent = SURF_RESOURCE_OFF;
+ m_stateCurrent = SURF_RESOURCE_OFF;
- while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->p_maxminSystem, cnst, &elem))) {
+ while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->getMaxminSystem(), cnst, &elem))) {
ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
if (action->getState() == SURF_ACTION_RUNNING ||
action->getState() == SURF_ACTION_READY ||
action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
- action->m_finish = date;
+ action->setFinishTime(date);
action->setState(SURF_ACTION_FAILED);
}
}
return;
}
-ActionPtr CpuCas01Lmm::execute(double size)
+CpuActionPtr CpuCas01Lmm::execute(double size)
{
- XBT_IN("(%s,%g)", m_name, size);
- CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, size, p_stateCurrent != SURF_RESOURCE_ON);
-
- action->m_suspended = 0; /* Should be useless because of the
- calloc but it seems to help valgrind... */
+ XBT_IN("(%s,%g)", getName(), size);
+ CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, size, m_stateCurrent != SURF_RESOURCE_ON,
+ m_powerScale * m_powerPeak, constraint());
- action->p_variable =
- lmm_variable_new(surf_cpu_model_pm->p_maxminSystem, static_cast<ActionLmmPtr>(action),
- action->m_priority,
- m_powerScale * m_powerPeak, 1);
- if (surf_cpu_model_pm->p_updateMechanism == UM_LAZY) {
- action->m_indexHeap = -1;
- action->m_lastUpdate = surf_get_clock();
- action->m_lastValue = 0.0;
- }
- lmm_expand(surf_cpu_model_pm->p_maxminSystem, p_constraint,
- action->p_variable, 1.0);
XBT_OUT();
return action;
}
-ActionPtr CpuCas01Lmm::sleep(double duration)
+CpuActionPtr CpuCas01Lmm::sleep(double duration)
{
if (duration > 0)
duration = MAX(duration, MAXMIN_PRECISION);
- XBT_IN("(%s,%g)", m_name, duration);
- CpuCas01ActionLmmPtr action = dynamic_cast<CpuCas01ActionLmmPtr>(execute(1.0));
+ XBT_IN("(%s,%g)", getName(), duration);
+ CpuCas01ActionLmmPtr action = new CpuCas01ActionLmm(surf_cpu_model_pm, 1.0, m_stateCurrent != SURF_RESOURCE_ON,
+ m_powerScale * m_powerPeak, constraint());
+
// FIXME: sleep variables should not consume 1.0 in lmm_expand
action->m_maxDuration = duration;
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention
is used to speed up update_resource_state */
- xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
- action->p_stateSet = static_cast<CpuCas01ModelPtr>(p_model)->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
- xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(action), action->getStateSet());
+ action->p_stateSet = static_cast<CpuCas01ModelPtr>(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
+ xbt_swag_insert(static_cast<ActionPtr>(action), action->getStateSet());
}
- lmm_update_variable_weight(surf_cpu_model_pm->p_maxminSystem,
- action->p_variable, 0.0);
- if (surf_cpu_model_pm->p_updateMechanism == UM_LAZY) { // remove action from the heap
- action->heapRemove(surf_cpu_model_pm->p_actionHeap);
+ lmm_update_variable_weight(surf_cpu_model_pm->getMaxminSystem(),
+ action->getVariable(), 0.0);
+ if (surf_cpu_model_pm->getUpdateMechanism() == UM_LAZY) { // remove action from the heap
+ action->heapRemove(surf_cpu_model_pm->getActionHeap());
// this is necessary for a variable with weight 0 since such
// variables are ignored in lmm and we need to set its max_duration
// correctly at the next call to share_resources
- xbt_swag_insert_at_head(static_cast<ActionLmmPtr>(action), surf_cpu_model_pm->p_modifiedSet);
+ xbt_swag_insert_at_head(static_cast<ActionLmmPtr>(action), surf_cpu_model_pm->getModifiedSet());
}
XBT_OUT();
xbt_dynar_t current_power_values;
double min_power, max_power;
- if (m_properties == NULL)
+ if (getProperties() == NULL)
return NULL;
- char* all_power_values_str = (char*)xbt_dict_get_or_null(m_properties, "power_per_state");
+ char* all_power_values_str = (char*)xbt_dict_get_or_null(getProperties(), "power_per_state");
if (all_power_values_str == NULL)
return NULL;
current_power_values = xbt_str_split(xbt_dynar_get_as(all_power_values, i, char*), ":");
xbt_assert(xbt_dynar_length(current_power_values) > 1,
"Power properties incorrectly defined - could not retrieve min and max power values for host %s",
- m_name);
+ getName());
/* min_power corresponds to the idle power (cpu load = 0) */
/* max_power is the power consumed at 100% cpu load */
if (power_range_list == NULL)
{
- XBT_DEBUG("No power range properties specified for host %s", m_name);
+ XBT_DEBUG("No power range properties specified for host %s", getName());
return 0;
}
xbt_assert(xbt_dynar_length(power_range_list) == xbt_dynar_length(p_powerPeakList),
"The number of power ranges in the properties does not match the number of pstates for host %s",
- m_name);
+ getName());
/* retrieve the power values associated with the current pstate */
xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, m_pstate, xbt_dynar_t);
* Action *
**********/
+CpuCas01ActionLmm::CpuCas01ActionLmm(ModelPtr model_, double cost, bool failed, double power, lmm_constraint_t constraint)
+ : Action(model_, cost, failed)
+ , CpuActionLmm(lmm_variable_new(getModel()->getMaxminSystem(), static_cast<ActionLmmPtr>(this),
+ m_priority,
+ power, 1))
+{
+ m_suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
+
+ if (getModel()->getUpdateMechanism() == UM_LAZY) {
+ m_indexHeap = -1;
+ m_lastUpdate = surf_get_clock();
+ m_lastValue = 0.0;
+ }
+ lmm_expand(getModel()->getMaxminSystem(), constraint, getVariable(), 1.0);
+}
+
+
/**
* Update the CPU total energy for a finished action
*
void CpuCas01ActionLmm::updateEnergy()
{
CpuCas01LmmPtr cpu = static_cast<CpuCas01LmmPtr>(lmm_constraint_id(lmm_get_cnst_from_var
- (p_model->p_maxminSystem,
- p_variable, 0)));
+ (getModel()->getMaxminSystem(),
+ getVariable(), 0)));
if(cpu->p_energy->last_updated < surf_get_clock()) {
- double load = lmm_constraint_get_usage(cpu->p_constraint) / cpu->m_powerPeak;
+ double load = lmm_constraint_get_usage(cpu->constraint()) / cpu->m_powerPeak;
cpu->updateEnergy(load);
}
}
} s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
class CpuCas01Lmm : public CpuLmm {
+public://FIXME:
+ tmgr_trace_event_t p_stateEvent;
public:
CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
xbt_dict_t properties) ;
~CpuCas01Lmm();
void updateState(tmgr_trace_event_t event_type, double value, double date);
- ActionPtr execute(double size);
- ActionPtr sleep(double duration);
+ CpuActionPtr execute(double size);
+ CpuActionPtr sleep(double duration);
xbt_dynar_t getWattsRangeList();
double getCurrentWattsValue(double cpu_load);
bool isUsed();
tmgr_trace_event_t p_powerEvent;
-
xbt_dynar_t p_powerPeakList; /*< List of supported CPU capacities */
int m_pstate; /*< Current pstate (index in the power_peak_list)*/
energy_cpu_cas01_t p_energy; /*< Structure with energy-consumption data */
* Action *
**********/
class CpuCas01ActionLmm: public CpuActionLmm {
+ friend CpuActionPtr CpuCas01Lmm::execute(double size);
+ friend CpuActionPtr CpuCas01Lmm::sleep(double duration);
public:
CpuCas01ActionLmm() {};
- CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
+ CpuCas01ActionLmm(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
+
~CpuCas01ActionLmm() {};
void updateEnergy();
};
{
void *_action;
CpuActionLmmPtr action;
- while ((xbt_heap_size(p_actionHeap) > 0)
- && (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
- action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionLmmPtr>(xbt_heap_pop(p_actionHeap)));
+ while ((xbt_heap_size(getActionHeap()) > 0)
+ && (double_equals(xbt_heap_maxkey(getActionHeap()), now))) {
+ action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionLmmPtr>(xbt_heap_pop(getActionHeap())));
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
- CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_maxminSystem, action->p_variable, 0));
- TRACE_surf_host_set_utilization(cpu->m_name, action->p_category,
- lmm_variable_getvalue(action->p_variable),
- action->m_lastUpdate,
- now - action->m_lastUpdate);
+ CpuPtr cpu = static_cast<CpuPtr>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
+ TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
+ lmm_variable_getvalue(action->getVariable()),
+ action->getLastUpdate(),
+ now - action->getLastUpdate());
}
#endif
- action->m_finish = surf_get_clock();
+ action->finish();
XBT_CDEBUG(surf_kernel, "Action %p finished", action);
action->updateEnergy();
/* set the remains to 0 due to precision problems when updating the remaining amount */
- action->m_remains = 0;
+ action->setRemains(0);
action->setState(SURF_ACTION_DONE);
- action->heapRemove(p_actionHeap); //FIXME: strange call since action was already popped
+ action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
}
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
//defining the last timestamp that we can safely dump to trace file
//without losing the event ascending order (considering all CPU's)
double smaller = -1;
- xbt_swag_foreach(_action, p_runningActionSet) {
+ xbt_swag_t actionSet = getRunningActionSet();
+ xbt_swag_foreach(_action, actionSet) {
action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
if (smaller < 0) {
- smaller = action->m_lastUpdate;
+ smaller = action->getLastUpdate();
continue;
}
- if (action->m_lastUpdate < smaller) {
- smaller = action->m_lastUpdate;
+ if (action->getLastUpdate() < smaller) {
+ smaller = action->getLastUpdate();
}
}
if (smaller > 0) {
{
void *_action, *_next_action;
CpuActionLmmPtr action = NULL;
- xbt_swag_t running_actions = p_runningActionSet;
+ xbt_swag_t running_actions = getRunningActionSet();
xbt_swag_foreach_safe(_action, _next_action, running_actions) {
action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionPtr>(_action));
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var
- (p_maxminSystem, action->p_variable, 0));
+ (getMaxminSystem(), action->getVariable(), 0));
- TRACE_surf_host_set_utilization(x->m_name,
- action->p_category,
- lmm_variable_getvalue(action->p_variable),
+ TRACE_surf_host_set_utilization(x->getName(),
+ action->getCategory(),
+ lmm_variable_getvalue(action->getVariable()),
now - delta,
delta);
TRACE_last_timestamp_to_dump = now - delta;
}
#endif
- double_update(&(action->m_remains),
- lmm_variable_getvalue(action->p_variable) * delta);
+ action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
- if (action->m_maxDuration != NO_MAX_DURATION)
- double_update(&(action->m_maxDuration), delta);
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ action->updateMaxDuration(delta);
- if ((action->m_remains <= 0) &&
- (lmm_get_variable_weight(action->p_variable) > 0)) {
- action->m_finish = surf_get_clock();
+ if ((action->getRemains() <= 0) &&
+ (lmm_get_variable_weight(action->getVariable()) > 0)) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
-
- } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
- (action->m_maxDuration <= 0)) {
- action->m_finish = surf_get_clock();
+ } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+ (action->getMaxDuration() <= 0)) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
}
action->updateEnergy();
* Resource *
************/
+Cpu::Cpu(int core, double powerPeak, double powerScale)
+ : m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
+{}
+
double Cpu::getSpeed(double load)
{
return load * m_powerPeak;
return m_core;
}
-CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
-: ResourceLmm(), Cpu(model, name, properties, core, powerPeak, powerScale) {
+CpuLmm::CpuLmm(lmm_constraint_t constraint)
+: ResourceLmm(constraint), p_constraintCore(NULL), p_constraintCoreId(NULL)
+{}
+
+CpuLmm::CpuLmm(lmm_constraint_t constraint, int core, double powerPeak, double powerScale)
+ : ResourceLmm(constraint)
+ , Cpu(core, powerPeak, powerScale)
+{
/* At now, we assume that a VM does not have a multicore CPU. */
if (core > 1)
- xbt_assert(model == surf_cpu_model_pm);
+ xbt_assert(getModel() == surf_cpu_model_pm);
+
p_constraintCore = xbt_new(lmm_constraint_t, core);
p_constraintCoreId = xbt_new(void*, core);
int i;
for (i = 0; i < core; i++) {
/* just for a unique id, never used as a string. */
- p_constraintCoreId[i] = bprintf("%s:%i", name, i);
- p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, p_constraintCoreId[i], m_powerScale * m_powerPeak);
+ p_constraintCoreId[i] = bprintf("%s:%i", getName(), i);
+ p_constraintCore[i] = lmm_constraint_new(getModel()->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
}
}
{
double delta = 0.0;
- xbt_assert(p_stateSet == p_model->p_runningActionSet,
+ xbt_assert(getStateSet() == getModel()->getRunningActionSet(),
"You're updating an action that is not running.");
/* bogus priority, skip it */
- xbt_assert(m_priority > 0,
+ xbt_assert(getPriority() > 0,
"You're updating an action that seems suspended.");
delta = now - m_lastUpdate;
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
- CpuPtr cpu = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0));
- TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+ CpuPtr cpu = static_cast<CpuPtr>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
+ TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
}
#endif
XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %lf", this, m_remains);
}
m_lastUpdate = now;
- m_lastValue = lmm_variable_getvalue(p_variable);
+ m_lastValue = lmm_variable_getvalue(getVariable());
}
void CpuActionLmm::setBound(double bound)
{
XBT_IN("(%p,%g)", this, bound);
m_bound = bound;
- lmm_update_variable_bound(p_model->p_maxminSystem, p_variable, bound);
+ lmm_update_variable_bound(getModel()->getMaxminSystem(), getVariable(), bound);
- if (p_model->p_updateMechanism == UM_LAZY)
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(getModel()->getActionHeap());
XBT_OUT();
}
*/
void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
{
- lmm_variable_t var_obj = p_variable;
+ lmm_variable_t var_obj = getVariable();
CpuLmmPtr cpu = reinterpret_cast<CpuLmmPtr>(_cpu);
XBT_IN("(%p,%lx)", this, mask);
}
for (int i = 0; i < cpu->m_core; i++) {
- XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i, cpu->m_name);
- lmm_shrink(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj);
+ XBT_DEBUG("clear affinity %p to cpu-%d@%s", this, i, cpu->getName());
+ lmm_shrink(cpu->getModel()->getMaxminSystem(), cpu->p_constraintCore[i], var_obj);
unsigned long has_affinity = (1UL << i) & mask;
if (has_affinity) {
* accept affinity settings on a future host. We might be able to assign
* zero to elem->value to maintain such inactive affinity settings in the
* system. But, this will make the system complex. */
- XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->m_name);
- lmm_expand(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i], var_obj, 1.0);
+ XBT_DEBUG("set affinity %p to cpu-%d@%s", this, i, cpu->getName());
+ lmm_expand(cpu->getModel()->getMaxminSystem(), cpu->p_constraintCore[i], var_obj, 1.0);
}
}
- if (cpu->p_model->p_updateMechanism == UM_LAZY) {
+ if (cpu->getModel()->getUpdateMechanism() == UM_LAZY) {
/* FIXME (hypervisor): Do we need to do something for the LAZY mode? */
}
*********/
class CpuModel : public Model {
public:
- CpuModel(string name) : Model(name) {};
+ CpuModel(const char *name) : Model(name) {};
CpuPtr createResource(string name);
void updateActionsStateLazy(double now, double delta);
void updateActionsStateFull(double now, double delta);
class Cpu : virtual public Resource {
public:
Cpu(){};
- Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
- : Resource(model, name, properties), m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
- {};
- virtual ActionPtr execute(double size)=0;
- virtual ActionPtr sleep(double duration)=0;
+ Cpu(int core, double powerPeak, double powerScale);
+ virtual CpuActionPtr execute(double size)=0;
+ virtual CpuActionPtr sleep(double duration)=0;
virtual int getCore();
virtual double getSpeed(double load);
virtual double getAvailableSpeed();
class CpuLmm : public ResourceLmm, public Cpu {
public:
- CpuLmm() : p_constraintCore(NULL), p_constraintCoreId(NULL) {};
- CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale);
+ CpuLmm(lmm_constraint_t constraint);
+ CpuLmm(lmm_constraint_t constraint, int core, double powerPeak, double powerScale);
~CpuLmm();
/* Note (hypervisor): */
lmm_constraint_t *p_constraintCore;
public:
CpuAction(){};
CpuAction(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed) {};
+ : Action(model, cost, failed) {};//FIXME:REMOVE
virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
virtual void setBound(double bound)=0;
};
class CpuActionLmm : public ActionLmm, public CpuAction {
public:
CpuActionLmm(){};
- CpuActionLmm(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed), ActionLmm(model, cost, failed), CpuAction(model, cost, failed) {};
+ CpuActionLmm(lmm_variable_t var)
+ : ActionLmm(var), CpuAction() {};
void updateRemainingLazy(double now);
virtual void updateEnergy()=0;
void setAffinity(CpuPtr cpu, unsigned long mask);
/* iterates over modified cpus to update share resources */
xbt_swag_foreach_safe(_cpu, _cpu_next, p_modifiedCpu) {
- static_cast<CpuTiPtr>(_cpu)->updateActionFinishDate(now);
+ static_cast<CpuTiPtr>(_cpu)->updateActionsFinishTime(now);
}
/* get the min next event if heap not empty */
if (xbt_heap_size(p_tiActionHeap) > 0)
&& (xbt_heap_maxkey(p_tiActionHeap) <= now)) {
CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(p_tiActionHeap);
XBT_DEBUG("Action %p: finish", action);
- action->m_finish = surf_get_clock();
+ action->finish();
/* set the remains to 0 due to precision problems when updating the remaining amount */
- action->m_remains = 0;
+ action->setRemains(0);
action->setState(SURF_ACTION_DONE);
/* update remaining amount of all actions */
action->p_cpu->updateRemainingAmount(surf_get_clock());
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
xbt_dict_t properties)
: Resource(model, name, properties)
-, Cpu(model, name, properties, core, 0, powerScale) {
+, Cpu(core, 0, powerScale) {
p_powerEvent = NULL;
- p_stateCurrent = stateInitial;
+ m_stateCurrent = stateInitial;
m_powerScale = powerScale;
m_core = core;
tmgr_trace_t empty_trace;
value, date);
/* update remaining of actions and put in modified cpu swag */
updateRemainingAmount(date);
- xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
power_trace = p_availTrace->p_powerTrace;
xbt_dynar_get_cpy(power_trace->s_list.event_list,
} else if (event_type == p_stateEvent) {
if (value > 0) {
- if(p_stateCurrent == SURF_RESOURCE_OFF)
- xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
- p_stateCurrent = SURF_RESOURCE_ON;
+ if(m_stateCurrent == SURF_RESOURCE_OFF)
+ xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
+ m_stateCurrent = SURF_RESOURCE_ON;
} else {
- p_stateCurrent = SURF_RESOURCE_OFF;
+ m_stateCurrent = SURF_RESOURCE_OFF;
/* put all action running on cpu to failed */
xbt_swag_foreach(_action, p_actionSet) {
if (action->getState() == SURF_ACTION_RUNNING
|| action->getState() == SURF_ACTION_READY
|| action->getState() == SURF_ACTION_NOT_IN_THE_SYSTEM) {
- action->m_finish = date;
+ action->setFinishTime(date);
action->setState(SURF_ACTION_FAILED);
if (action->m_indexHeap >= 0) {
CpuTiActionPtr heap_act = (CpuTiActionPtr)
- xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
+ xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action->m_indexHeap);
if (heap_act != action)
DIE_IMPOSSIBLE;
}
return;
}
-void CpuTi::updateActionFinishDate(double now)
+void CpuTi::updateActionsFinishTime(double now)
{
void *_action;
CpuTiActionPtr action;
xbt_swag_foreach(_action, p_actionSet) {
action = static_cast<CpuTiActionPtr>(_action);
/* action not running, skip it */
- if (action->p_stateSet !=
- surf_cpu_model_pm->p_runningActionSet)
+ if (action->getStateSet() !=
+ surf_cpu_model_pm->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action->m_priority <= 0)
+ if (action->getPriority() <= 0)
continue;
/* action suspended, skip it */
if (action->m_suspended != 0)
continue;
- sum_priority += 1.0 / action->m_priority;
+ sum_priority += 1.0 / action->getPriority();
}
m_sumPriority = sum_priority;
action = static_cast<CpuTiActionPtr>(_action);
min_finish = -1;
/* action not running, skip it */
- if (action->p_stateSet !=
- surf_cpu_model_pm->p_runningActionSet)
+ if (action->getStateSet() !=
+ surf_cpu_model_pm->getRunningActionSet())
continue;
/* verify if the action is really running on cpu */
- if (action->m_suspended == 0 && action->m_priority > 0) {
+ if (action->m_suspended == 0 && action->getPriority() > 0) {
/* total area needed to finish the action. Used in trace integration */
total_area =
- (action->m_remains) * sum_priority *
- action->m_priority;
+ (action->getRemains()) * sum_priority *
+ action->getPriority();
total_area /= m_powerPeak;
- action->m_finish = p_availTrace->solve(now, total_area);
+ action->setFinishTime(p_availTrace->solve(now, total_area));
/* verify which event will happen before (max_duration or finish time) */
- if (action->m_maxDuration != NO_MAX_DURATION &&
- action->m_start + action->m_maxDuration < action->m_finish)
- min_finish = action->m_start + action->m_maxDuration;
+ if (action->getMaxDuration() != NO_MAX_DURATION &&
+ action->getStartTime() + action->getMaxDuration() < action->m_finish)
+ min_finish = action->getStartTime() + action->getMaxDuration();
else
min_finish = action->m_finish;
} else {
/* put the max duration time on heap */
- if (action->m_maxDuration != NO_MAX_DURATION)
- min_finish = action->m_start + action->m_maxDuration;
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ min_finish = action->getStartTime() + action->getMaxDuration();
}
/* add in action heap */
XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap);
if (action->m_indexHeap >= 0) {
CpuTiActionPtr heap_act = (CpuTiActionPtr)
- xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
+ xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action->m_indexHeap);
if (heap_act != action)
DIE_IMPOSSIBLE;
}
if (min_finish != NO_MAX_DURATION)
- xbt_heap_push(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action, min_finish);
+ xbt_heap_push(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, action, min_finish);
XBT_DEBUG
("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
- m_name, action, action->m_start,
+ getName(), action, action->getStartTime(),
action->m_finish,
- action->m_maxDuration);
+ action->getMaxDuration());
}
/* remove from modified cpu */
- xbt_swag_remove(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_swag_remove(this, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
}
bool CpuTi::isUsed()
xbt_swag_foreach(_action, p_actionSet) {
action = static_cast<CpuTiActionPtr>(_action);
/* action not running, skip it */
- if (action->p_stateSet !=
- getModel()->p_runningActionSet)
+ if (action->getStateSet() !=
+ getModel()->getRunningActionSet())
continue;
/* bogus priority, skip it */
- if (action->m_priority <= 0)
+ if (action->getPriority() <= 0)
continue;
/* action suspended, skip it */
continue;
/* action don't need update */
- if (action->m_start >= now)
+ if (action->getStartTime() >= now)
continue;
/* skip action that are finishing now */
continue;
/* update remaining */
- double_update(&(action->m_remains),
- area_total / (m_sumPriority *
- action->m_priority));
+ action->updateRemains(area_total / (m_sumPriority * action->getPriority()));
XBT_DEBUG("Update remaining action(%p) remaining %f", action,
action->m_remains);
}
CpuActionPtr CpuTi::execute(double size)
{
- return _execute(size);
-}
-
-CpuTiActionPtr CpuTi::_execute(double size)
-{
- XBT_IN("(%s,%g)", m_name, size);
- CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(p_model), size, p_stateCurrent != SURF_RESOURCE_ON);
-
- action->p_cpu = this;
- action->m_indexHeap = -1;
-
- xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ XBT_IN("(%s,%g)", getName(), size);
+ CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), size, m_stateCurrent != SURF_RESOURCE_ON, this);
xbt_swag_insert(action, p_actionSet);
- action->m_suspended = 0; /* Should be useless because of the
- » calloc but it seems to help valgrind... */
-
XBT_OUT();
return action;
}
if (duration > 0)
duration = MAX(duration, MAXMIN_PRECISION);
- XBT_IN("(%s,%g)", m_name, duration);
- CpuTiActionPtr action = _execute(1.0);
+ XBT_IN("(%s,%g)", getName(), duration);
+ CpuTiActionPtr action = new CpuTiAction(static_cast<CpuTiModelPtr>(getModel()), 1.0, m_stateCurrent != SURF_RESOURCE_ON, this);
+
action->m_maxDuration = duration;
action->m_suspended = 2;
if (duration == NO_MAX_DURATION) {
- /* Move to the *end* of the corresponding action set. This convention
- is used to speed up update_resource_state */
- xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
- action->p_stateSet = reinterpret_cast<CpuTiModelPtr>(p_model)->p_runningActionSetThatDoesNotNeedBeingChecked;
- xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
+ /* Move to the *end* of the corresponding action set. This convention
+ is used to speed up update_resource_state */
+ xbt_swag_remove(static_cast<ActionPtr>(action), action->getStateSet());
+ action->p_stateSet = reinterpret_cast<CpuTiModelPtr>(getModel())->p_runningActionSetThatDoesNotNeedBeingChecked;
+ xbt_swag_insert(static_cast<ActionPtr>(action), action->getStateSet());
}
+
+ xbt_swag_insert(action, p_actionSet);
+
XBT_OUT();
return action;
}
-void CpuTi::printCpuTiModel()
-{
- std::cout << getModel()->getName() << "<<plop"<< std::endl;
-};
-
/**********
* Action *
**********/
+
static void cpu_ti_action_update_index_heap(void *action, int i)
{
- ((CpuTiActionPtr)action)->updateIndexHeap(i);
+((CpuTiActionPtr)action)->updateIndexHeap(i);
}
+
+CpuTiAction::CpuTiAction(CpuTiModelPtr model_, double cost, bool failed,
+ CpuTiPtr cpu)
+ : Action(model_, cost, failed)
+ , CpuAction(model_, cost, failed)
+{
+ p_cpuListHookup.next = 0;
+ p_cpuListHookup.prev = 0;
+
+ m_suspended = 0; /* Should be useless because of the
+ calloc but it seems to help valgrind... */
+ p_cpu = cpu;
+ m_indexHeap = -1;
+ xbt_swag_insert(cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
+}
+
void CpuTiAction::updateIndexHeap(int i)
{
m_indexHeap = i;
void CpuTiAction::setState(e_surf_action_state_t state)
{
Action::setState(state);
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
}
int CpuTiAction::unref()
{
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), getStateSet());
/* remove from action_set */
xbt_swag_remove(this, p_cpu->p_actionSet);
/* remove from heap */
- xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, this->m_indexHeap);
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(getModel())->p_tiActionHeap, this->m_indexHeap);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
delete this;
return 1;
}
void CpuTiAction::cancel()
{
this->setState(SURF_ACTION_FAILED);
- xbt_heap_remove(p_model->p_actionHeap, this->m_indexHeap);
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_heap_remove(getModel()->getActionHeap(), this->m_indexHeap);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
return;
}
XBT_IN("(%p)", this);
if (m_suspended != 2) {
m_suspended = 1;
- xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_heap_remove(getModel()->getActionHeap(), m_indexHeap);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
}
XBT_OUT();
}
XBT_IN("(%p)", this);
if (m_suspended != 2) {
m_suspended = 0;
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
}
XBT_OUT();
}
m_maxDuration = duration;
if (duration >= 0)
- min_finish = (m_start + m_maxDuration) < m_finish ?
- (m_start + m_maxDuration) : m_finish;
+ min_finish = (getStartTime() + getMaxDuration()) < getFinishTime() ?
+ (getStartTime() + getMaxDuration()) : getFinishTime();
else
- min_finish = m_finish;
+ min_finish = getFinishTime();
/* add in action heap */
if (m_indexHeap >= 0) {
CpuTiActionPtr heap_act = (CpuTiActionPtr)
- xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
+ xbt_heap_remove(getModel()->getActionHeap(), m_indexHeap);
if (heap_act != this)
DIE_IMPOSSIBLE;
}
- xbt_heap_push(p_model->p_actionHeap, this, min_finish);
+ xbt_heap_push(getModel()->getActionHeap(), this, min_finish);
XBT_OUT();
}
{
XBT_IN("(%p,%g)", this, priority);
m_priority = priority;
- xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
+ xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(getModel())->p_modifiedCpu);
XBT_OUT();
}
~CpuTi();
void updateState(tmgr_trace_event_t event_type, double value, double date);
- void updateActionFinishDate(double now);
+ void updateActionsFinishTime(double now);
bool isUsed();
void printCpuTiModel();
CpuActionPtr execute(double size);
- CpuTiActionPtr _execute(double size);
CpuActionPtr sleep(double duration);
double getAvailableSpeed();
**********/
class CpuTiAction: public CpuAction {
+ friend CpuActionPtr CpuTi::execute(double size);
+ friend CpuActionPtr CpuTi::sleep(double duration);
+ friend void CpuTi::updateActionsFinishTime(double now);//FIXME
+ friend void CpuTi::updateRemainingAmount(double now);//FIXME
+
public:
CpuTiAction() {};
- CpuTiAction(CpuTiModelPtr model, double cost, bool failed)
- : Action(model, cost, failed), CpuAction(model, cost, failed) {
- p_cpuListHookup.next = 0;
- p_cpuListHookup.prev = 0;
- };
+ CpuTiAction(CpuTiModelPtr model, double cost, bool failed,
+ CpuTiPtr cpu);
void setState(e_surf_action_state_t state);
int unref();
XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
- int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->p_variable);
+ int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
int i;
for (i = 0; i < n; i++){
lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
- action->p_variable,
+ action->getVariable(),
i);
NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(lmm_constraint_id(constraint));
- TRACE_surf_link_set_utilization(link->m_name,
- action->p_category,
- (lmm_variable_getvalue(action->p_variable)*
+ TRACE_surf_link_set_utilization(link->getName(),
+ action->getCategory(),
+ (lmm_variable_getvalue(action->getVariable())*
lmm_get_cnst_weight_from_var(p_maxminSystem,
- action->p_variable,
+ action->getVariable(),
i)),
- action->m_lastUpdate,
- now - action->m_lastUpdate);
+ action->getLastUpdate(),
+ now - action->getLastUpdate());
}
}
#endif
// if I am wearing a latency hat
- if (action->m_hat == LATENCY) {
+ if (action->getHat() == LATENCY) {
XBT_DEBUG("Latency paid for action %p. Activating", action);
- lmm_update_variable_weight(p_maxminSystem, action->p_variable, action->m_weight);
+ lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight);
action->heapRemove(p_actionHeap);
- action->m_lastUpdate = surf_get_clock();
+ action->refreshLastUpdate();
// if I am wearing a max_duration or normal hat
- } else if (action->m_hat == MAX_DURATION ||
- action->m_hat == NORMAL) {
+ } else if (action->getHat() == MAX_DURATION ||
+ action->getHat() == NORMAL) {
// no need to communicate anymore
// assume that flows that reached max_duration have remaining of 0
- action->m_finish = surf_get_clock();
XBT_DEBUG("Action %p finished", action);
- action->m_remains = 0;
- action->m_finish = surf_get_clock();
+ action->setRemains(0);
+ action->finish();
action->setState(SURF_ACTION_DONE);
action->heapRemove(p_actionHeap);
xbt_dynar_foreach(route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
+ if (link->getState() == SURF_RESOURCE_OFF) {
failed = 1;
break;
}
routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
xbt_dynar_foreach(back_route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
+ if (link->getState() == SURF_RESOURCE_OFF) {
failed = 1;
break;
}
if (sg_weight_S_parameter > 0) {
xbt_dynar_foreach(route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- action->m_weight +=
- sg_weight_S_parameter /
- (link->p_power.peak * link->p_power.scale);
+ action->m_weight += sg_weight_S_parameter / link->getBandwidth();
}
}
xbt_dynar_foreach(route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- double bb = bandwidthFactor(size) * (link->p_power.peak * link->p_power.scale);
+ double bb = bandwidthFactor(size) * link->getBandwidth(); //(link->p_power.peak * link->p_power.scale);
bandwidth_bound =
(bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
}
action->p_variable = lmm_variable_new(p_maxminSystem, action, 1.0, -1.0, constraints_per_variable);
if (action->m_rate < 0) {
- lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
+ lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
} else {
- lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
+ lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
}
xbt_dynar_foreach(route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, 1.0);
+ lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), 1.0);
}
if (sg_network_crosstraffic == 1) {
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
xbt_dynar_foreach(back_route, i, _link) {
link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, .05);
+ lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), .05);
}
}
tmgr_trace_t lat_trace,
e_surf_link_sharing_policy_t policy)
: Resource(model, name, props),
- NetworkLinkLmm(system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
+ NetworkLinkLmm(lmm_constraint_new(system, this, constraint_value), history, state_trace)
{
+ m_stateCurrent = state_init;
+
+ p_power.scale = 1.0;
+ p_power.peak = metric_peak;
+ if (metric_trace)
+ p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+ else
+ p_power.event = NULL;
+
m_latCurrent = lat_initial;
if (lat_trace)
p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(p_constraint);
+ lmm_constraint_shared(constraint());
}
NetworkCm02ActionLmmPtr action = NULL;
p_power.peak = value;
- lmm_update_constraint_bound(p_model->p_maxminSystem,
- p_constraint,
+ lmm_update_constraint_bound(getModel()->getMaxminSystem(),
+ constraint(),
sg_bandwidth_factor *
(p_power.peak * p_power.scale));
#ifdef HAVE_TRACING
- TRACE_surf_link_set_bandwidth(date, m_name, sg_bandwidth_factor * p_power.peak * p_power.scale);
+ TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale);
#endif
if (sg_weight_S_parameter > 0) {
- while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, p_constraint, &elem))) {
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), constraint(), &elem))) {
action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
action->m_weight += delta;
- if (!action->m_suspended)
- lmm_update_variable_weight(p_model->p_maxminSystem, action->p_variable, action->m_weight);
+ if (!action->isSuspended())
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
}
}
if (tmgr_trace_event_free(event_type))
NetworkCm02ActionLmmPtr action = NULL;
m_latCurrent = value;
- while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, p_constraint, &elem))) {
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), constraint(), &elem))) {
action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
action->m_latCurrent += delta;
action->m_weight += delta;
if (action->m_rate < 0)
- lmm_update_variable_bound(p_model->p_maxminSystem, action->p_variable, sg_tcp_gamma / (2.0 * action->m_latCurrent));
+ lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), sg_tcp_gamma / (2.0 * action->m_latCurrent));
else {
- lmm_update_variable_bound(p_model->p_maxminSystem, action->p_variable,
+ lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(),
min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)));
if (action->m_rate < sg_tcp_gamma / (2.0 * action->m_latCurrent)) {
action->m_latCurrent);
}
}
- if (!action->m_suspended)
- lmm_update_variable_weight(p_model->p_maxminSystem, action->p_variable, action->m_weight);
+ if (!action->isSuspended())
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
}
if (tmgr_trace_event_free(event_type))
p_latEvent = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- p_stateCurrent = SURF_RESOURCE_ON;
+ m_stateCurrent = SURF_RESOURCE_ON;
else {
- lmm_constraint_t cnst = p_constraint;
+ lmm_constraint_t cnst = constraint();
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- p_stateCurrent = SURF_RESOURCE_OFF;
- while ((var = lmm_get_var_from_cnst(p_model->p_maxminSystem, cnst, &elem))) {
+ m_stateCurrent = SURF_RESOURCE_OFF;
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) {
ActionPtr action = (ActionPtr) lmm_variable_id(var);
if (action->getState() == SURF_ACTION_RUNNING ||
action->getState() == SURF_ACTION_READY) {
- action->m_finish = date;
+ action->setFinishTime(date);
action->setState(SURF_ACTION_FAILED);
}
}
XBT_DEBUG
("There were a resource state event, need to update actions related to the constraint (%p)",
- p_constraint);
+ constraint());
return;
}
double_update(&m_maxDuration, delta);
if (m_remains <= 0 &&
- (lmm_get_variable_weight(p_variable) > 0)) {
- m_finish = surf_get_clock();
+ (lmm_get_variable_weight(getVariable()) > 0)) {
+ finish();
setState(SURF_ACTION_DONE);
- heapRemove(p_model->p_actionHeap);
+ heapRemove(getModel()->getActionHeap());
} else if (((m_maxDuration != NO_MAX_DURATION)
&& (m_maxDuration <= 0))) {
- m_finish = surf_get_clock();
+ finish();
setState(SURF_ACTION_DONE);
- heapRemove(p_model->p_actionHeap);
+ heapRemove(getModel()->getActionHeap());
}
m_lastUpdate = now;
- m_lastValue = lmm_variable_getvalue(p_variable);
+ m_lastValue = lmm_variable_getvalue(getVariable());
}
void NetworkCm02ActionLmm::recycle()
{
f_networkSolve = lmm_solve;
m_haveGap = false;
};//FIXME: add network clean interface
- NetworkCm02Model(string name) : NetworkModel(name) {
+ NetworkCm02Model(const char *name) : NetworkModel(name) {
this->initialize();
}
NetworkCm02Model() : NetworkModel("network") {
**********/
class NetworkCm02ActionLmm : public NetworkActionLmm {
+ friend ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate);
+
public:
NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
: Action(model, cost, failed) {};
NetworkConstantActionLmmPtr action = NULL;
double min = -1.0;
- xbt_swag_foreach(_action, p_runningActionSet) {
+ xbt_swag_t actionSet = getRunningActionSet();
+ xbt_swag_foreach(_action, actionSet) {
action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
if (action->m_latency > 0) {
if (min < 0)
{
void *_action, *_next_action;
NetworkConstantActionLmmPtr action = NULL;
-
- xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+ xbt_swag_t actionSet = getRunningActionSet();
+ xbt_swag_foreach_safe(_action, _next_action, actionSet) {
action = dynamic_cast<NetworkConstantActionLmmPtr>(static_cast<ActionPtr>(_action));
if (action->m_latency > 0) {
if (action->m_latency > delta) {
action->m_latency = 0.0;
}
}
- double_update(&(action->m_remains),
- action->m_cost * delta / action->m_latInit);
- if (action->m_maxDuration != NO_MAX_DURATION)
- double_update(&(action->m_maxDuration), delta);
+ action->updateRemains(action->getCost() * delta / action->m_latInit);
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ action->updateMaxDuration(delta);
- if (action->m_remains <= 0) {
- action->m_finish = surf_get_clock();
+ if (action->getRemains() <= 0) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
- } else if ((action->m_maxDuration != NO_MAX_DURATION)
- && (action->m_maxDuration <= 0)) {
- action->m_finish = surf_get_clock();
+ } else if ((action->getMaxDuration() != NO_MAX_DURATION)
+ && (action->getMaxDuration() <= 0)) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
}
}
**********/
class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
public:
- NetworkConstantActionLmm(NetworkConstantModelPtr model, double size, double latency):
- Action(model, size, false), NetworkCm02ActionLmm(model, 0, false), m_latInit(latency) {
+ NetworkConstantActionLmm(NetworkConstantModelPtr model_, double size, double latency):
+ Action(model_, size, false), NetworkCm02ActionLmm(model_, 0, false), m_latInit(latency) {
m_latency = latency;
if (m_latency <= 0.0) {
- p_stateSet = p_model->p_doneActionSet;
+ p_stateSet = getModel()->getDoneActionSet();
xbt_swag_insert(static_cast<ActionPtr>(this), p_stateSet);
}
};
return rate;
}
+NetworkLinkLmm::NetworkLinkLmm(lmm_constraint_t constraint,
+ tmgr_history_t history,
+ tmgr_trace_t state_trace)
+: ResourceLmm(constraint)
+{
+ if (state_trace)
+ p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+}
+
bool NetworkLinkLmm::isUsed()
{
- return lmm_constraint_used(p_model->p_maxminSystem, p_constraint);
+ return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
}
double NetworkLink::getLatency()
bool NetworkLinkLmm::isShared()
{
- return lmm_constraint_is_shared(p_constraint);
+ return lmm_constraint_is_shared(constraint());
}
#endif /* NETWORK_INTERFACE_CPP_ */
public:
NetworkModel() : Model("network") {
};
- NetworkModel(string name) : Model(name) {
+ NetworkModel(const char *name) : Model(name) {
f_networkSolve = lmm_solve;
m_haveGap = false;
};
};
class NetworkLinkLmm : public ResourceLmm, public NetworkLink {
+protected:
public:
NetworkLinkLmm() {};
- NetworkLinkLmm(lmm_system_t system,
- double constraint_value,
- tmgr_history_t history,
- e_surf_resource_state_t state_init,
- tmgr_trace_t state_trace,
- double metric_peak,
- tmgr_trace_t metric_trace)
- : ResourceLmm(system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
-{
-}
+ NetworkLinkLmm(lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace);
bool isShared();
bool isUsed();
double getBandwidth();
+ tmgr_trace_event_t p_stateEvent;
+ s_surf_metric_t p_power;
};
/**********
void NetworkSmpiModel::gapAppend(double size, const NetworkLinkLmmPtr link, NetworkActionLmmPtr action)
{
- const char *src = link->m_name;
+ const char *src = link->getName();
xbt_fifo_t fifo;
//surf_action_network_CM02_t last_action;
//double bw;
m_size(size), m_usedSize(0), p_typeId(xbt_strdup(type_id)), p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL))
{
p_content = parseContent(content_name);
- p_stateCurrent = SURF_RESOURCE_ON;
+ m_stateCurrent = SURF_RESOURCE_ON;
}
Storage::~Storage(){
StorageLmm::StorageLmm(lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
const char* type_id, char *content_name, char *content_type, sg_size_t size)
- : ResourceLmm(), Storage(type_id, content_name, content_type, size) {
+ : ResourceLmm(lmm_constraint_new(maxminSystem, this, bconnection)), Storage(type_id, content_name, content_type, size) {
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
-
- p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
}
{
};
-StorageActionLmm::StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type)
- : StorageAction(storage, type) {
+StorageActionLmm::StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var)
+ : StorageAction(storage, type), ActionLmm(var) {
}
public:
StorageActionLmm() {};//FIXME:REMOVE
- StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type);
+ StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var);
};
typedef struct s_storage_type {
}
StorageN11Model::StorageN11Model() : StorageModel() {
- StorageN11ActionLmm action;
+ ActionPtr action = NULL;
XBT_DEBUG("surf_storage_model_init_internal");
storage_running_action_set_that_does_not_need_being_checked =
- xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
-
+ xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
if (!p_maxminSystem) {
p_maxminSystem = lmm_system_new(storage_selective_update);
}
void *_write_action;
StorageActionLmmPtr write_action;
- double min_completion = shareResourcesMaxMin(p_runningActionSet,
+ double min_completion = shareResourcesMaxMin(getRunningActionSet(),
p_maxminSystem, lmm_solve);
double rate;
xbt_dynar_foreach(storage->p_writeActions, j, _write_action)
{
write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
- rate += lmm_variable_getvalue(write_action->p_variable);
+ rate += lmm_variable_getvalue(write_action->getVariable());
}
if(rate > 0)
min_completion = MIN(min_completion, (storage->m_size-storage->m_usedSize)/rate);
void *_action, *_next_action;
StorageActionLmmPtr action = NULL;
- xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+ xbt_swag_t actionSet = getRunningActionSet();
+ xbt_swag_foreach_safe(_action, _next_action, actionSet) {
action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_action));
if(action->m_type == WRITE)
{
// Update the disk usage
// Update the file size
// For each action of type write
- double rate = lmm_variable_getvalue(action->p_variable);
+ double rate = lmm_variable_getvalue(action->getVariable());
/* Hack to avoid rounding differences between x86 and x86_64
* (note that the next sizes are of type sg_size_t). */
long incr = delta * rate + MAXMIN_PRECISION;
xbt_dict_set(content_dict, action->p_file->name, psize, NULL);
}
- double_update(&action->m_remains,
- lmm_variable_getvalue(action->p_variable) * delta);
+ action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
- if (action->m_maxDuration != NO_MAX_DURATION)
- double_update(&action->m_maxDuration, delta);
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ action->updateMaxDuration(delta);
- if(action->m_remains > 0 &&
- lmm_get_variable_weight(action->p_variable) > 0 &&
+ if(action->getRemains() > 0 &&
+ lmm_get_variable_weight(action->getVariable()) > 0 &&
action->p_storage->m_usedSize == action->p_storage->m_size)
{
- action->m_finish = surf_get_clock();
+ action->finish();
action->setState(SURF_ACTION_FAILED);
- } else if ((action->m_remains <= 0) &&
- (lmm_get_variable_weight(action->p_variable) > 0))
+ } else if ((action->getRemains() <= 0) &&
+ (lmm_get_variable_weight(action->getVariable()) > 0))
{
- action->m_finish = surf_get_clock();
+ action->finish();
action->setState(SURF_ACTION_DONE);
- } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
- (action->m_maxDuration <= 0))
+ } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+ (action->getMaxDuration() <= 0))
{
- action->m_finish = surf_get_clock();
+ action->finish();
action->setState(SURF_ACTION_DONE);
}
}
: Resource(model, name, properties),
StorageLmm(maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size) {
XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
-
- p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
- p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
- p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
}
StorageActionPtr StorageN11Lmm::ls(const char* path)
{
- StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, LS);
+ StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
action->p_lsDict = NULL;
xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
file->mount = xbt_strdup(mount);
file->current_position = 0;
- StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+ StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
action->p_file = file;
return action;
}
free(fd->name);
free(fd->mount);
xbt_free(fd);
- StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+ StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
return action;
}
else
fd->current_position += size;
- StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
+ StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
return action;
}
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
- StorageActionLmmPtr action = new StorageN11ActionLmm(p_model, size, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+ StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
fd->current_position += size;
// If the storage is full
* Action *
**********/
-StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
- : Action(model, cost, failed),
- StorageActionLmm(storage, type) {
- XBT_IN("(%s,%g", storage->m_name, cost);
- p_variable = lmm_variable_new(p_model->p_maxminSystem, this, 1.0, -1.0 , 3);
+StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model_, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
+ : Action(model_, cost, failed),
+ StorageActionLmm(storage, type, lmm_variable_new(getModel()->getMaxminSystem(), this, 1.0, -1.0 , 3)) {
+ XBT_IN("(%s,%g", storage->getName(), cost);
// Must be less than the max bandwidth for all actions
- lmm_expand(p_model->p_maxminSystem, storage->p_constraint, p_variable, 1.0);
+ lmm_expand(getModel()->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
switch(type) {
case OPEN:
case CLOSE:
case LS:
break;
case READ:
- lmm_expand(p_model->p_maxminSystem, storage->p_constraintRead,
- p_variable, 1.0);
+ lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintRead,
+ getVariable(), 1.0);
break;
case WRITE:
- lmm_expand(p_model->p_maxminSystem, storage->p_constraintWrite,
- p_variable, 1.0);
+ lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintWrite,
+ getVariable(), 1.0);
ActionPtr action = this;
xbt_dynar_push(storage->p_writeActions, &action);
ref();
m_refcount--;
if (!m_refcount) {
xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
- if (p_variable)
- lmm_variable_free(p_model->p_maxminSystem, p_variable);
+ if (getVariable())
+ lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
#ifdef HAVE_TRACING
- xbt_free(p_category);
+ xbt_free(getCategory());
#endif
delete this;
return 1;
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
- lmm_update_variable_weight(p_model->p_maxminSystem,
- p_variable,
+ lmm_update_variable_weight(getModel()->getMaxminSystem(),
+ getVariable(),
0.0);
m_suspended = 1;
}
{
double next_action_end = -1.0;
int i = __sync_fetch_and_add(&surf_min_index, 1);
- if (strcmp(model->m_name.c_str(), "network NS3")) {
- XBT_DEBUG("Running for Resource [%s]", model->m_name.c_str());
+ if (strcmp(model->getName(), "network NS3")) {
+ XBT_DEBUG("Running for Resource [%s]", model->getName());
next_action_end = model->shareResources(NOW);
XBT_DEBUG("Resource [%s] : next action end = %f",
- model->m_name.c_str(), next_action_end);
+ model->getName(), next_action_end);
}
surf_mins[i] = next_action_end;
}
next_event_date = tmgr_history_next_date(history);
- if(!strcmp(surf_network_model->m_name.c_str(), "network NS3")){//FIXME: add surf_network_model->m_name &&
+ if(!strcmp(surf_network_model->getName(), "network NS3")){//FIXME: add surf_network_model->m_name &&
if(next_event_date!=-1.0 && surf_min!=-1.0) {
surf_min = MIN(next_event_date - NOW, surf_min);
} else{
tmgr_history_get_next_event_leq(history, next_event_date,
&value,
(void **) &resource))) {
- if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->m_name)) {
+ if (resource->isUsed() || xbt_dict_get_or_null(watched_hosts_lib, resource->getName())) {
surf_min = next_event_date - NOW;
XBT_DEBUG
("This event will modify model state. Next event set to %f",
/* update state of model_obj according to new value. Does not touch lmm.
It will be modified if needed when updating actions */
XBT_DEBUG("Calling update_resource_state for resource %s with min %lf",
- resource->m_name, surf_min);
+ resource->getName(), surf_min);
resource->updateState(event, value, next_event_date);
}
} while (1);
/* If level is SURF_WKS_LEVEL, ws is a workstation_CLM03 object. It has
* surf_resource at the generic_resource field. */
ResourcePtr ws = static_cast<ResourcePtr>(xbt_lib_get_level((xbt_dictelm_t) host, level));
- return ws->p_model;
+ return ws->getModel();
}
void *surf_as_cluster_get_backbone(AS_t as){
}
const char *surf_model_name(surf_model_t model){
- return model->m_name.c_str();
+ return model->getName();
}
xbt_swag_t surf_model_done_action_set(surf_model_t model){
- return model->p_doneActionSet;
+ return model->getDoneActionSet();
}
xbt_swag_t surf_model_failed_action_set(surf_model_t model){
- return model->p_failedActionSet;
+ return model->getFailedActionSet();
}
xbt_swag_t surf_model_ready_action_set(surf_model_t model){
- return model->p_readyActionSet;
+ return model->getReadyActionSet();
}
xbt_swag_t surf_model_running_action_set(surf_model_t model){
- return model->p_runningActionSet;
+ return model->getRunningActionSet();
}
surf_action_t surf_workstation_model_execute_parallel_task(surf_workstation_model_t model,
}
const char *surf_resource_name(surf_cpp_resource_t resource){
- return resource->m_name;
+ return resource->getName();
}
xbt_dict_t surf_resource_get_properties(surf_cpp_resource_t resource){
}
double surf_action_get_start_time(surf_action_t action){
- return action->m_start;
+ return action->getStartTime();
}
double surf_action_get_finish_time(surf_action_t action){
- return action->m_finish;
+ return action->getFinishTime();
}
double surf_action_get_remains(surf_action_t action){
}
void *surf_action_get_data(surf_action_t action){
- return action->p_data;
+ return action->getData();
}
void surf_action_set_data(surf_action_t action, void *data){
- action->p_data = data;
+ action->setData(data);
}
e_surf_action_state_t surf_action_get_state(surf_action_t action){
}
int surf_action_get_cost(surf_action_t action){
- return action->m_cost;
+ return action->getCost();
}
void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) {
* Model *
*********/
-Model::Model(string name)
- : p_maxminSystem(0), m_name(name),
+Model::Model(const char *name)
+ : p_maxminSystem(0), p_name(name),
m_resOnCB(0), m_resOffCB(0),
m_actCancelCB(0), m_actSuspendCB(0), m_actResumeCB(0)
{
while((action = static_cast<ActionLmmPtr>(xbt_swag_extract(p_modifiedSet)))) {
int max_dur_flag = 0;
- if (action->p_stateSet != p_runningActionSet)
+ if (action->getStateSet() != p_runningActionSet)
continue;
/* bogus priority, skip it */
- if (action->m_priority <= 0)
+ if (action->getPriority() <= 0)
continue;
action->updateRemainingLazy(now);
min = -1;
- value = lmm_variable_getvalue(action->p_variable);
+ value = lmm_variable_getvalue(action->getVariable());
if (value > 0) {
- if (action->m_remains > 0) {
- value = action->m_remains / value;
+ if (action->getRemains() > 0) {
+ value = action->getRemains() / value;
min = now + value;
} else {
value = 0.0;
}
}
- if ((action->m_maxDuration != NO_MAX_DURATION)
+ if ((action->getMaxDuration() != NO_MAX_DURATION)
&& (min == -1
- || action->m_start +
- action->m_maxDuration < min)) {
- min = action->m_start +
- action->m_maxDuration;
+ || action->getStartTime() +
+ action->getMaxDuration() < min)) {
+ min = action->getStartTime() +
+ action->getMaxDuration();
max_dur_flag = 1;
}
XBT_DEBUG("Action(%p) Start %lf Finish %lf Max_duration %lf", action,
- action->m_start, now + value,
- action->m_maxDuration);
+ action->getStartTime(), now + value,
+ action->getMaxDuration());
if (min != -1) {
action->heapRemove(p_actionHeap);
xbt_swag_foreach(_action, running_actions) {
action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
- value = lmm_variable_getvalue(action->p_variable);
- if ((value > 0) || (action->m_maxDuration >= 0))
+ value = lmm_variable_getvalue(action->getVariable());
+ if ((value > 0) || (action->getMaxDuration() >= 0))
break;
}
return -1.0;
if (value > 0) {
- if (action->m_remains > 0)
- min = action->m_remains / value;
+ if (action->getRemains() > 0)
+ min = action->getRemains() / value;
else
min = 0.0;
- if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min))
- min = action->m_maxDuration;
+ if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min))
+ min = action->getMaxDuration();
} else
- min = action->m_maxDuration;
+ min = action->getMaxDuration();
for (_action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset);
_action;
_action = xbt_swag_getNext(static_cast<ActionPtr>(action), running_actions->offset)) {
action = dynamic_cast<ActionLmmPtr>(static_cast<ActionPtr>(_action));
- value = lmm_variable_getvalue(action->p_variable);
+ value = lmm_variable_getvalue(action->getVariable());
if (value > 0) {
- if (action->m_remains > 0)
- value = action->m_remains / value;
+ if (action->getRemains() > 0)
+ value = action->getRemains() / value;
else
value = 0.0;
if (value < min) {
XBT_DEBUG("Updating min (value) with %p: %f", action, min);
}
}
- if ((action->m_maxDuration >= 0) && (action->m_maxDuration < min)) {
- min = action->m_maxDuration;
+ if ((action->getMaxDuration() >= 0) && (action->getMaxDuration() < min)) {
+ min = action->getMaxDuration();
XBT_DEBUG("Updating min (duration) with %p: %f", action, min);
}
}
* Resource *
************/
-Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
- : m_name(xbt_strdup(name)), m_properties(props), p_model(model), m_running(true)
-{}
-
Resource::Resource()
-: m_name(NULL), m_properties(NULL), p_model(NULL)
+: p_name(NULL), p_properties(NULL), p_model(NULL)
{}
-const char *Resource::getName()
-{
- return m_name;
-}
+Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props)
+ : p_name(xbt_strdup(name)), p_properties(props), p_model(model)
+ , m_running(true), m_stateCurrent(SURF_RESOURCE_ON)
+{}
-xbt_dict_t Resource::getProperties()
-{
- return m_properties;
-}
+Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit)
+ : p_name(xbt_strdup(name)), p_properties(props), p_model(model)
+ , m_running(true), m_stateCurrent(stateInit)
+{}
e_surf_resource_state_t Resource::getState()
{
- return p_stateCurrent;
+ return m_stateCurrent;
}
void Resource::setState(e_surf_resource_state_t state)
{
- p_stateCurrent = state;
+ m_stateCurrent = state;
}
bool Resource::isOn()
{
if (!m_running) {
m_running = true;
- p_model->notifyResourceTurnedOn(this);
+ getModel()->notifyResourceTurnedOn(this);
}
}
{
if (m_running) {
m_running = false;
- p_model->notifyResourceTurnedOff(this);
+ getModel()->notifyResourceTurnedOff(this);
}
}
-ResourceLmm::ResourceLmm(lmm_system_t system,
- double constraint_value,
- tmgr_history_t history,
- e_surf_resource_state_t state_init,
- tmgr_trace_t state_trace,
- double metric_peak,
- tmgr_trace_t metric_trace)
-{
- p_constraint = lmm_constraint_new(system, this, constraint_value);
- p_stateCurrent = state_init;
- if (state_trace)
- p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
- p_power.scale = 1.0;
- p_power.peak = metric_peak;
- if (metric_trace)
- p_power.event = tmgr_history_add_trace(history, metric_trace, 0.0, 0, static_cast<ResourcePtr>(this));
- else
- p_power.event = NULL;
-}
+ResourceLmm::ResourceLmm()
+ : p_constraint(NULL)
+{}
+
+ResourceLmm::ResourceLmm(lmm_constraint_t constraint)
+ : p_constraint(constraint)
+{}
/**********
* Action *
p_stateHookup.prev = 0;
p_stateHookup.next = 0;
if (failed)
- p_stateSet = p_model->p_failedActionSet;
+ p_stateSet = getModel()->getFailedActionSet();
else
- p_stateSet = p_model->p_runningActionSet;
+ p_stateSet = getModel()->getRunningActionSet();
xbt_swag_insert(this, p_stateSet);
}
-Action::~Action() {}
+Action::~Action() {
+#ifdef HAVE_TRACING
+ xbt_free(p_category);
+#endif
+}
+
+void Action::finish() {
+ m_finish = surf_get_clock();
+}
int Action::unref(){
DIE_IMPOSSIBLE;
e_surf_action_state_t Action::getState()
{
- if (p_stateSet == p_model->p_readyActionSet)
+ if (p_stateSet == getModel()->getReadyActionSet())
return SURF_ACTION_READY;
- if (p_stateSet == p_model->p_runningActionSet)
+ if (p_stateSet == getModel()->getRunningActionSet())
return SURF_ACTION_RUNNING;
- if (p_stateSet == p_model->p_failedActionSet)
+ if (p_stateSet == getModel()->getFailedActionSet())
return SURF_ACTION_FAILED;
- if (p_stateSet == p_model->p_doneActionSet)
+ if (p_stateSet == getModel()->getDoneActionSet())
return SURF_ACTION_DONE;
return SURF_ACTION_NOT_IN_THE_SYSTEM;
}
xbt_swag_remove(this, p_stateSet);
if (state == SURF_ACTION_READY)
- p_stateSet = p_model->p_readyActionSet;
+ p_stateSet = getModel()->getReadyActionSet();
else if (state == SURF_ACTION_RUNNING)
- p_stateSet = p_model->p_runningActionSet;
+ p_stateSet = getModel()->getRunningActionSet();
else if (state == SURF_ACTION_FAILED)
- p_stateSet = p_model->p_failedActionSet;
+ p_stateSet = getModel()->getFailedActionSet();
else if (state == SURF_ACTION_DONE)
- p_stateSet = p_model->p_doneActionSet;
+ p_stateSet = getModel()->getDoneActionSet();
else
p_stateSet = NULL;
{
XBT_IN("(%p,%g)", this, duration);
m_maxDuration = duration;
- if (p_model->p_updateMechanism == UM_LAZY) // remove action from the heap
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY) // remove action from the heap
+ heapRemove(getModel()->getActionHeap());
XBT_OUT();
}
{
XBT_IN("(%p,%g)", this, priority);
m_priority = priority;
- lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, priority);
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), priority);
- if (p_model->p_updateMechanism == UM_LAZY)
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(getModel()->getActionHeap());
XBT_OUT();
}
void ActionLmm::cancel(){
setState(SURF_ACTION_FAILED);
- if (p_model->p_updateMechanism == UM_LAZY) {
- xbt_swag_remove(this, p_model->p_modifiedSet);
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY) {
+ xbt_swag_remove(this, getModel()->getModifiedSet());
+ heapRemove(getModel()->getActionHeap());
}
}
m_refcount--;
if (!m_refcount) {
xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
- if (p_variable)
- lmm_variable_free(p_model->p_maxminSystem, p_variable);
- if (p_model->p_updateMechanism == UM_LAZY) {
+ if (getVariable())
+ lmm_variable_free(getModel()->getMaxminSystem(), getVariable());
+ if (getModel()->getUpdateMechanism() == UM_LAZY) {
/* remove from heap */
- heapRemove(p_model->p_actionHeap);
- xbt_swag_remove(this, p_model->p_modifiedSet);
+ heapRemove(getModel()->getActionHeap());
+ xbt_swag_remove(this, getModel()->getModifiedSet());
}
-#ifdef HAVE_TRACING
- xbt_free(p_category);
-#endif
delete this;
return 1;
}
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
- lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, 0.0);
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), 0.0);
m_suspended = 1;
- if (p_model->p_updateMechanism == UM_LAZY)
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(getModel()->getActionHeap());
}
XBT_OUT();
}
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
- lmm_update_variable_weight(p_model->p_maxminSystem, p_variable, m_priority);
+ lmm_update_variable_weight(getModel()->getMaxminSystem(), getVariable(), m_priority);
m_suspended = 0;
- if (p_model->p_updateMechanism == UM_LAZY)
- heapRemove(p_model->p_actionHeap);
+ if (getModel()->getUpdateMechanism() == UM_LAZY)
+ heapRemove(getModel()->getActionHeap());
}
XBT_OUT();
}
{
XBT_IN("(%p)", this);
/* update remains before return it */
- if (p_model->p_updateMechanism == UM_LAZY) /* update remains before return it */
+ if (getModel()->getUpdateMechanism() == UM_LAZY) /* update remains before return it */
updateRemainingLazy(surf_get_clock());
XBT_OUT();
return m_remains;
{
double delta = 0.0;
- if(p_model == static_cast<ModelPtr>(surf_network_model))
+ if(getModel() == static_cast<ModelPtr>(surf_network_model))
{
if (m_suspended != 0)
return;
}
else
{
- xbt_assert(p_stateSet == p_model->p_runningActionSet,
+ xbt_assert(p_stateSet == getModel()->getRunningActionSet(),
"You're updating an action that is not running.");
/* bogus priority, skip it */
double_update(&m_remains, m_lastValue * delta);
#ifdef HAVE_TRACING
- if (p_model == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
- ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0)));
- TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+ if (getModel() == static_cast<ModelPtr>(surf_cpu_model_pm) && TRACE_is_enabled()) {
+ ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0)));
+ TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate);
}
#endif
XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains);
}
- if(p_model == static_cast<ModelPtr>(surf_network_model))
+ if(getModel() == static_cast<ModelPtr>(surf_network_model))
{
if (m_maxDuration != NO_MAX_DURATION)
double_update(&m_maxDuration, delta);
//FIXME: duplicated code
if ((m_remains <= 0) &&
- (lmm_get_variable_weight(p_variable) > 0)) {
- m_finish = surf_get_clock();
+ (lmm_get_variable_weight(getVariable()) > 0)) {
+ finish();
setState(SURF_ACTION_DONE);
- heapRemove(p_model->p_actionHeap);
+ heapRemove(getModel()->getActionHeap());
} else if (((m_maxDuration != NO_MAX_DURATION)
&& (m_maxDuration <= 0))) {
- m_finish = surf_get_clock();
+ finish();
setState(SURF_ACTION_DONE);
- heapRemove(p_model->p_actionHeap);
+ heapRemove(getModel()->getActionHeap());
}
}
m_lastUpdate = now;
- m_lastValue = lmm_variable_getvalue(p_variable);
+ m_lastValue = lmm_variable_getvalue(getVariable());
}
/*void Action::cancel()
XBT_PUBLIC_DATA(xbt_dynar_t) model_list;
class Model {
+ const char *p_name;
+
+ xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */
+ xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */
+ xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */
+ xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */
+
+ ResourceCallback m_resOnCB, m_resOffCB;
+ ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB;
+
+protected:
+ xbt_swag_t p_modifiedSet;
+
+ lmm_system_t p_maxminSystem;
+ e_UM_t p_updateMechanism;
+ int m_selectiveUpdate;
+ xbt_heap_t p_actionHeap;
+
public:
- Model(string name);
+ Model(const char *name);
virtual ~Model();
- //ResourcePtr createResource(string name);
+ const char *getName() {return p_name;}
+ xbt_swag_t getReadyActionSet() {return p_readyActionSet;}
+ xbt_swag_t getRunningActionSet() {return p_runningActionSet;}
+ xbt_swag_t getFailedActionSet() {return p_failedActionSet;}
+ xbt_swag_t getDoneActionSet() {return p_doneActionSet;}
+ xbt_swag_t getModifiedSet() {return p_modifiedSet;}
+ lmm_system_t getMaxminSystem() {return p_maxminSystem;}
+ e_UM_t getUpdateMechanism() {return p_updateMechanism;}
+ xbt_heap_t getActionHeap() {return p_actionHeap;}
+
ActionPtr createAction(double _cost, bool _failed);
virtual double shareResources(double now);
virtual double shareResourcesLazy(double now);
virtual void updateActionsStateLazy(double now, double delta);
virtual void updateActionsStateFull(double now, double delta);
- string getName() {return m_name;};
-
void addTurnedOnCallback(ResourceCallback rc);
void notifyResourceTurnedOn(ResourcePtr r);
void notifyActionResume(ActionPtr a);
void addActionSuspendCallback(ActionCallback ac);
void notifyActionSuspend(ActionPtr a);
-
- lmm_system_t p_maxminSystem;
- e_UM_t p_updateMechanism;
- xbt_swag_t p_modifiedSet;
- xbt_heap_t p_actionHeap;
- int m_selectiveUpdate;
-
- xbt_swag_t p_readyActionSet; /**< Actions in state SURF_ACTION_READY */
- xbt_swag_t p_runningActionSet; /**< Actions in state SURF_ACTION_RUNNING */
- xbt_swag_t p_failedActionSet; /**< Actions in state SURF_ACTION_FAILED */
- xbt_swag_t p_doneActionSet; /**< Actions in state SURF_ACTION_DONE */
- string m_name;
-
-protected:
- std::vector<ActionPtr> m_failedActions, m_runningActions;
-
-private:
- ResourceCallback m_resOnCB, m_resOffCB;
- ActionCallback m_actCancelCB, m_actSuspendCB, m_actResumeCB;
};
/************
} s_surf_metric_t;
class Resource {
+ void *p_resource;
+ const char *p_name;
+ ModelPtr p_model;
+ xbt_dict_t p_properties;
+ bool m_running;
+
+protected:
+ e_surf_resource_state_t m_stateCurrent;
+
public:
Resource();
Resource(ModelPtr model, const char *name, xbt_dict_t properties);
+ Resource(surf_model_t model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit);
virtual ~Resource() {
- xbt_free((void*)m_name);
- xbt_dict_free(&m_properties);
+ xbt_free((void*)p_name);
+ xbt_dict_free(&p_properties);
};
- virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0;
+ ModelPtr getModel() {return p_model;};
+ const char *getName() {return p_name;};
+ virtual xbt_dict_t getProperties() {return p_properties;};
- //private
+ virtual void updateState(tmgr_trace_event_t event_type, double value, double date)=0;
virtual bool isUsed()=0;
- //FIXME:updateActionState();
- //FIXME:updateResourceState();
- //FIXME:finilize();
-
bool isOn();
void turnOn();
void turnOff();
void setName(string name);
- const char *getName();
- virtual xbt_dict_t getProperties();
- ModelPtr getModel() {return p_model;};
virtual e_surf_resource_state_t getState();
virtual void setState(e_surf_resource_state_t state);
- void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
- void *p_resource;
- const char *m_name;
- xbt_dict_t m_properties;
- ModelPtr p_model;
- e_surf_resource_state_t p_stateCurrent;
-
-protected:
-
-private:
- bool m_running;
};
class ResourceLmm: virtual public Resource {
+ lmm_constraint_t p_constraint;
+
public:
- ResourceLmm() : p_constraint(NULL) {
- p_power.event = NULL;
- };
- ResourceLmm(lmm_system_t system,
- double constraint_value,
- tmgr_history_t history,
- e_surf_resource_state_t state_init,
- tmgr_trace_t state_trace,
- double metric_peak,
- tmgr_trace_t metric_trace);
+ ResourceLmm();
+ ResourceLmm(lmm_constraint_t constraint);
~ResourceLmm() {
};
- lmm_constraint_t p_constraint;
- tmgr_trace_event_t p_stateEvent;
- s_surf_metric_t p_power;
+
+ lmm_constraint_t constraint() {return p_constraint;};
};
/**********
**********/
class Action {
+ xbt_swag_t p_modifiedSet;
+ xbt_heap_t p_actionHeap;
+ int m_selectiveUpdate;
+ ModelPtr p_model;
+ double m_bound; /**< the capping of the CPU use */
+ bool m_failed;
+ double m_start; /**< start time */
+ char *p_category; /**< tracing category for categorized resource utilization monitoring */
+
+ #ifdef HAVE_LATENCY_BOUND_TRACKING
+ int m_latencyLimited; /**< Set to 1 if is limited by latency, 0 otherwise */
+ #endif
+ int m_cost;
+ void *p_data; /**< for your convenience */
+
+protected:
+ xbt_swag_t p_stateSet;
+ double m_priority; /**< priority (1.0 by default) */
+ int m_refcount;
+ double m_remains; /**< How much of that cost remains to be done in the currently running task */
+ double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */
+ double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
+
+ ModelPtr getModel() {return p_model;}
+ double getBound() {return m_bound;}
+
public:
+
Action();
Action(ModelPtr model, double cost, bool failed);
virtual ~Action();
+ void finish();
s_xbt_swag_hookup_t p_stateHookup;
e_surf_action_state_t getState(); /**< get the state*/
virtual void setState(e_surf_action_state_t state); /**< Change state*/
double getStartTime(); /**< Return the start time of an action */
double getFinishTime(); /**< Return the finish time of an action */
+ void *getData() {return p_data;}
void setData(void* data);
+ double getMaxDuration() {return m_maxDuration;}
+ char *getCategory() {return p_category;}
+ double getCost() {return m_cost;}
+ void setCost(double cost) {m_cost = cost;}
+
+ void updateMaxDuration(double delta) {double_update(&m_maxDuration, delta);}
+ void updateRemains(double delta) {double_update(&m_remains, delta);}
+ void setRemains(double value) {m_remains = value;}
+ void setFinishTime(double value) {m_finish = value;}
+
void ref();
virtual int unref(); /**< Specify that we don't use that action anymore. Returns true if the action was destroyed and false if someone still has references on it. */
int getLatencyLimited(); /**< Return 1 if action is limited by latency, 0 otherwise */
#endif
- xbt_swag_t p_stateSet;
- double m_priority; /**< priority (1.0 by default) */
- double m_bound; /**< the capping of the CPU use */
- bool m_failed;
- double m_start; /**< start time */
- double m_finish; /**< finish time : this is modified during the run and fluctuates until the task is completed */
- double m_remains; /**< How much of that cost remains to be done in the currently running task */
- #ifdef HAVE_LATENCY_BOUND_TRACKING
- int m_latencyLimited; /**< Set to 1 if is limited by latency, 0 otherwise */
- #endif
- double m_maxDuration; /*< max_duration (may fluctuate until the task is completed) */
- char *p_category; /**< tracing category for categorized resource utilization monitoring */
- int m_cost;
- void *p_data; /**< for your convenience */
-protected:
- ModelPtr p_model;
- int m_refcount;
-#ifdef HAVE_TRACING
-#endif
+ double getPriority() {return m_priority;};
+ xbt_swag_t getStateSet() {return p_stateSet;};
private:
int resourceUsed(void *resource_id);
void updateResourceState(void *id, tmgr_trace_event_t event_type,
double value, double time);
- xbt_swag_t p_modifiedSet;
- xbt_heap_t p_actionHeap;
- int m_selectiveUpdate;
+
};
//FIXME:REMOVE
void surf_action_lmm_update_index_heap(void *action, int i);
class ActionLmm: virtual public Action {
+
+protected:
+ lmm_variable_t p_variable;
+ double m_lastUpdate;
+ double m_lastValue;
+ int m_suspended;
+ int m_indexHeap;
+ enum heap_action_type m_hat;
+
public:
ActionLmm() : m_suspended(false) {
p_actionListHookup.prev = 0;
p_actionListHookup.next = 0;
- m_lastUpdate = 0;
- m_lastValue = 0;
+ m_lastUpdate = 0;
+ m_lastValue = 0;
};
- ActionLmm(ModelPtr /*model*/, double /*cost*/, bool /*failed*/) : m_suspended(false) {
+ ActionLmm(lmm_variable_t var) : m_suspended(false) {
p_actionListHookup.prev = 0;
p_actionListHookup.next = 0;
- m_lastUpdate = 0;
- m_lastValue = 0;
+ m_lastUpdate = 0;
+ m_lastValue = 0;
+ p_variable = var;
};
virtual void updateRemainingLazy(double now);
void heapRemove(xbt_heap_t heap);
double getRemains(); /**< Get the remains of an action */
void updateIndexHeap(int i);
+ lmm_variable_t getVariable() {return p_variable;}
+ double getLastUpdate() {return m_lastUpdate;}
+ void refreshLastUpdate() {m_lastUpdate = surf_get_clock();}
+ enum heap_action_type getHat() {return m_hat;}
virtual int unref();
void cancel();
void setMaxDuration(double duration);
void setPriority(double priority);
void gapRemove();
-
- lmm_variable_t p_variable;
s_xbt_swag_hookup_t p_actionListHookup;
- int m_indexHeap;
- double m_lastUpdate;
- double m_lastValue;
- enum heap_action_type m_hat;
- int m_suspended;
+
};
#endif /* SURF_MODEL_H_ */
routerNode = new_xbt_graph_node(graph, link_name, nodes);
if(p_backbone) {
- const char *link_nameR = p_backbone->m_name;
+ const char *link_nameR = p_backbone->getName();
backboneNode = new_xbt_graph_node(graph, link_nameR, nodes);
new_xbt_graph_edge(graph, routerNode, backboneNode, edges);
if (info.link_up) { // link up
- const char *link_name = ((ResourcePtr) info.link_up)->m_name;
+ const char *link_name = static_cast<ResourcePtr>(info.link_up)->getName();
current = new_xbt_graph_node(graph, link_name, nodes);
new_xbt_graph_edge(graph, previous, current, edges);
}
if (info.link_down) { // link down
- const char *link_name = ((ResourcePtr) info.link_down)->m_name;
+ const char *link_name = static_cast<ResourcePtr>(info.link_down)->getName();
current = new_xbt_graph_node(graph, link_name, nodes);
new_xbt_graph_edge(graph, previous, current, edges);
}
xbt_dynar_foreach(route->link_list, cpt, link) {
- const char *link_name = ((ResourcePtr) link)->m_name;
+ const char *link_name = ((ResourcePtr) link)->getName();
current = new_xbt_graph_node(graph, link_name, nodes);
current_name = link_name;
new_xbt_graph_edge(graph, previous, current, edges);
static inline double get_solved_value(CpuActionLmmPtr cpu_action)
{
- return cpu_action->p_variable->value;
+ return cpu_action->getVariable()->value;
}
/* In the real world, processes on the guest operating system will be somewhat
if (!ws)
continue;
/* skip if it is not a virtual machine */
- if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
continue;
xbt_assert(cpu, "cpu-less workstation");
double solved_value = get_solved_value(reinterpret_cast<CpuActionLmmPtr>(ws_vm->p_action));
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value,
- ws->m_name, ws_vm->p_subWs->m_name);
+ ws->getName(), ws_vm->p_subWs->getName());
// TODO: check lmm_update_constraint_bound() works fine instead of the below manual substitution.
// cpu_cas01->constraint->bound = solved_value;
- xbt_assert(cpu->p_model == static_cast<ModelPtr>(surf_cpu_model_vm));
- lmm_system_t vcpu_system = cpu->p_model->p_maxminSystem;
- lmm_update_constraint_bound(vcpu_system, cpu->p_constraint, virt_overhead * solved_value);
+ xbt_assert(cpu->getModel() == static_cast<ModelPtr>(surf_cpu_model_vm));
+ lmm_system_t vcpu_system = cpu->getModel()->getMaxminSystem();
+ lmm_update_constraint_bound(vcpu_system, cpu->constraint(), virt_overhead * solved_value);
}
/* skip if it is not a virtual machine */
if (!ws_clm03)
continue;
- if (ws_clm03->p_model != surf_vm_workstation_model)
+ if (ws_clm03->getModel() != surf_vm_workstation_model)
continue;
/* It is a virtual machine, so we can cast it to workstation_VM2013_t */
);
#endif
#if 0
- void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.name);
+ void *ind_sub_host = xbt_lib_get_elm_or_null(host_lib, ws_vm2013->sub_ws->generic_resource.getName);
surf_cpu_model_pm->action_unref(ws_vm2013->cpu_action);
/* FIXME: this means busy loop? */
// ws_vm2013->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_sub_host, GUESTOS_NOISE);
* from the VM name, we have to make sure that the system does not call the
* free callback for the network resource object. The network resource object
* is still used by the physical machine. */
- p_netElm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->m_name, ROUTING_HOST_LEVEL));
+ p_netElm = static_cast<RoutingEdgePtr>(xbt_lib_get_or_null(host_lib, sub_ws->getName(), ROUTING_HOST_LEVEL));
xbt_lib_set(host_lib, name, ROUTING_HOST_LEVEL, p_netElm);
p_subWs = sub_ws;
* If you want to get a workstation_VM2013 object from host_lib, see
* ws->generic_resouce.model->type first. If it is
* SURF_MODEL_TYPE_VM_WORKSTATION, you can cast ws to vm_ws. */
- XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->m_name, xbt_dynar_length(p_storage));
+ XBT_INFO("Create VM(%s)@PM(%s) with %ld mounted disks", name, sub_ws->getName(), xbt_dynar_length(p_storage));
}
/*
WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
{
/* ind_phys_workstation equals to smx_host_t */
- surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
+ surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
/* Before clearing the entries in host_lib, we have to pick up resources. */
CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
* Do not call xbt_lib_remove() here. It deletes all levels of the key,
* including MSG_HOST_LEVEL and others. We should unregister only what we know.
*/
- xbt_lib_unset(host_lib, m_name, SURF_CPU_LEVEL, 0);
- xbt_lib_unset(host_lib, m_name, ROUTING_HOST_LEVEL, 0);
- xbt_lib_unset(host_lib, m_name, SURF_WKS_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
/* TODO: comment out when VM stroage is implemented. */
// xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
WorkstationPtr ws_dst = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(
surf_workstation_resource_priv(ind_dst_pm)));
- const char *vm_name = m_name;
- const char *pm_name_src = p_subWs->m_name;
- const char *pm_name_dst = ws_dst->m_name;
+ const char *vm_name = getName();
+ const char *pm_name_src = p_subWs->getName();
+ const char *pm_name_dst = ws_dst->getName();
xbt_assert(ws_dst);
e_surf_action_state_t state = p_action->getState();
if (state != SURF_ACTION_DONE)
XBT_CRITICAL("FIXME: may need a proper handling, %d", state);
- if (p_action->m_remains > 0)
- XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->m_remains);
+ if (p_action->getRemains() > 0)
+ XBT_CRITICAL("FIXME: need copy the state(?), %f", p_action->getRemains());
int ret = p_action->unref();
xbt_assert(ret == 1, "Bug: some resource still remains");
**/
surf_resource_t WorkstationVMHL13Lmm::getPm()
{
- return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
+ return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
}
/* Adding a task to a VM updates the VCPU task on its physical machine. */
ActionPtr WorkstationVMHL13Lmm::execute(double size)
{
- double old_cost = p_action->m_cost;
+ double old_cost = p_action->getCost();
double new_cost = old_cost + size;
XBT_DEBUG("VM(%s)@PM(%s): update dummy action's cost (%f -> %f)",
- m_name, p_subWs->m_name,
+ getName(), p_subWs->getName(),
old_cost, new_cost);
- p_action->m_cost = new_cost;
+ p_action->setCost(new_cost);
return WorkstationCLM03Lmm::execute(size);
}
WorkstationVM::~WorkstationVM()
{
/* ind_phys_workstation equals to smx_host_t */
- surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, m_name);
+ surf_resource_t ind_vm_workstation = xbt_lib_get_elm_or_null(host_lib, getName());
/* Before clearing the entries in host_lib, we have to pick up resources. */
CpuCas01LmmPtr cpu = dynamic_cast<CpuCas01LmmPtr>(
* Do not call xbt_lib_remove() here. It deletes all levels of the key,
* including MSG_HOST_LEVEL and others. We should unregister only what we know.
*/
- xbt_lib_unset(host_lib, m_name, SURF_CPU_LEVEL, 0);
- xbt_lib_unset(host_lib, m_name, ROUTING_HOST_LEVEL, 0);
- xbt_lib_unset(host_lib, m_name, SURF_WKS_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), SURF_CPU_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), ROUTING_HOST_LEVEL, 0);
+ xbt_lib_unset(host_lib, getName(), SURF_WKS_LEVEL, 0);
/* TODO: comment out when VM stroage is implemented. */
// xbt_lib_unset(host_lib, name, SURF_STORAGE_LEVEL, 0);
**/
surf_resource_t WorkstationVM::getPm()
{
- return xbt_lib_get_elm_or_null(host_lib, p_subWs->m_name);
+ return xbt_lib_get_elm_or_null(host_lib, p_subWs->getName());
}
/**********
sg_platf_host_add_cb(workstation_new);
}
-WorkstationCLM03Model::WorkstationCLM03Model(string name)
+WorkstationCLM03Model::WorkstationCLM03Model(const char *name)
: WorkstationModel(name)
{}
createResource(host->id);
}
-WorkstationPtr WorkstationCLM03Model::createResource(string name){
+WorkstationPtr WorkstationCLM03Model::createResource(const char *name){
- WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name.c_str(), NULL,
- (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name.c_str(), ROUTING_STORAGE_HOST_LEVEL),
- (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name.c_str(), ROUTING_HOST_LEVEL),
- dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name.c_str(), SURF_CPU_LEVEL))));
- XBT_DEBUG("Create workstation %s with %ld mounted disks", name.c_str(), xbt_dynar_length(workstation->p_storage));
- xbt_lib_set(host_lib, name.c_str(), SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
+ WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name, NULL,
+ (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL),
+ (RoutingEdgePtr)xbt_lib_get_or_null(host_lib, name, ROUTING_HOST_LEVEL),
+ dynamic_cast<CpuPtr>(static_cast<ResourcePtr>(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL))));
+ XBT_DEBUG("Create workstation %s with %ld mounted disks", name, xbt_dynar_length(workstation->p_storage));
+ xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(workstation));
return workstation;
}
min_by_sto = surf_storage_model->shareResources(now);
XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_sto %f",
- this, surf_cpu_model_pm->m_name.c_str(), min_by_cpu,
- surf_network_model->m_name.c_str(), min_by_net,
- surf_storage_model->m_name.c_str(), min_by_sto);
+ this, surf_cpu_model_pm->getName(), min_by_cpu,
+ surf_network_model->getName(), min_by_net,
+ surf_storage_model->getName(), min_by_sto);
double res = max(max(min_by_cpu, min_by_net), min_by_sto);
if (min_by_cpu >= 0.0 && min_by_cpu < res)
class WorkstationCLM03Model : virtual public WorkstationModel {
public:
- WorkstationCLM03Model(string name);
+ WorkstationCLM03Model(const char *name);
WorkstationCLM03Model();
~WorkstationCLM03Model();
void parseInit(sg_platf_host_cbarg_t host);
- WorkstationPtr createResource(string name);
+ WorkstationPtr createResource(const char *name);
double shareResources(double now);
void updateActionsState(double now, double delta);
/*********
* Model *
*********/
-WorkstationModel::WorkstationModel(string name)
+WorkstationModel::WorkstationModel(const char *name)
: Model(name)
{
p_cpuModel = surf_cpu_model_pm;
if (!ws)
continue;
/* skip if it is not a virtual machine */
- if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
continue;
xbt_assert(cpu_cas01, "cpu-less workstation");
/* It is a virtual machine, so we can cast it to workstation_VM2013_t */
WorkstationVMLmmPtr ws_vm = dynamic_cast<WorkstationVMLmmPtr>(ws);
- int is_active = lmm_constraint_used(cpu_cas01->p_model->p_maxminSystem, cpu_cas01->p_constraint);
+ int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->constraint());
// int is_active_old = constraint_is_active(cpu_cas01);
// {
xbt_dict_t Workstation::getProperties()
{
- return p_cpu->m_properties;
+ return p_cpu->getProperties();
}
s_mount_t mnt;
unsigned int cursor;
- XBT_DEBUG("Search for storage name '%s' on '%s'", mount, m_name);
+ XBT_DEBUG("Search for storage name '%s' on '%s'", mount, getName());
xbt_dynar_foreach(p_storage,cursor,mnt)
{
XBT_DEBUG("See '%s'",mnt.name);
break;
}
}
- if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, m_name);
+ if(!st) xbt_die("Can't find mount '%s' for '%s'", mount, getName());
return st;
}
char *storage_name = NULL;
xbt_dynar_foreach(p_storage,i,mnt){
- storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->m_name;
+ storage_name = (char *)dynamic_cast<StoragePtr>(static_cast<ResourcePtr>(mnt.storage))->getName();
xbt_dict_set(storage_list,mnt.name,storage_name,NULL);
}
return storage_list;
ActionPtr Workstation::open(const char* mount, const char* path) {
StoragePtr st = findStorageOnMountList(mount);
- XBT_DEBUG("OPEN on disk '%s'", st->m_name);
+ XBT_DEBUG("OPEN on disk '%s'", st->getName());
return st->open(mount, path);
}
ActionPtr Workstation::close(surf_file_t fd) {
StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("CLOSE on disk '%s'",st->m_name);
+ XBT_DEBUG("CLOSE on disk '%s'",st->getName());
return st->close(fd);
}
ActionPtr Workstation::read(surf_file_t fd, sg_size_t size) {
StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("READ on disk '%s'",st->m_name);
+ XBT_DEBUG("READ on disk '%s'",st->getName());
return st->read(fd, size);
}
ActionPtr Workstation::write(surf_file_t fd, sg_size_t size) {
StoragePtr st = findStorageOnMountList(fd->mount);
- XBT_DEBUG("WRITE on disk '%s'",st->m_name);
+ XBT_DEBUG("WRITE on disk '%s'",st->getName());
return st->write(fd, size);
}
/* Check if the file is on this storage */
if (!xbt_dict_get_or_null(st->p_content, fd->name)){
XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name,
- st->m_name);
+ st->getName());
return 0;
} else {
- XBT_DEBUG("UNLINK on disk '%s'",st->m_name);
+ XBT_DEBUG("UNLINK on disk '%s'",st->getName());
st->m_usedSize -= fd->size;
// Remove the file from storage
xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL);
xbt_dynar_push_as(info, sg_size_t *, psize);
xbt_dynar_push_as(info, void *, fd->mount);
- xbt_dynar_push_as(info, void *, (void *)st->m_name);
+ xbt_dynar_push_as(info, void *, (void *)st->getName());
xbt_dynar_push_as(info, void *, st->p_typeId);
xbt_dynar_push_as(info, void *, st->p_contentType);
if (!ws)
continue;
/* skip if it is not a virtual machine */
- if (ws->p_model != static_cast<ModelPtr>(surf_vm_workstation_model))
+ if (ws->getModel() != static_cast<ModelPtr>(surf_vm_workstation_model))
continue;
/* It is a virtual machine, so we can cast it to workstation_VM2013_t */
*********/
class WorkstationModel : public Model {
public:
- WorkstationModel(string name);
+ WorkstationModel(const char *name);
WorkstationModel();
~WorkstationModel();
virtual void adjustWeightOfDummyCpuActions();
void *_action;
WorkstationL07ActionLmmPtr action;
- xbt_swag_t running_actions = this->p_runningActionSet;
+ xbt_swag_t running_actions = getRunningActionSet();
double min = this->shareResourcesMaxMin(running_actions,
ptask_maxmin_system,
bottleneck_solve);
if (min < 0) {
min = action->m_latency;
XBT_DEBUG("Updating min (value) with %p (start %f): %f", action,
- action->m_start, min);
+ action->getStartTime(), min);
} else if (action->m_latency < min) {
min = action->m_latency;
XBT_DEBUG("Updating min (latency) with %p (start %f): %f", action,
- action->m_start, min);
+ action->getStartTime(), min);
}
}
}
void *_action, *_next_action;
WorkstationL07ActionLmmPtr action;
- xbt_swag_foreach_safe(_action, _next_action, p_runningActionSet) {
+ xbt_swag_t actionSet = getRunningActionSet();
+ xbt_swag_foreach_safe(_action, _next_action, actionSet) {
action = dynamic_cast<WorkstationL07ActionLmmPtr>(static_cast<ActionPtr>(_action));
deltap = delta;
double_update(&(deltap), action->m_latency);
action->m_latency = 0.0;
}
- if ((action->m_latency == 0.0) && (action->m_suspended == 0)) {
+ if ((action->m_latency == 0.0) && (action->isSuspended() == 0)) {
action->updateBound();
- lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 1.0);
+ lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 1.0);
}
}
XBT_DEBUG("Action (%p) : remains (%g) updated by %g.",
- action, action->m_remains, lmm_variable_getvalue(action->p_variable) * delta);
- double_update(&(action->m_remains), lmm_variable_getvalue(action->p_variable) * delta);
+ action, action->getRemains(), lmm_variable_getvalue(action->getVariable()) * delta);
+ action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
- if (action->m_maxDuration != NO_MAX_DURATION)
- double_update(&(action->m_maxDuration), delta);
+ if (action->getMaxDuration() != NO_MAX_DURATION)
+ action->updateMaxDuration(delta);
XBT_DEBUG("Action (%p) : remains (%g).",
- action, action->m_remains);
- if ((action->m_remains <= 0) &&
- (lmm_get_variable_weight(action->p_variable) > 0)) {
- action->m_finish = surf_get_clock();
+ action, action->getRemains());
+ if ((action->getRemains() <= 0) &&
+ (lmm_get_variable_weight(action->getVariable()) > 0)) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
- } else if ((action->m_maxDuration != NO_MAX_DURATION) &&
- (action->m_maxDuration <= 0)) {
- action->m_finish = surf_get_clock();
+ } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
+ (action->getMaxDuration() <= 0)) {
+ action->finish();
action->setState(SURF_ACTION_DONE);
} else {
/* Need to check that none of the model has failed */
int i = 0;
void *constraint_id = NULL;
- while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->p_variable,
+ while ((cnst = lmm_get_cnst_from_var(ptask_maxmin_system, action->getVariable(),
i++))) {
constraint_id = lmm_constraint_id(cnst);
- if (static_cast<WorkstationLmmPtr>(constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
+ if (static_cast<WorkstationLmmPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
XBT_DEBUG("Action (%p) Failed!!", action);
- action->m_finish = surf_get_clock();
+ action->finish();
action->setState(SURF_ACTION_FAILED);
break;
}
xbt_dynar_foreach(route, cpt, _link) {
link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
- xbt_dict_set(ptask_parallel_task_link_set, link->m_name, link, NULL);
+ xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL);
}
}
}
workstation_nb + nb_link);
if (action->m_latency > 0)
- lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
+ lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
for (i = 0; i < workstation_nb; i++)
lmm_expand(ptask_maxmin_system,
static_cast<CpuLmmPtr>(dynamic_cast<WorkstationL07Ptr>(
- static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->p_constraint,
- action->p_variable, computation_amount[i]);
+ static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->constraint(),
+ action->getVariable(), computation_amount[i]);
for (i = 0; i < workstation_nb; i++) {
for (j = 0; j < workstation_nb; j++) {
xbt_dynar_foreach(route, cpt, _link) {
link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
- lmm_expand_add(ptask_maxmin_system, link->p_constraint,
- action->p_variable,
+ lmm_expand_add(ptask_maxmin_system, link->constraint(),
+ action->getVariable(),
communication_amount[i * workstation_nb + j]);
}
}
}
if (nb_link + nb_host == 0) {
- action->m_cost = 1.0;
- action->m_remains = 0.0;
+ action->setCost(1.0);
+ action->setRemains(0.0);
}
return static_cast<ActionPtr>(action);
tmgr_trace_t state_trace,
xbt_dict_t cpu_properties)
{
- CpuL07Ptr cpu = NULL;
xbt_assert(!surf_workstation_resource_priv(surf_workstation_resource_by_name(name)),
"Host '%s' declared several times in the platform file.",
name);
- cpu = new CpuL07(this, name, cpu_properties);
-
- cpu->p_power.scale = power_scale;
- xbt_assert(cpu->p_power.scale > 0, "Power has to be >0");
-
- cpu->m_powerCurrent = power_initial;
- if (power_trace)
- cpu->p_power.event =
- tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
-
- cpu->p_stateCurrent = state_initial;
- if (state_trace)
- cpu->p_stateEvent =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(cpu));
-
- cpu->p_constraint =
- lmm_constraint_new(ptask_maxmin_system, cpu,
- cpu->m_powerCurrent * cpu->p_power.scale);
+ CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties,
+ power_scale, power_initial, power_trace,state_initial, state_trace);
xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
e_surf_resource_state_t
state_initial,
tmgr_trace_t state_trace,
- e_surf_link_sharing_policy_t
- policy, xbt_dict_t properties)
+ e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties)
{
- LinkL07Ptr nw_link = new LinkL07(this, name, properties);
xbt_assert(!xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL),
- "Link '%s' declared several times in the platform file.",
- name);
+ "Link '%s' declared several times in the platform file.",
+ name);
- nw_link->m_bwCurrent = bw_initial;
- if (bw_trace)
- nw_link->p_bwEvent =
- tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
- nw_link->p_stateCurrent = state_initial;
- nw_link->m_latCurrent = lat_initial;
- if (lat_trace)
- nw_link->p_latEvent =
- tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
- if (state_trace)
- nw_link->p_stateEvent =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(nw_link));
-
- nw_link->p_constraint =
- lmm_constraint_new(ptask_maxmin_system, nw_link,
- nw_link->m_bwCurrent);
-
- if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(nw_link->p_constraint);
+ LinkL07Ptr nw_link = new LinkL07(this, name, properties,
+ bw_initial, bw_trace,
+ lat_initial, lat_trace,
+ state_initial, state_trace,
+ policy);
xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<ResourcePtr>(nw_link));
return nw_link;
return 0.0;
}
-CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
- : Resource(model, name, props), CpuLmm() {
+CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props,
+ double power_scale,
+ double power_initial, tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial, tmgr_trace_t state_trace)
+ : Resource(model, name, props)
+ , CpuLmm(lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale))
+{
+ p_power.scale = power_scale;
+ xbt_assert(p_power.scale > 0, "Power has to be >0");
+ m_powerCurrent = power_initial;
+ if (power_trace)
+ p_power.event = tmgr_history_add_trace(history, power_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+
+ m_stateCurrent = state_initial;
+ if (state_trace)
+ p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
}
-LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props)
- : Resource(model, name, props), NetworkLinkLmm() {
+LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy)
+ : Resource(model, name, props)
+ , NetworkLinkLmm(lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
+{
+ m_bwCurrent = bw_initial;
+ if (bw_trace)
+ p_bwEvent = tmgr_history_add_trace(history, bw_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+
+ m_stateCurrent = state_initial;
+ m_latCurrent = lat_initial;
+
+ if (lat_trace)
+ p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast<ResourcePtr>(this));
+ if (policy == SURF_LINK_FATPIPE)
+ lmm_constraint_shared(constraint());
}
bool CpuL07::isUsed(){
- return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+ return lmm_constraint_used(ptask_maxmin_system, constraint());
}
bool LinkL07::isUsed(){
- return lmm_constraint_used(ptask_maxmin_system, p_constraint);
+ return lmm_constraint_used(ptask_maxmin_system, constraint());
}
void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
- XBT_DEBUG("Updating cpu %s (%p) with value %g", m_name, this, value);
+ XBT_DEBUG("Updating cpu %s (%p) with value %g", getName(), this, value);
if (event_type == p_power.event) {
m_powerCurrent = value;
- lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_powerCurrent * p_power.scale);
+ lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_powerCurrent * p_power.scale);
if (tmgr_trace_event_free(event_type))
p_power.event = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- p_stateCurrent = SURF_RESOURCE_ON;
+ m_stateCurrent = SURF_RESOURCE_ON;
else
- p_stateCurrent = SURF_RESOURCE_OFF;
+ m_stateCurrent = SURF_RESOURCE_OFF;
if (tmgr_trace_event_free(event_type))
p_stateEvent = NULL;
} else {
}
void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double date){
- XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", m_name, this, value, date);
+ XBT_DEBUG("Updating link %s (%p) with value=%f for date=%g", getName(), this, value, date);
if (event_type == p_bwEvent) {
m_bwCurrent = value;
- lmm_update_constraint_bound(ptask_maxmin_system, p_constraint, m_bwCurrent);
+ lmm_update_constraint_bound(ptask_maxmin_system, constraint(), m_bwCurrent);
if (tmgr_trace_event_free(event_type))
p_bwEvent = NULL;
} else if (event_type == p_latEvent) {
lmm_element_t elem = NULL;
m_latCurrent = value;
- while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, p_constraint, &elem))) {
+ while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, constraint(), &elem))) {
action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
action->updateBound();
}
p_latEvent = NULL;
} else if (event_type == p_stateEvent) {
if (value > 0)
- p_stateCurrent = SURF_RESOURCE_ON;
+ m_stateCurrent = SURF_RESOURCE_ON;
else
- p_stateCurrent = SURF_RESOURCE_OFF;
+ m_stateCurrent = SURF_RESOURCE_OFF;
if (tmgr_trace_event_free(event_type))
p_stateEvent = NULL;
} else {
e_surf_resource_state_t WorkstationL07::getState()
{
- return p_cpu->p_stateCurrent;
+ return p_cpu->getState();
}
e_surf_resource_state_t CpuL07::getState()
{
- return p_stateCurrent;
+ return m_stateCurrent;
}
double CpuL07::getSpeed(double load)
communication_amount[0] = 0.0;
computation_amount[0] = size;
- return static_cast<WorkstationL07ModelPtr>(p_model)->executeParallelTask(1, workstation_list,
+ return static_cast<WorkstationL07ModelPtr>(getModel())->executeParallelTask(1, workstation_list,
computation_amount,
communication_amount, -1);
}
{
WorkstationL07ActionLmmPtr action = NULL;
- XBT_IN("(%s,%g)", m_name, duration);
+ XBT_IN("(%s,%g)", getName(), duration);
action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
action->m_maxDuration = duration;
action->m_suspended = 2;
- lmm_update_variable_weight(ptask_maxmin_system, action->p_variable, 0.0);
+ lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
XBT_OUT();
return action;
bool LinkL07::isShared()
{
- return lmm_constraint_is_shared(p_constraint);
+ return lmm_constraint_is_shared(constraint());
}
/**********
free(p_workstationList);
free(p_communicationAmount);
free(p_computationAmount);
-#ifdef HAVE_TRACING
- xbt_free(p_category);
-#endif
}
void WorkstationL07ActionLmm::updateBound()
XBT_DEBUG("action (%p) : lat_bound = %g", this, lat_bound);
if ((m_latency == 0.0) && (m_suspended == 0)) {
if (m_rate < 0)
- lmm_update_variable_bound(ptask_maxmin_system, p_variable, lat_bound);
+ lmm_update_variable_bound(ptask_maxmin_system, getVariable(), lat_bound);
else
- lmm_update_variable_bound(ptask_maxmin_system, p_variable, min(m_rate, lat_bound));
+ lmm_update_variable_bound(ptask_maxmin_system, getVariable(), min(m_rate, lat_bound));
}
}
m_refcount--;
if (!m_refcount) {
xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
- if (p_variable)
- lmm_variable_free(ptask_maxmin_system, p_variable);
+ if (getVariable())
+ lmm_variable_free(ptask_maxmin_system, getVariable());
delete this;
return 1;
}
XBT_IN("(%p))", this);
if (m_suspended != 2) {
m_suspended = 1;
- lmm_update_variable_weight(ptask_maxmin_system, p_variable, 0.0);
+ lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 0.0);
}
XBT_OUT();
}
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
- lmm_update_variable_weight(ptask_maxmin_system, p_variable, 1.0);
+ lmm_update_variable_weight(ptask_maxmin_system, getVariable(), 1.0);
m_suspended = 0;
}
XBT_OUT();
return m_remains;
}
-/*static void ptask_finalize(void)
+/*FIXME:remove static void ptask_finalize(void)
{
xbt_dict_free(&ptask_parallel_task_link_set);
/******* Resource Private **********/
/**************************************/
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
/**************************************/
/*** Resource Creation & Destruction **/
/**************************************/
class CpuL07 : public CpuLmm {
public:
- CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties);
+ s_surf_metric_t p_power;
+ tmgr_trace_event_t p_stateEvent;
+
+public:
+ CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties,
+ double power_scale,
+ double power_initial, tmgr_trace_t power_trace,
+ e_surf_resource_state_t state_initial, tmgr_trace_t state_trace);
bool isUsed();
//bool isUsed() {DIE_IMPOSSIBLE;};
void updateState(tmgr_trace_event_t event_type, double value, double date);
e_surf_resource_state_t getState();
double getSpeed(double load);
double getAvailableSpeed();
- ActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
- ActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
+ CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;};
+ CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
class LinkL07 : public NetworkLinkLmm {
public:
- LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props);
+ LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
+ double bw_initial,
+ tmgr_trace_t bw_trace,
+ double lat_initial,
+ tmgr_trace_t lat_trace,
+ e_surf_resource_state_t
+ state_initial,
+ tmgr_trace_t state_trace,
+ e_surf_link_sharing_policy_t policy);
~LinkL07(){
};
bool isUsed();
* Action *
**********/
class WorkstationL07ActionLmm : public WorkstationActionLmm {
+ friend ActionPtr WorkstationL07::execute(double size);
+ friend ActionPtr WorkstationL07::sleep(double duration);
+ friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double
+ *computation_amount, double
+ *communication_amount,
+ double rate);
public:
WorkstationL07ActionLmm(ModelPtr model, double cost, bool failed)
: Action(model, cost, failed), WorkstationActionLmm() {};