"Power has to be >0.0");
xbt_assert(core > 0, "Invalid number of cores %d", core);
- cpu = new CpuCas01Lmm(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
+ cpu = new CpuCas01(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
return cpu;
/* connect all traces relative to hosts */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01LmmPtr host = static_cast<CpuCas01LmmPtr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
+ CpuCas01Ptr host = static_cast<CpuCas01Ptr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01LmmPtr host = dynamic_cast<CpuCas01LmmPtr>(static_cast<ResourcePtr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm))));
+ CpuCas01Ptr host = dynamic_cast<CpuCas01Ptr>(static_cast<ResourcePtr>(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm))));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
/************
* Resource *
************/
-CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model_, const char *name, xbt_dynar_t powerPeak,
+CpuCas01::CpuCas01(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(lmm_constraint_new(getModel()->getMaxminSystem(), this, core * powerScale * xbt_dynar_get_as(powerPeak, pstate, double)),
- core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
+: Cpu(model, name, properties,
+ lmm_constraint_new(model->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;
p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
}
-CpuCas01Lmm::~CpuCas01Lmm(){
+CpuCas01::~CpuCas01(){
unsigned int iter;
xbt_dynar_t power_tuple = NULL;
xbt_dynar_foreach(p_energy->power_range_watts_list, iter, power_tuple)
xbt_free(p_energy);
}
-bool CpuCas01Lmm::isUsed()
+bool CpuCas01::isUsed()
{
- return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
+ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
}
-void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, double date)
+void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double date)
{
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
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->getMaxminSystem(), constraint(),
+ lmm_update_constraint_bound(surf_cpu_model_pm->getMaxminSystem(), getConstraint(),
m_core * m_powerScale *
m_powerPeak);
#ifdef HAVE_TRACING
m_powerPeak);
#endif
while ((var = lmm_get_var_from_cnst
- (surf_cpu_model_pm->getMaxminSystem(), constraint(), &elem))) {
- CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
+ (surf_cpu_model_pm->getMaxminSystem(), getConstraint(), &elem))) {
+ CpuCas01ActionPtr action = static_cast<CpuCas01ActionPtr>(static_cast<ActionPtr>(lmm_variable_id(var)));
lmm_update_variable_bound(surf_cpu_model_pm->getMaxminSystem(),
action->getVariable(),
xbt_dynar_push_as(host_that_restart, char*, (char *)getName());
m_stateCurrent = SURF_RESOURCE_ON;
} else {
- lmm_constraint_t cnst = constraint();
+ lmm_constraint_t cnst = getConstraint();
m_stateCurrent = SURF_RESOURCE_OFF;
while ((var = lmm_get_var_from_cnst(surf_cpu_model_pm->getMaxminSystem(), cnst, &elem))) {
- ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
+ ActionPtr action = static_cast<ActionPtr>(lmm_variable_id(var));
if (action->getState() == SURF_ACTION_RUNNING ||
action->getState() == SURF_ACTION_READY ||
return;
}
-CpuActionPtr CpuCas01Lmm::execute(double size)
+CpuActionPtr CpuCas01::execute(double size)
{
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());
+ CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, size, m_stateCurrent != SURF_RESOURCE_ON,
+ m_powerScale * m_powerPeak, getConstraint());
XBT_OUT();
return action;
}
-CpuActionPtr CpuCas01Lmm::sleep(double duration)
+CpuActionPtr CpuCas01::sleep(double duration)
{
if (duration > 0)
duration = MAX(duration, MAXMIN_PRECISION);
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());
+ CpuCas01ActionPtr action = new CpuCas01Action(surf_cpu_model_pm, 1.0, m_stateCurrent != SURF_RESOURCE_ON,
+ m_powerScale * m_powerPeak, getConstraint());
// FIXME: sleep variables should not consume 1.0 in lmm_expand
return action;
}
-xbt_dynar_t CpuCas01Lmm::getWattsRangeList()
+xbt_dynar_t CpuCas01::getWattsRangeList()
{
xbt_dynar_t power_range_list;
xbt_dynar_t power_tuple;
* Computes the power consumed by the host according to the current pstate and processor load
*
*/
-double CpuCas01Lmm::getCurrentWattsValue(double cpu_load)
+double CpuCas01::getCurrentWattsValue(double cpu_load)
{
xbt_dynar_t power_range_list = p_energy->power_range_watts_list;
* Updates the total energy consumed as the sum of the current energy and
* the energy consumed by the current action
*/
-void CpuCas01Lmm::updateEnergy(double cpu_load)
+void CpuCas01::updateEnergy(double cpu_load)
{
double start_time = p_energy->last_updated;
double finish_time = surf_get_clock();
XBT_DEBUG("[cpu_update_energy] old_energy_value=%f, action_energy_value=%f", current_energy, action_energy);
}
-double CpuCas01Lmm::getCurrentPowerPeak()
+double CpuCas01::getCurrentPowerPeak()
{
return m_powerPeak;
}
-double CpuCas01Lmm::getPowerPeakAt(int pstate_index)
+double CpuCas01::getPowerPeakAt(int pstate_index)
{
xbt_dynar_t plist = p_powerPeakList;
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
return xbt_dynar_get_as(plist, pstate_index, double);
}
-int CpuCas01Lmm::getNbPstates()
+int CpuCas01::getNbPstates()
{
return xbt_dynar_length(p_powerPeakList);
}
-void CpuCas01Lmm::setPowerPeakAt(int pstate_index)
+void CpuCas01::setPowerPeakAt(int pstate_index)
{
xbt_dynar_t plist = p_powerPeakList;
xbt_assert((pstate_index <= (int)xbt_dynar_length(plist)), "Invalid parameters (pstate index out of bounds)");
m_powerPeak = new_power_peak;
}
-double CpuCas01Lmm::getConsumedEnergy()
+double CpuCas01::getConsumedEnergy()
{
return p_energy->total_energy;
}
* 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))
+CpuCas01Action::CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint)
+ : CpuAction(model, cost, failed,
+ lmm_variable_new(model->getMaxminSystem(), static_cast<ActionPtr>(this),
+ 1.0, power, 1))
{
m_suspended = 0; /* Should be useless because of the
calloc but it seems to help valgrind... */
- if (getModel()->getUpdateMechanism() == UM_LAZY) {
+ if (model->getUpdateMechanism() == UM_LAZY) {
m_indexHeap = -1;
m_lastUpdate = surf_get_clock();
m_lastValue = 0.0;
}
- lmm_expand(getModel()->getMaxminSystem(), constraint, getVariable(), 1.0);
+ lmm_expand(model->getMaxminSystem(), constraint, getVariable(), 1.0);
}
* Update the CPU total energy for a finished action
*
*/
-void CpuCas01ActionLmm::updateEnergy()
+void CpuCas01Action::updateEnergy()
{
- CpuCas01LmmPtr cpu = static_cast<CpuCas01LmmPtr>(lmm_constraint_id(lmm_get_cnst_from_var
+ CpuCas01Ptr cpu = static_cast<CpuCas01Ptr>(lmm_constraint_id(lmm_get_cnst_from_var
(getModel()->getMaxminSystem(),
getVariable(), 0)));
if(cpu->p_energy->last_updated < surf_get_clock()) {
- double load = lmm_constraint_get_usage(cpu->constraint()) / cpu->m_powerPeak;
+ double load = lmm_constraint_get_usage(cpu->getConstraint()) / cpu->m_powerPeak;
cpu->updateEnergy(load);
}
}
class CpuCas01Model;
typedef CpuCas01Model *CpuCas01ModelPtr;
-class CpuCas01Lmm;
-typedef CpuCas01Lmm *CpuCas01LmmPtr;
+class CpuCas01;
+typedef CpuCas01 *CpuCas01Ptr;
-class CpuCas01ActionLmm;
-typedef CpuCas01ActionLmm *CpuCas01ActionLmmPtr;
+class CpuCas01Action;
+typedef CpuCas01Action *CpuCas01ActionPtr;
/*********
* Model *
double last_updated; /*< Timestamp of the last energy update event*/
} s_energy_cpu_cas01_t, *energy_cpu_cas01_t;
-class CpuCas01Lmm : public CpuLmm {
+class CpuCas01 : public Cpu {
public://FIXME:
tmgr_trace_event_t p_stateEvent;
public:
- CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
+ CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak,
int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
xbt_dict_t properties) ;
- ~CpuCas01Lmm();
+ ~CpuCas01();
void updateState(tmgr_trace_event_t event_type, double value, double date);
CpuActionPtr execute(double size);
CpuActionPtr sleep(double duration);
/**********
* Action *
**********/
-class CpuCas01ActionLmm: public CpuActionLmm {
- friend CpuActionPtr CpuCas01Lmm::execute(double size);
- friend CpuActionPtr CpuCas01Lmm::sleep(double duration);
+class CpuCas01Action: public CpuAction {
+ friend CpuActionPtr CpuCas01::execute(double size);
+ friend CpuActionPtr CpuCas01::sleep(double duration);
public:
- CpuCas01ActionLmm() {};
- CpuCas01ActionLmm(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
+ CpuCas01Action() {};
+ CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint);
- ~CpuCas01ActionLmm() {};
+ ~CpuCas01Action() {};
void updateEnergy();
};
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
- CpuActionLmmPtr action;
+ CpuActionPtr action;
while ((xbt_heap_size(getActionHeap()) > 0)
&& (double_equals(xbt_heap_maxkey(getActionHeap()), now))) {
- action = dynamic_cast<CpuActionLmmPtr>(static_cast<ActionLmmPtr>(xbt_heap_pop(getActionHeap())));
+ action = static_cast<CpuActionPtr>(static_cast<ActionPtr>(xbt_heap_pop(getActionHeap())));
XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
ActionListPtr actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
; it != itend ; ++it) {
- action = dynamic_cast<CpuActionLmmPtr>(&*it);
+ action = static_cast<CpuActionPtr>(&*it);
if (smaller < 0) {
smaller = action->getLastUpdate();
continue;
void CpuModel::updateActionsStateFull(double now, double delta)
{
- CpuActionLmmPtr action = NULL;
+ CpuActionPtr action = NULL;
ActionListPtr running_actions = getRunningActionSet();
for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
; it != itend ; it=itNext) {
++itNext;
- action = dynamic_cast<CpuActionLmmPtr>(&*it);
+ action = static_cast<CpuActionPtr>(&*it);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var
* Resource *
************/
-Cpu::Cpu(int core, double powerPeak, double powerScale)
- : m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
+Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
+ int core, double powerPeak, double powerScale)
+ : Resource(model, name, props)
+ , m_core(core)
+ , m_powerPeak(powerPeak)
+ , m_powerScale(powerScale)
+ , p_constraintCore(NULL)
+ , p_constraintCoreId(NULL)
{}
+Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint, int core, double powerPeak, double powerScale)
+ : Resource(model, name, props, constraint)
+ , m_core(core)
+ , m_powerPeak(powerPeak)
+ , m_powerScale(powerScale)
+{
+ /* At now, we assume that a VM does not have a multicore CPU. */
+ if (core > 1)
+ xbt_assert(model == surf_cpu_model_pm);
+
+ p_constraintCore = NULL;
+ p_constraintCoreId = NULL;
+ if (model->getUpdateMechanism() != UM_UNDEFINED) {
+ 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(model->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
+ }
+ }
+}
+
+Cpu::~Cpu(){
+ if (getModel()->getUpdateMechanism() != UM_UNDEFINED){
+ for (int i = 0; i < m_core; i++) {
+ xbt_free(p_constraintCoreId[i]);
+ }
+ xbt_free(p_constraintCore);
+ xbt_free(p_constraintCoreId);
+ }
+}
+
double Cpu::getSpeed(double load)
{
return load * m_powerPeak;
return m_core;
}
-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(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", getName(), i);
- p_constraintCore[i] = lmm_constraint_new(getModel()->getMaxminSystem(), p_constraintCoreId[i], m_powerScale * m_powerPeak);
- }
-}
-
-CpuLmm::~CpuLmm(){
- if (p_constraintCore){
- for (int i = 0; i < m_core; i++) {
- xbt_free(p_constraintCoreId[i]);
- }
- xbt_free(p_constraintCore);
- xbt_free(p_constraintCoreId);
- }
-}
-
/**********
* Action *
**********/
-void CpuActionLmm::updateRemainingLazy(double now)
+void CpuAction::updateRemainingLazy(double now)
{
double delta = 0.0;
m_lastValue = lmm_variable_getvalue(getVariable());
}
-void CpuActionLmm::setBound(double bound)
+void CpuAction::setBound(double bound)
{
XBT_IN("(%p,%g)", this, bound);
m_bound = bound;
* action object does not have the information about the location where the
* action is being executed.
*/
-void CpuActionLmm::setAffinity(CpuPtr _cpu, unsigned long mask)
+void CpuAction::setAffinity(CpuPtr cpu, unsigned long mask)
{
lmm_variable_t var_obj = getVariable();
- CpuLmmPtr cpu = reinterpret_cast<CpuLmmPtr>(_cpu);
XBT_IN("(%p,%lx)", this, mask);
{
class Cpu;
typedef Cpu *CpuPtr;
-class CpuLmm;
-typedef CpuLmm *CpuLmmPtr;
-
class CpuAction;
typedef CpuAction *CpuActionPtr;
-class CpuActionLmm;
-typedef CpuActionLmm *CpuActionLmmPtr;
-
/*********
* Model *
*********/
/************
* Resource *
************/
-class Cpu : virtual public Resource {
+class Cpu : public Resource {
public:
Cpu(){};
- Cpu(int core, double powerPeak, double powerScale);
+ /*Cpu(lmm_constraint_t constraint);*/
+ Cpu(ModelPtr model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint, int core, double powerPeak, double powerScale);
+ Cpu(ModelPtr model, const char *name, xbt_dict_t props,
+ int core, double powerPeak, double powerScale);
+ ~Cpu();
virtual CpuActionPtr execute(double size)=0;
virtual CpuActionPtr sleep(double duration)=0;
virtual int getCore();
int m_core;
double m_powerPeak; /*< CPU power peak */
double m_powerScale; /*< Percentage of CPU disponible */
-protected:
- //virtual boost::shared_ptr<Action> execute(double size) = 0;
- //virtual boost::shared_ptr<Action> sleep(double duration) = 0;
-};
-
-class CpuLmm : public ResourceLmm, public Cpu {
-public:
- CpuLmm(lmm_constraint_t constraint);
- CpuLmm(lmm_constraint_t constraint, int core, double powerPeak, double powerScale);
- ~CpuLmm();
/* Note (hypervisor): */
lmm_constraint_t *p_constraintCore;
void **p_constraintCoreId;
-
};
/**********
* Action *
**********/
-class CpuAction : virtual public Action {
+class CpuAction : public Action {
public:
CpuAction(){};
CpuAction(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed) {};//FIXME:REMOVE
- virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
- virtual void setBound(double bound)=0;
-};
+ : Action(model, cost, failed) {} //FIXME:REMOVE
+ CpuAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
+ : Action(model, cost, failed, var) {}
+ virtual void setAffinity(CpuPtr cpu, unsigned long mask);
+ virtual void setBound(double bound);
-class CpuActionLmm : public ActionLmm, public CpuAction {
-public:
- CpuActionLmm(){};
- CpuActionLmm(lmm_variable_t var)
- : ActionLmm(var), CpuAction() {};
void updateRemainingLazy(double now);
virtual void updateEnergy()=0;
- void setAffinity(CpuPtr cpu, unsigned long mask);
- void setBound(double bound);
double m_bound;
};
-
#endif /* SURF_CPU_INTERFACE_HPP_ */
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)
-, Cpu(core, 0, powerScale) {
+: Cpu(model, name, properties, core, 0, powerScale)
+{
p_powerEvent = NULL;
m_stateCurrent = stateInitial;
m_powerScale = powerScale;
CpuTiAction::CpuTiAction(CpuTiModelPtr model_, double cost, bool failed,
CpuTiPtr cpu)
- : Action(model_, cost, failed)
- , CpuAction(model_, cost, failed)
+ : CpuAction(model_, cost, failed)
{
p_cpuListHookup.next = 0;
p_cpuListHookup.prev = 0;
double getRemains();
void setAffinity(CpuPtr /*cpu*/, unsigned long /*mask*/) {};
void setBound(double /*bound*/) {};
+ void updateEnergy() {};
CpuTiPtr p_cpu;
int m_indexHeap;
obj += var->mu * var->bound;
}
- xbt_swag_foreach(_cnst, cnst_list)
+ xbt_swag_foreach(_cnst, cnst_list) {
cnst = (lmm_constraint_t)_cnst;
obj += cnst->lambda * cnst->bound;
+ }
return obj;
}
cnst->usage = elem->value / elem->variable->weight;
make_elem_active(elem);
- ActionLmmPtr action = static_cast<ActionLmmPtr>(elem->variable->id);
+ ActionPtr action = static_cast<ActionPtr>(elem->variable->id);
if (sys->keep_track && !action->is_linked())
sys->keep_track->push_back(*action);
}
/* connect all traces relative to network */
xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- NetworkCm02LinkLmmPtr link = dynamic_cast<NetworkCm02LinkLmmPtr>(
+ NetworkCm02LinkPtr link = dynamic_cast<NetworkCm02LinkPtr>(
static_cast<ResourcePtr>(
xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- NetworkCm02LinkLmmPtr link = dynamic_cast<NetworkCm02LinkLmmPtr>(
+ NetworkCm02LinkPtr link = dynamic_cast<NetworkCm02LinkPtr>(
static_cast<ResourcePtr>(
xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- NetworkCm02LinkLmmPtr link = dynamic_cast<NetworkCm02LinkLmmPtr>(
+ NetworkCm02LinkPtr link = dynamic_cast<NetworkCm02LinkPtr>(
static_cast<ResourcePtr>(
xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
"Link '%s' declared several times in the platform file.",
name);
- NetworkCm02LinkLmmPtr nw_link =
- new NetworkCm02LinkLmm(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history,
+ NetworkCm02LinkPtr nw_link =
+ new NetworkCm02Link(this, name, properties, p_maxminSystem, sg_bandwidth_factor * bw_initial, history,
state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
{
- NetworkCm02ActionLmmPtr action;
+ NetworkCm02ActionPtr action;
while ((xbt_heap_size(p_actionHeap) > 0)
&& (double_equals(xbt_heap_maxkey(p_actionHeap), now))) {
- action = (NetworkCm02ActionLmmPtr) xbt_heap_pop(p_actionHeap);
+ action = (NetworkCm02ActionPtr) xbt_heap_pop(p_actionHeap);
XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
if (TRACE_is_enabled()) {
lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
action->getVariable(),
i);
- NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(lmm_constraint_id(constraint));
+ NetworkCm02LinkPtr link = static_cast<NetworkCm02LinkPtr>(lmm_constraint_id(constraint));
TRACE_surf_link_set_utilization(link->getName(),
action->getCategory(),
(lmm_variable_getvalue(action->getVariable())*
{
unsigned int i;
void *_link;
- NetworkCm02LinkLmmPtr link;
+ NetworkCm02LinkPtr link;
int failed = 0;
- NetworkCm02ActionLmmPtr action = NULL;
+ NetworkCm02ActionPtr action = NULL;
double bandwidth_bound;
double latency = 0.0;
xbt_dynar_t back_route = NULL;
src->p_name, dst->p_name);
xbt_dynar_foreach(route, i, _link) {
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
if (link->getState() == SURF_RESOURCE_OFF) {
failed = 1;
break;
if (sg_network_crosstraffic == 1) {
routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
xbt_dynar_foreach(back_route, i, _link) {
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
if (link->getState() == SURF_RESOURCE_OFF) {
failed = 1;
break;
}
}
- action = new NetworkCm02ActionLmm(this, size, failed);
+ action = new NetworkCm02Action(this, size, failed);
#ifdef HAVE_LATENCY_BOUND_TRACKING
action->m_latencyLimited = 0;
bandwidth_bound = -1.0;
if (sg_weight_S_parameter > 0) {
xbt_dynar_foreach(route, i, _link) {
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
action->m_weight += sg_weight_S_parameter / link->getBandwidth();
}
}
xbt_dynar_foreach(route, i, _link) {
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
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);
xbt_assert(!xbt_dynar_is_empty(route),
"Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
- //link = *(NetworkCm02LinkLmmPtr *) xbt_dynar_get_ptr(route, 0);
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(*static_cast<ResourcePtr *>(xbt_dynar_get_ptr(route, 0)));
+ //link = *(NetworkCm02LinkPtr *) xbt_dynar_get_ptr(route, 0);
+ link = dynamic_cast<NetworkCm02LinkPtr>(*static_cast<ResourcePtr *>(xbt_dynar_get_ptr(route, 0)));
gapAppend(size, link, action);
XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
action, src->p_name, dst->p_name, action->m_senderGap,
constraints_per_variable += xbt_dynar_length(back_route);
if (action->m_latency > 0) {
- action->p_variable = lmm_variable_new(p_maxminSystem, static_cast<ActionLmmPtr>(action), 0.0, -1.0,
+ action->p_variable = lmm_variable_new(p_maxminSystem, static_cast<ActionPtr>(action), 0.0, -1.0,
constraints_per_variable);
if (p_updateMechanism == UM_LAZY) {
// add to the heap the event when the latency is payed
action->heapInsert(p_actionHeap, action->m_latency + action->m_lastUpdate, xbt_dynar_is_empty(route) ? NORMAL : LATENCY);
}
} else
- action->p_variable = lmm_variable_new(p_maxminSystem, static_cast<ActionLmmPtr>(action), 1.0, -1.0, constraints_per_variable);
+ action->p_variable = lmm_variable_new(p_maxminSystem, static_cast<ActionPtr>(action), 1.0, -1.0, constraints_per_variable);
if (action->m_rate < 0) {
lmm_update_variable_bound(p_maxminSystem, action->getVariable(), (action->m_latCurrent > 0) ? sg_tcp_gamma / (2.0 * action->m_latCurrent) : -1.0);
}
xbt_dynar_foreach(route, i, _link) {
- link = dynamic_cast<NetworkCm02LinkLmmPtr>(static_cast<ResourcePtr>(_link));
- lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), 1.0);
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
+ lmm_expand(p_maxminSystem, link->getConstraint(), 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->constraint(), action->getVariable(), .05);
+ link = dynamic_cast<NetworkCm02LinkPtr>(static_cast<ResourcePtr>(_link));
+ lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05);
}
}
/************
* Resource *
************/
-NetworkCm02LinkLmm::NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
+NetworkCm02Link::NetworkCm02Link(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
lmm_system_t system,
double constraint_value,
tmgr_history_t history,
double lat_initial,
tmgr_trace_t lat_trace,
e_surf_link_sharing_policy_t policy)
-: Resource(model, name, props),
- NetworkLinkLmm(lmm_constraint_new(system, this, constraint_value), history, state_trace)
+: NetworkLink(model, name, props, lmm_constraint_new(system, this, constraint_value), history, state_trace)
{
m_stateCurrent = state_init;
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());
+ lmm_constraint_shared(getConstraint());
}
-void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type,
+void NetworkCm02Link::updateState(tmgr_trace_event_t event_type,
double value, double date)
{
/* printf("[" "%g" "] Asking to update network card \"%s\" with value " */
(p_power.peak * p_power.scale);
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- NetworkCm02ActionLmmPtr action = NULL;
+ NetworkCm02ActionPtr action = NULL;
p_power.peak = value;
lmm_update_constraint_bound(getModel()->getMaxminSystem(),
- constraint(),
+ getConstraint(),
sg_bandwidth_factor *
(p_power.peak * p_power.scale));
#ifdef HAVE_TRACING
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(getModel()->getMaxminSystem(), constraint(), &elem))) {
- action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ action = (NetworkCm02ActionPtr) lmm_variable_id(var);
action->m_weight += delta;
if (!action->isSuspended())
lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight);
double delta = value - m_latCurrent;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- NetworkCm02ActionLmmPtr action = NULL;
+ NetworkCm02ActionPtr action = NULL;
m_latCurrent = value;
- while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), constraint(), &elem))) {
- action = (NetworkCm02ActionLmmPtr) lmm_variable_id(var);
+ while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), getConstraint(), &elem))) {
+ action = (NetworkCm02ActionPtr) lmm_variable_id(var);
action->m_latCurrent += delta;
action->m_weight += delta;
if (action->m_rate < 0)
if (value > 0)
m_stateCurrent = SURF_RESOURCE_ON;
else {
- lmm_constraint_t cnst = constraint();
+ lmm_constraint_t cnst = getConstraint();
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
XBT_DEBUG
("There were a resource state event, need to update actions related to the constraint (%p)",
- constraint());
+ getConstraint());
return;
}
/**********
* Action *
**********/
-void NetworkCm02ActionLmm::updateRemainingLazy(double now)
+void NetworkCm02Action::updateRemainingLazy(double now)
{
double delta = 0.0;
m_lastUpdate = now;
m_lastValue = lmm_variable_getvalue(getVariable());
}
-void NetworkCm02ActionLmm::recycle()
+void NetworkCm02Action::recycle()
{
return;
}
class NetworkCm02Model;
typedef NetworkCm02Model *NetworkCm02ModelPtr;
-class NetworkCm02LinkLmm;
-typedef NetworkCm02LinkLmm *NetworkCm02LinkLmmPtr;
+class NetworkCm02Link;
+typedef NetworkCm02Link *NetworkCm02LinkPtr;
-class NetworkCm02ActionLmm;
-typedef NetworkCm02ActionLmm *NetworkCm02ActionLmmPtr;
+class NetworkCm02Action;
+typedef NetworkCm02Action *NetworkCm02ActionPtr;
/*********
* Tools *
* Resource *
************/
-class NetworkCm02LinkLmm : public NetworkLinkLmm {
+class NetworkCm02Link : public NetworkLink {
public:
- NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
+ NetworkCm02Link(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props,
lmm_system_t system,
double constraint_value,
tmgr_history_t history,
* Action *
**********/
-class NetworkCm02ActionLmm : public NetworkActionLmm {
+class NetworkCm02Action : public NetworkAction {
friend ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate);
public:
- NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed) {};
+ NetworkCm02Action(ModelPtr model, double cost, bool failed)
+ : NetworkAction(model, cost, failed) {};
void updateRemainingLazy(double now);
void recycle();
};
double NetworkConstantModel::shareResources(double /*now*/)
{
- NetworkConstantActionLmmPtr action = NULL;
+ NetworkConstantActionPtr action = NULL;
double min = -1.0;
ActionListPtr actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
; it != itend ; ++it) {
- action = dynamic_cast<NetworkConstantActionLmmPtr>(&*it);
+ action = dynamic_cast<NetworkConstantActionPtr>(&*it);
if (action->m_latency > 0) {
if (min < 0)
min = action->m_latency;
void NetworkConstantModel::updateActionsState(double /*now*/, double delta)
{
- NetworkConstantActionLmmPtr action = NULL;
+ NetworkConstantActionPtr action = NULL;
ActionListPtr actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
; it != itend ; it=itNext) {
++itNext;
- action = dynamic_cast<NetworkConstantActionLmmPtr>(&*it);
+ action = dynamic_cast<NetworkConstantActionPtr>(&*it);
if (action->m_latency > 0) {
if (action->m_latency > delta) {
double_update(&(action->m_latency), delta);
char *dst_name = dst->p_name;
XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
- NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, size, sg_latency_factor);
+ NetworkConstantActionPtr action = new NetworkConstantAction(this, size, sg_latency_factor);
XBT_OUT();
return action;
/************
* Resource *
************/
-bool NetworkConstantLinkLmm::isUsed()
+bool NetworkConstantLink::isUsed()
{
return 0;
}
-void NetworkConstantLinkLmm::updateState(tmgr_trace_event_t /*event_type*/,
+void NetworkConstantLink::updateState(tmgr_trace_event_t /*event_type*/,
double /*value*/, double /*time*/)
{
DIE_IMPOSSIBLE;
}
-double NetworkConstantLinkLmm::getBandwidth()
+double NetworkConstantLink::getBandwidth()
{
DIE_IMPOSSIBLE;
return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
}
-double NetworkConstantLinkLmm::getLatency()
+double NetworkConstantLink::getLatency()
{
DIE_IMPOSSIBLE;
return -1.0; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
}
-bool NetworkConstantLinkLmm::isShared()
+bool NetworkConstantLink::isShared()
{
DIE_IMPOSSIBLE;
return -1; /* useless since DIE actually abort(), but eclipse prefer to have a useless and harmless return */
* Action *
**********/
-int NetworkConstantActionLmm::unref()
+int NetworkConstantAction::unref()
{
m_refcount--;
if (!m_refcount) {
return 0;
}
-void NetworkConstantActionLmm::cancel()
+void NetworkConstantAction::cancel()
{
return;
}
#ifdef HAVE_TRACING
-void NetworkConstantActionLmm::setCategory(const char */*category*/)
+void NetworkConstantAction::setCategory(const char */*category*/)
{
//ignore completely the categories in constant model, they are not traced
}
#endif
-void NetworkConstantActionLmm::suspend()
+void NetworkConstantAction::suspend()
{
m_suspended = true;
}
-void NetworkConstantActionLmm::resume()
+void NetworkConstantAction::resume()
{
if (m_suspended)
m_suspended = false;
}
-void NetworkConstantActionLmm::recycle()
+void NetworkConstantAction::recycle()
{
return;
}
-bool NetworkConstantActionLmm::isSuspended()
+bool NetworkConstantAction::isSuspended()
{
return m_suspended;
}
class NetworkConstantModel;
typedef NetworkConstantModel *NetworkConstantModelPtr;
-class NetworkConstantLinkLmm;
-typedef NetworkConstantLinkLmm *NetworkConstantLinkLmmPtr;
+class NetworkConstantLink;
+typedef NetworkConstantLink *NetworkConstantLinkPtr;
-class NetworkConstantActionLmm;
-typedef NetworkConstantActionLmm *NetworkConstantActionLmmPtr;
+class NetworkConstantAction;
+typedef NetworkConstantAction *NetworkConstantActionPtr;
/*********
* Model *
void updateActionsState(double now, double delta);
ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
double size, double rate);
- void gapRemove(ActionLmmPtr action);
+ void gapRemove(ActionPtr action);
//FIXME:virtual void addTraces() =0;
};
/************
* Resource *
************/
-class NetworkConstantLinkLmm : public NetworkCm02LinkLmm {
+class NetworkConstantLink : public NetworkCm02Link {
public:
- NetworkConstantLinkLmm(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties);
+ NetworkConstantLink(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties);
bool isUsed();
void updateState(tmgr_trace_event_t event_type, double value, double date);
double getBandwidth();
/**********
* Action *
**********/
-class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
+class NetworkConstantAction : public NetworkCm02Action {
public:
- NetworkConstantActionLmm(NetworkConstantModelPtr model_, double size, double latency):
- Action(model_, size, false), NetworkCm02ActionLmm(model_, 0, false), m_latInit(latency) {
+ NetworkConstantAction(NetworkConstantModelPtr model_, double size, double latency)
+ : NetworkCm02Action(model_, size, false)
+ , m_latInit(latency)
+ {
m_latency = latency;
if (m_latency <= 0.0) {
p_stateSet = getModel()->getDoneActionSet();
return rate;
}
-NetworkLinkLmm::NetworkLinkLmm(lmm_constraint_t constraint,
- tmgr_history_t history,
- tmgr_trace_t state_trace)
-: ResourceLmm(constraint)
+NetworkLink::NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props)
+: p_latEvent(NULL)
+{}
+
+NetworkLink::NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint,
+ tmgr_history_t history,
+ tmgr_trace_t state_trace)
+: Resource(model, name, props, constraint),
+ p_latEvent(NULL)
{
if (state_trace)
p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, static_cast<ResourcePtr>(this));
}
-bool NetworkLinkLmm::isUsed()
+bool NetworkLink::isUsed()
{
- return lmm_constraint_used(getModel()->getMaxminSystem(), constraint());
+ return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint());
}
double NetworkLink::getLatency()
return m_latCurrent;
}
-double NetworkLinkLmm::getBandwidth()
+double NetworkLink::getBandwidth()
{
return p_power.peak * p_power.scale;
}
-bool NetworkLinkLmm::isShared()
+bool NetworkLink::isShared()
{
- return lmm_constraint_is_shared(constraint());
+ return lmm_constraint_is_shared(getConstraint());
}
#endif /* NETWORK_INTERFACE_CPP_ */
class NetworkLink;
typedef NetworkLink *NetworkLinkPtr;
-class NetworkLinkLmm;
-typedef NetworkLinkLmm *NetworkLinkLmmPtr;
-
class NetworkAction;
typedef NetworkAction *NetworkActionPtr;
-class NetworkActionLmm;
-typedef NetworkActionLmm *NetworkActionLmmPtr;
-
/*********
* Tools *
*********/
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties)=0;
- //FIXME:void updateActionsStateLazy(double now, double delta);
- virtual void gapAppend(double /*size*/, const NetworkLinkLmmPtr /*link*/, NetworkActionLmmPtr /*action*/) {};
+ virtual void gapAppend(double /*size*/, const NetworkLinkPtr /*link*/, NetworkActionPtr /*action*/) {};
virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
double size, double rate)=0;
virtual xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); //FIXME: kill field? That is done by the routing nowadays
* Resource *
************/
-class NetworkLink : virtual public Resource {
+class NetworkLink : public Resource {
public:
- NetworkLink() : p_latEvent(NULL) {};
- virtual double getBandwidth()=0;
+ NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props);
+ NetworkLink(NetworkModelPtr model, const char *name, xbt_dict_t props,
+ lmm_constraint_t constraint,
+ tmgr_history_t history,
+ tmgr_trace_t state_trace);
+ virtual double getBandwidth();
virtual double getLatency();
- virtual bool isShared()=0;
+ virtual bool isShared();
+ bool isUsed();
/* Using this object with the public part of
model does not make sense */
double m_latCurrent;
tmgr_trace_event_t p_latEvent;
-};
-class NetworkLinkLmm : public ResourceLmm, public NetworkLink {
-protected:
-public:
- NetworkLinkLmm() {};
- NetworkLinkLmm(lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace);
- bool isShared();
- bool isUsed();
- double getBandwidth();
+ /* LMM */
tmgr_trace_event_t p_stateEvent;
s_surf_metric_t p_power;
};
/**********
* Action *
**********/
-class NetworkAction : virtual public Action {
+class NetworkAction : public Action {
public:
- NetworkAction() {};
+ NetworkAction(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed) {}
+ NetworkAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
+ : Action(model, cost, failed, var) {};
double m_latency;
double m_latCurrent;
double m_weight;
};
-class NetworkActionLmm : public ActionLmm, public NetworkAction {
-public:
- NetworkActionLmm() {};
-};
-
#endif /* SURF_NETWORK_INTERFACE_HPP_ */
}
}
-void NetworkSmpiModel::gapAppend(double size, const NetworkLinkLmmPtr link, NetworkActionLmmPtr action)
+void NetworkSmpiModel::gapAppend(double size, const NetworkLinkPtr link, NetworkActionPtr action)
{
const char *src = link->getName();
xbt_fifo_t fifo;
}
}
-void NetworkSmpiModel::gapRemove(ActionLmmPtr lmm_action)
+void NetworkSmpiModel::gapRemove(ActionPtr lmm_action)
{
xbt_fifo_t fifo;
size_t size;
- NetworkCm02ActionLmmPtr action = (NetworkCm02ActionLmmPtr)(lmm_action);
+ NetworkCm02ActionPtr action = static_cast<NetworkCm02ActionPtr>(lmm_action);
if (sg_sender_gap > 0.0 && action->p_senderLinkName
&& action->p_senderFifoItem) {
return current;
}
+
double NetworkSmpiModel::latencyFactor(double size)
{
if (!smpi_lat_factor)
NetworkSmpiModel();
~NetworkSmpiModel();
- void gapAppend(double size, const NetworkLinkLmmPtr link, NetworkActionLmmPtr action);
- void gapRemove(ActionLmmPtr action);
+ void gapAppend(double size, const NetworkLinkPtr link, NetworkActionPtr action);
+ void gapRemove(ActionPtr action);
double latencyFactor(double size);
double bandwidthFactor(double size);
double bandwidthConstraint(double rate, double bound, double size);
* Resource *
************/
-Storage::Storage(const char* type_id, char *content_name, char *content_type, sg_size_t size)
-: p_contentType(content_type),
- m_size(size), m_usedSize(0), p_typeId(xbt_strdup(type_id)), p_writeActions(xbt_dynar_new(sizeof(ActionPtr),NULL))
+Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props,
+ const char* type_id, char *content_name, char *content_type, sg_size_t size)
+ : Resource(model, name, props)
+ , p_contentType(content_type)
+ , 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);
m_stateCurrent = SURF_RESOURCE_ON;
}
+Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props,
+ lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+ const char* type_id, char *content_name, char *content_type, sg_size_t size)
+ : Resource(model, name, props, lmm_constraint_new(maxminSystem, this, bconnection))
+ , p_contentType(content_type)
+ , 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);
+ m_stateCurrent = SURF_RESOURCE_ON;
+ XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size);
+ p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
+ p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
+}
+
Storage::~Storage(){
xbt_dict_free(&p_content);
xbt_dynar_free(&p_writeActions);
return m_size;
}
-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(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_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
- p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
-}
+
/**********
* Action *
**********/
-StorageAction::StorageAction(StoragePtr storage, e_surf_action_storage_type_t type)
-: m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL)
+StorageAction::StorageAction(ModelPtr model, double cost, bool failed,
+ StoragePtr storage, e_surf_action_storage_type_t type)
+: Action(model, cost, failed)
+, m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL)
{
};
-StorageActionLmm::StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var)
- : StorageAction(storage, type), ActionLmm(var) {
+StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
+ StoragePtr storage, e_surf_action_storage_type_t type)
+ : Action(model, cost, failed, var)
+ , m_type(type), p_storage(storage), p_file(NULL), p_lsDict(NULL) {
}
class Storage;
typedef Storage *StoragePtr;
-class StorageLmm;
-typedef StorageLmm *StorageLmmPtr;
+class Storage;
+typedef Storage *StoragePtr;
class StorageAction;
typedef StorageAction *StorageActionPtr;
-class StorageActionLmm;
-typedef StorageActionLmm *StorageActionLmmPtr;
+class StorageAction;
+typedef StorageAction *StorageActionPtr;
/*********
* Model *
* Resource *
************/
-class Storage : virtual public Resource {
+class Storage : public Resource {
public:
- Storage(const char* type_id, char *content_name, char *content_type, sg_size_t size);
+ Storage(ModelPtr model, const char *name, xbt_dict_t props,
+ const char* type_id, char *content_name, char *content_type, sg_size_t size);
+ Storage(ModelPtr model, const char *name, xbt_dict_t props,
+ lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+ const char* type_id, char *content_name, char *content_type, sg_size_t size);
~Storage();
bool isUsed();
xbt_dict_t parseContent(char *filename);
xbt_dynar_t p_writeActions;
-};
-
-class StorageLmm : public ResourceLmm, public Storage {
-public:
- 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);
lmm_constraint_t p_constraintWrite; /* Constraint for maximum write bandwidth*/
lmm_constraint_t p_constraintRead; /* Constraint for maximum write bandwidth*/
} e_surf_action_storage_type_t;
-class StorageAction : virtual public Action {
+class StorageAction : public Action {
public:
StorageAction() : m_type(READ) {};//FIXME:REMOVE
- StorageAction(StoragePtr storage, e_surf_action_storage_type_t type);
+ StorageAction(ModelPtr model, double cost, bool failed,
+ StoragePtr storage, e_surf_action_storage_type_t type);
+ StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var,
+ StoragePtr storage, e_surf_action_storage_type_t type);
e_surf_action_storage_type_t m_type;
StoragePtr p_storage;
xbt_dict_t p_lsDict;
};
-class StorageActionLmm : public ActionLmm, public StorageAction {
-public:
- StorageActionLmm() {};//FIXME:REMOVE
-
- StorageActionLmm(StorageLmmPtr storage, e_surf_action_storage_type_t type, lmm_variable_t var);
-};
-
typedef struct s_storage_type {
char *model;
char *content;
double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->properties, "Bwrite"));
double Bconnection = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
- StoragePtr storage = new StorageN11Lmm(this, id, properties, p_maxminSystem,
+ StoragePtr storage = new StorageN11(this, id, properties, p_maxminSystem,
Bread, Bwrite, Bconnection,
type_id, (char *)content_name, xbt_strdup(content_type), storage_type->size);
unsigned int i, j;
StoragePtr storage;
void *_write_action;
- StorageActionLmmPtr write_action;
+ StorageActionPtr write_action;
double min_completion = shareResourcesMaxMin(getRunningActionSet(),
p_maxminSystem, lmm_solve);
// Foreach write action on disk
xbt_dynar_foreach(storage->p_writeActions, j, _write_action)
{
- write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
+ write_action = dynamic_cast<StorageActionPtr>(static_cast<ActionPtr>(_write_action));
rate += lmm_variable_getvalue(write_action->getVariable());
}
if(rate > 0)
void StorageN11Model::updateActionsState(double /*now*/, double delta)
{
- StorageActionLmmPtr action = NULL;
+ StorageActionPtr action = NULL;
ActionListPtr actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end())
; it != itend ; it=itNext) {
++itNext;
- action = dynamic_cast<StorageActionLmmPtr>(&*it);
+ action = dynamic_cast<StorageActionPtr>(&*it);
if(action->m_type == WRITE)
{
// Update the disk usage
* Resource *
************/
-StorageN11Lmm::StorageN11Lmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+StorageN11::StorageN11(StorageModelPtr model, const char* name, xbt_dict_t properties,
lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
const char* type_id, char *content_name, char *content_type, sg_size_t size)
- : Resource(model, name, properties),
- StorageLmm(maxminSystem, bread, bwrite, bconnection, type_id, content_name, content_type, size) {
+ : Storage(model, name, properties,
+ 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);
}
-StorageActionPtr StorageN11Lmm::ls(const char* path)
+StorageActionPtr StorageN11::ls(const char* path)
{
- StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
action->p_lsDict = NULL;
xbt_dict_t ls_dict = xbt_dict_new_homogeneous(xbt_free);
return action;
}
-StorageActionPtr StorageN11Lmm::open(const char* mount, const char* path)
+StorageActionPtr StorageN11::open(const char* mount, const char* path)
{
XBT_DEBUG("\tOpen file '%s'",path);
sg_size_t size, *psize;
file->mount = xbt_strdup(mount);
file->current_position = 0;
- StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
action->p_file = file;
return action;
}
-StorageActionPtr StorageN11Lmm::close(surf_file_t fd)
+StorageActionPtr StorageN11::close(surf_file_t fd)
{
char *filename = fd->name;
XBT_DEBUG("\tClose file '%s' size '%llu'", filename, fd->size);
// unref write actions from storage
void *_write_action;
- StorageActionLmmPtr write_action;
+ StorageActionPtr write_action;
unsigned int i;
xbt_dynar_foreach(p_writeActions, i, _write_action) {
- write_action = dynamic_cast<StorageActionLmmPtr>(static_cast<ActionPtr>(_write_action));
+ write_action = dynamic_cast<StorageActionPtr>(static_cast<ActionPtr>(_write_action));
if ((write_action->p_file) == fd) {
xbt_dynar_cursor_rm(p_writeActions, &i);
write_action->unref();
free(fd->name);
free(fd->mount);
xbt_free(fd);
- StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+ StorageActionPtr action = new StorageN11Action(getModel(), 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
return action;
}
-StorageActionPtr StorageN11Lmm::read(surf_file_t fd, sg_size_t size)
+StorageActionPtr StorageN11::read(surf_file_t fd, sg_size_t size)
{
if(size > fd->size){
size = fd->size;
else
fd->current_position += size;
- StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
+ StorageActionPtr action = new StorageN11Action(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
return action;
}
-StorageActionPtr StorageN11Lmm::write(surf_file_t fd, sg_size_t size)
+StorageActionPtr StorageN11::write(surf_file_t fd, sg_size_t size)
{
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%llu/%llu'",filename,size,fd->size);
- StorageActionLmmPtr action = new StorageN11ActionLmm(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+ StorageActionPtr action = new StorageN11Action(getModel(), size, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
fd->current_position += size;
// If the storage is full
return action;
}
-void StorageN11Lmm::rename(const char *src, const char *dest)
+void StorageN11::rename(const char *src, const char *dest)
{
sg_size_t *psize, *new_psize;
psize = (sg_size_t*) xbt_dict_get_or_null(p_content,src);
XBT_DEBUG("File %s doesn't exist",src);
}
-xbt_dict_t StorageN11Lmm::getContent()
+xbt_dict_t StorageN11::getContent()
{
/* For the moment this action has no cost, but in the future we could take in account access latency of the disk */
/*surf_action_t action = storage_action_execute(storage,0, LS);*/
return content_dict;
}
-sg_size_t StorageN11Lmm::getSize(){
+sg_size_t StorageN11::getSize(){
return m_size;
}
* 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, lmm_variable_new(getModel()->getMaxminSystem(), this, 1.0, -1.0 , 3)) {
+StorageN11Action::StorageN11Action(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
+ : StorageAction(model, cost, failed,
+ lmm_variable_new(model->getMaxminSystem(), this, 1.0, -1.0 , 3),
+ storage, type) {
XBT_IN("(%s,%g", storage->getName(), cost);
// Must be less than the max bandwidth for all actions
- lmm_expand(getModel()->getMaxminSystem(), storage->constraint(), getVariable(), 1.0);
+ lmm_expand(model->getMaxminSystem(), storage->getConstraint(), getVariable(), 1.0);
switch(type) {
case OPEN:
case CLOSE:
case LS:
break;
case READ:
- lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintRead,
+ lmm_expand(model->getMaxminSystem(), storage->p_constraintRead,
getVariable(), 1.0);
break;
case WRITE:
- lmm_expand(getModel()->getMaxminSystem(), storage->p_constraintWrite,
+ lmm_expand(model->getMaxminSystem(), storage->p_constraintWrite,
getVariable(), 1.0);
ActionPtr action = this;
xbt_dynar_push(storage->p_writeActions, &action);
XBT_OUT();
}
-int StorageN11ActionLmm::unref()
+int StorageN11Action::unref()
{
m_refcount--;
if (!m_refcount) {
return 0;
}
-void StorageN11ActionLmm::cancel()
+void StorageN11Action::cancel()
{
setState(SURF_ACTION_FAILED);
return;
}
-void StorageN11ActionLmm::suspend()
+void StorageN11Action::suspend()
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
XBT_OUT();
}
-void StorageN11ActionLmm::resume()
+void StorageN11Action::resume()
{
THROW_UNIMPLEMENTED;
}
-bool StorageN11ActionLmm::isSuspended()
+bool StorageN11Action::isSuspended()
{
return m_suspended == 1;
}
-void StorageN11ActionLmm::setMaxDuration(double /*duration*/)
+void StorageN11Action::setMaxDuration(double /*duration*/)
{
THROW_UNIMPLEMENTED;
}
-void StorageN11ActionLmm::setPriority(double /*priority*/)
+void StorageN11Action::setPriority(double /*priority*/)
{
THROW_UNIMPLEMENTED;
}
class StorageN11;
typedef StorageN11 *StorageN11Ptr;
-class StorageN11Lmm;
-typedef StorageN11Lmm *StorageN11LmmPtr;
+class StorageN11;
+typedef StorageN11 *StorageN11Ptr;
class StorageN11Action;
typedef StorageN11Action *StorageN11ActionPtr;
-class StorageN11ActionLmm;
-typedef StorageN11ActionLmm *StorageN11ActionLmmPtr;
+class StorageN11Action;
+typedef StorageN11Action *StorageN11ActionPtr;
/*********
* Resource *
************/
-class StorageN11Lmm : public StorageLmm {
+class StorageN11 : public Storage {
public:
- StorageN11Lmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+ StorageN11(StorageModelPtr model, const char* name, xbt_dict_t properties,
lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
const char* type_id, char *content_name, char *content_type, sg_size_t size);
* Action *
**********/
-class StorageN11ActionLmm : public StorageActionLmm {
+class StorageN11Action : public StorageAction {
public:
- StorageN11ActionLmm() {}; //FIXME:REMOVE
- StorageN11ActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
+ StorageN11Action() {}; //FIXME:REMOVE
+ StorageN11Action(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type);
void suspend();
int unref();
void cancel();
}
void surf_vm_workstation_set_affinity(surf_resource_t resource, surf_resource_t cpu, unsigned long mask){
- return get_casted_vm_workstation(resource)->setAffinity(dynamic_cast<CpuLmmPtr>(get_casted_cpu(cpu)), mask);
+ return get_casted_vm_workstation(resource)->setAffinity(get_casted_cpu(cpu), mask);
}
int surf_network_link_is_shared(surf_cpp_resource_t link){
double Model::shareResourcesLazy(double now)
{
- ActionLmmPtr action = NULL;
+ ActionPtr action = NULL;
double min = -1;
double value;
p_modifiedSet->size());
while(!p_modifiedSet->empty()) {
- action = dynamic_cast<ActionLmmPtr>(&(p_modifiedSet->front()));
+ action = &(p_modifiedSet->front());
p_modifiedSet->pop_front();
int max_dur_flag = 0;
void (*solve) (lmm_system_t))
{
void *_action = NULL;
- ActionLmmPtr action = NULL;
+ ActionPtr action = NULL;
double min = -1;
double value = -1;
ActionList::iterator it(running_actions->begin()), itend(running_actions->end());
for(; it != itend ; ++it) {
- action = dynamic_cast<ActionLmmPtr>(&*it);
+ action = &*it;
value = lmm_variable_getvalue(action->getVariable());
if ((value > 0) || (action->getMaxDuration() >= 0))
break;
for (++it; it != itend; ++it) {
- action = dynamic_cast<ActionLmmPtr>(&*it);
+ action = &*it;
value = lmm_variable_getvalue(action->getVariable());
if (value > 0) {
if (action->getRemains() > 0)
, m_running(true), m_stateCurrent(SURF_RESOURCE_ON)
{}
+Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props, lmm_constraint_t constraint)
+ : p_name(xbt_strdup(name)), p_properties(props), p_model(model)
+ , m_running(true), m_stateCurrent(SURF_RESOURCE_ON), p_constraint(constraint)
+{}
+
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)
}
}
-ResourceLmm::ResourceLmm()
- : p_constraint(NULL)
-{}
-
-ResourceLmm::ResourceLmm(lmm_constraint_t constraint)
- : p_constraint(constraint)
-{}
-
/**********
* Action *
**********/
, p_data(NULL)
, p_model(model)
, m_refcount(1)
+ , m_lastValue(0)
+ , m_lastUpdate(0)
+ , m_suspended(false)
+ , p_variable(NULL)
+{
+ #ifdef HAVE_TRACING
+ p_category = NULL;
+ #endif
+ p_stateHookup.prev = 0;
+ p_stateHookup.next = 0;
+ if (failed)
+ p_stateSet = getModel()->getFailedActionSet();
+ else
+ p_stateSet = getModel()->getRunningActionSet();
+
+ p_stateSet->push_back(*this);
+}
+
+Action::Action(ModelPtr model, double cost, bool failed, lmm_variable_t var)
+ : m_priority(1.0)
+ , m_failed(failed)
+ , m_start(surf_get_clock()), m_finish(-1.0)
+ , m_remains(cost)
+ , m_maxDuration(NO_MAX_DURATION)
+ , m_cost(cost)
+ , p_data(NULL)
+ , p_model(model)
+ , m_refcount(1)
+ , m_lastValue(0)
+ , m_lastUpdate(0)
+ , m_suspended(false)
+ , p_variable(var)
{
#ifdef HAVE_TRACING
p_category = NULL;
m_finish = surf_get_clock();
}
-int Action::unref(){
- DIE_IMPOSSIBLE;
-}
-
-void Action::cancel(){
- DIE_IMPOSSIBLE;
-}
-
-void Action::recycle(){
- DIE_IMPOSSIBLE;
-}
-
e_surf_action_state_t Action::getState()
{
if (p_stateSet == getModel()->getReadyActionSet())
return m_remains == 0 ? m_finish : -1;
}
-double Action::getRemains()
-{
- XBT_IN("(%p)", this);
- XBT_OUT();
- return m_remains;
-}
-
void Action::setData(void* data)
{
p_data = data;
m_refcount++;
}
-void ActionLmm::setMaxDuration(double duration)
+void Action::setMaxDuration(double duration)
{
XBT_IN("(%p,%g)", this, duration);
m_maxDuration = duration;
XBT_OUT();
}
-void ActionLmm::gapRemove() {}
+void Action::gapRemove() {}
-void ActionLmm::setPriority(double priority)
+void Action::setPriority(double priority)
{
XBT_IN("(%p,%g)", this, priority);
m_priority = priority;
XBT_OUT();
}
-void ActionLmm::cancel(){
+void Action::cancel(){
setState(SURF_ACTION_FAILED);
if (getModel()->getUpdateMechanism() == UM_LAZY) {
getModel()->getModifiedSet()->erase(getModel()->getModifiedSet()->iterator_to(*this));
}
}
-int ActionLmm::unref(){
+int Action::unref(){
m_refcount--;
if (!m_refcount) {
if (actionHook::is_linked())
return 0;
}
-void ActionLmm::suspend()
+void Action::suspend()
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
XBT_OUT();
}
-void ActionLmm::resume()
+void Action::resume()
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
XBT_OUT();
}
-bool ActionLmm::isSuspended()
+bool Action::isSuspended()
{
return m_suspended == 1;
}
* LATENCY = this is a heap entry to warn us when the latency is payed
* MAX_DURATION =this is a heap entry to warn us when the max_duration limit is reached
*/
-void ActionLmm::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
+void Action::heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat)
{
m_hat = hat;
xbt_heap_push(heap, this, key);
}
-void ActionLmm::heapRemove(xbt_heap_t heap)
+void Action::heapRemove(xbt_heap_t heap)
{
m_hat = NOTSET;
if (m_indexHeap >= 0) {
/* added to manage the communication action's heap */
void surf_action_lmm_update_index_heap(void *action, int i) {
- ((ActionLmmPtr)action)->updateIndexHeap(i);
+ ((ActionPtr)action)->updateIndexHeap(i);
}
-void ActionLmm::updateIndexHeap(int i) {
+void Action::updateIndexHeap(int i) {
m_indexHeap = i;
}
-double ActionLmm::getRemains()
+double Action::getRemains()
{
XBT_IN("(%p)", this);
/* update remains before return it */
}
//FIXME split code in the right places
-void ActionLmm::updateRemainingLazy(double now)
+void Action::updateRemainingLazy(double now)
{
double delta = 0.0;
m_lastValue = lmm_variable_getvalue(getVariable());
}
-/*void Action::cancel()
-{
- p_model->notifyActionCancel(this);
-}
-
-void Action::suspend()
-{
- p_model->notifyActionSuspend(this);
-}
-
-void Action::resume()
-{
- p_model->notifyActionResume(this);
-}
-
-bool Action::isSuspended()
-{
- return false;
-}*/
-
typedef ActionList* ActionListPtr;
typedef boost::intrusive::list_base_hook<> actionHook;
-//class ActionLmm;
-typedef ActionLmm* ActionLmmPtr;
-
struct lmmTag;
-typedef boost::intrusive::list<ActionLmm, boost::intrusive::base_hook<boost::intrusive::list_base_hook<boost::intrusive::tag<lmmTag> > > > ActionLmmList;
+typedef boost::intrusive::list<Action, boost::intrusive::base_hook<boost::intrusive::list_base_hook<boost::intrusive::tag<lmmTag> > > > ActionLmmList;
typedef ActionLmmList* ActionLmmListPtr;
typedef boost::intrusive::list_base_hook<boost::intrusive::tag<lmmTag> > actionLmmHook;
virtual ~Model();
const char *getName() {return p_name;}
- ActionListPtr getReadyActionSet() {return p_readyActionSet;}
- ActionListPtr getRunningActionSet() {return p_runningActionSet;}
- ActionListPtr getFailedActionSet() {return p_failedActionSet;}
- ActionListPtr getDoneActionSet() {return p_doneActionSet;}
- ActionLmmListPtr getModifiedSet() {return p_modifiedSet;}
+ virtual ActionListPtr getReadyActionSet() {return p_readyActionSet;}
+ virtual ActionListPtr getRunningActionSet() {return p_runningActionSet;}
+ virtual ActionListPtr getFailedActionSet() {return p_failedActionSet;}
+ virtual ActionListPtr getDoneActionSet() {return p_doneActionSet;}
+ virtual ActionLmmListPtr 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;}
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);
+ Resource(ModelPtr model, const char *name, xbt_dict_t props);
+ Resource(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint);
+ Resource(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit);
+ Resource(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit, lmm_constraint_t constraint);
+
virtual ~Resource() {
xbt_free((void*)p_name);
xbt_dict_free(&p_properties);
virtual e_surf_resource_state_t getState();
virtual void setState(e_surf_resource_state_t state);
-};
-class ResourceLmm: virtual public Resource {
+ /* LMM */
+private:
lmm_constraint_t p_constraint;
-
public:
- ResourceLmm();
- ResourceLmm(lmm_constraint_t constraint);
- ~ResourceLmm() {
- };
+ lmm_constraint_t getConstraint() {return p_constraint;};
- lmm_constraint_t constraint() {return p_constraint;};
};
/**********
* Action *
**********/
+void surf_action_lmm_update_index_heap(void *action, int i);
-class Action : public actionHook{
+class Action : public actionHook, public actionLmmHook {
ActionLmmListPtr p_modifiedSet;
xbt_heap_t p_actionHeap;
int m_selectiveUpdate;
Action();
Action(ModelPtr model, double cost, bool failed);
+ Action(ModelPtr model, double cost, bool failed, lmm_variable_t var);
virtual ~Action();
void finish();
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. */
virtual void cancel(); /**< Cancel a running action */
- virtual void recycle(); /**< Recycle an action */
+ virtual void recycle(){}; /**< Recycle an action */
- virtual void suspend()=0; /**< Suspend an action */
- virtual void resume()=0; /**< Resume a suspended action */
- virtual bool isSuspended()=0; /**< Return whether an action is suspended */
- virtual void setMaxDuration(double duration)=0; /**< Set the max duration of an action*/
- virtual void setPriority(double priority)=0; /**< Set the priority of an action */
+ virtual void suspend(); /**< Suspend an action */
+ virtual void resume(); /**< Resume a suspended action */
+ virtual bool isSuspended(); /**< Return whether an action is suspended */
+ virtual void setMaxDuration(double duration); /**< Set the max duration of an action*/
+ virtual void setPriority(double priority); /**< Set the priority of an action */
#ifdef HAVE_TRACING
void setCategory(const char *category); /**< Set the category of an action */
#endif
void updateResourceState(void *id, tmgr_trace_event_t event_type,
double value, double time);
-
-};
-
-//FIXME:REMOVE
-void surf_action_lmm_update_index_heap(void *action, int i);
-class ActionLmm: virtual public Action, public actionLmmHook {
-
+ /* LMM */
protected:
lmm_variable_t p_variable;
double m_lastUpdate;
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;
- };
- ActionLmm(lmm_variable_t var) : m_suspended(false) {
- p_actionListHookup.prev = 0;
- p_actionListHookup.next = 0;
- m_lastUpdate = 0;
- m_lastValue = 0;
- p_variable = var;
- };
-
virtual void updateRemainingLazy(double now);
void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
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;}
bool is_linked() {return actionLmmHook::is_linked();}
- virtual int unref();
- void cancel();
- void suspend();
- void resume();
- bool isSuspended();
- void setMaxDuration(double duration);
- void setPriority(double priority);
void gapRemove();
- s_xbt_swag_hookup_t p_actionListHookup;
-
};
#endif /* SURF_MODEL_H_ */
p_cpuModel = surf_cpu_model_vm;
}
+void WorkstationVMHL13Model::updateActionsState(double /*now*/, double /*delta*/){
+ return;
+}
+
xbt_dynar_t WorkstationVMHL13Model::getRoute(WorkstationPtr src, WorkstationPtr dst){
- return WorkstationCLM03Model::getRoute(src, dst);
+ XBT_DEBUG("ws_get_route");
+ return surf_network_model->getRoute(src->p_netElm, dst->p_netElm);
}
ActionPtr WorkstationVMHL13Model::communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate){
- return WorkstationCLM03Model::communicate(src, dst, size, rate);
+ return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate);
}
/* ind means ''indirect'' that this is a reference on the whole dict_elm
void WorkstationVMHL13Model::createResource(const char *name, void *ind_phys_workstation)
{
- WorkstationVMHL13LmmPtr ws = new WorkstationVMHL13Lmm(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
+ WorkstationVMHL13Ptr ws = new WorkstationVMHL13(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(ws));
*/
}
-static inline double get_solved_value(CpuActionLmmPtr cpu_action)
+static inline double get_solved_value(CpuActionPtr cpu_action)
{
return cpu_action->getVariable()->value;
}
xbt_lib_foreach(host_lib, cursor, key, ind_host) {
WorkstationPtr ws = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
- CpuLmmPtr cpu = dynamic_cast<CpuLmmPtr>(
+ CpuPtr cpu = dynamic_cast<CpuPtr>(
static_cast<ResourcePtr>(ind_host[SURF_CPU_LEVEL]));
if (!ws)
/* It is a virtual machine, so we can cast it to workstation_VM2013_t */
WorkstationVMPtr ws_vm = dynamic_cast<WorkstationVMPtr>(ws);
- double solved_value = get_solved_value(reinterpret_cast<CpuActionLmmPtr>(ws_vm->p_action));
+ double solved_value = get_solved_value(reinterpret_cast<CpuActionPtr>(ws_vm->p_action));
XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value,
ws->getName(), ws_vm->p_subWs->getName());
// cpu_cas01->constraint->bound = 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);
+ lmm_update_constraint_bound(vcpu_system, cpu->getConstraint(), virt_overhead * solved_value);
}
/* 2. Calculate resource share at the virtual machine layer. */
- double ret = WorkstationCLM03Model::shareResources(now);
-
+ adjustWeightOfDummyCpuActions();
+
+ double min_by_cpu = p_cpuModel->shareResources(now);
+ double min_by_net = surf_network_model->shareResources(now);
+ double min_by_sto = -1;
+ if (p_cpuModel == surf_cpu_model_pm)
+ 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->getName(), min_by_cpu,
+ surf_network_model->getName(), min_by_net,
+ surf_storage_model->getName(), min_by_sto);
+
+ double ret = max(max(min_by_cpu, min_by_net), min_by_sto);
+ if (min_by_cpu >= 0.0 && min_by_cpu < ret)
+ ret = min_by_cpu;
+ if (min_by_net >= 0.0 && min_by_net < ret)
+ ret = min_by_net;
+ if (min_by_sto >= 0.0 && min_by_sto < ret)
+ ret = min_by_sto;
/* FIXME: 3. do we have to re-initialize our cpu_action object? */
#if 0
return ret;
}
+ActionPtr WorkstationVMHL13Model::executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double rate){
+#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
+ if ((workstation_nb == 1)
+ && (cost_or_zero(communication_amount, 0) == 0.0))
+ return ((WorkstationCLM03Ptr)workstation_list[0])->execute(computation_amount[0]);
+ else if ((workstation_nb == 1)
+ && (cost_or_zero(computation_amount, 0) == 0.0))
+ return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[0],communication_amount[0], rate);
+ else if ((workstation_nb == 2)
+ && (cost_or_zero(computation_amount, 0) == 0.0)
+ && (cost_or_zero(computation_amount, 1) == 0.0)) {
+ int i,nb = 0;
+ double value = 0.0;
+
+ for (i = 0; i < workstation_nb * workstation_nb; i++) {
+ if (cost_or_zero(communication_amount, i) > 0.0) {
+ nb++;
+ value = cost_or_zero(communication_amount, i);
+ }
+ }
+ if (nb == 1)
+ return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[1],value, rate);
+ }
+#undef cost_or_zero
+
+ THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks */
+ return NULL;
+}
+
/************
* Resource *
************/
-WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
+
+WorkstationVMHL13::WorkstationVMHL13(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
surf_resource_t ind_phys_workstation)
- : Resource(model, name, props)
- , WorkstationVMLmm(NULL, NULL)
- , WorkstationCLM03Lmm(model, name, props, NULL, NULL, NULL)
+ : WorkstationVM(model, name, props, NULL, NULL)
{
WorkstationPtr sub_ws = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(
// //// CPU RELATED STUFF ////
// Roughly, create a vcpu resource by using the values of the sub_cpu one.
- CpuCas01LmmPtr sub_cpu = dynamic_cast<CpuCas01LmmPtr>(
+ CpuCas01Ptr sub_cpu = dynamic_cast<CpuCas01Ptr>(
static_cast<ResourcePtr>(
surf_cpu_resource_priv(ind_phys_workstation)));
/* We create cpu_action corresponding to a VM process on the host operating system. */
/* FIXME: TODO: we have to peridocally input GUESTOS_NOISE to the system? how ? */
// vm_ws->cpu_action = surf_cpu_model_pm->extension.cpu.execute(ind_phys_workstation, GUESTOS_NOISE);
- p_action = dynamic_cast<CpuActionLmmPtr>(sub_cpu->execute(0));
+ p_action = dynamic_cast<CpuActionPtr>(sub_cpu->execute(0));
/* The SURF_WKS_LEVEL at host_lib saves workstation_CLM03 objects. Please
* note workstation_VM2013 objects, inheriting the workstation_CLM03
* A physical host does not disapper in the current SimGrid code, but a VM may
* disapper during a simulation.
*/
-WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm()
+WorkstationVMHL13::~WorkstationVMHL13()
{
/* ind_phys_workstation equals to smx_host_t */
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>(
+ CpuCas01Ptr cpu = dynamic_cast<CpuCas01Ptr>(
static_cast<ResourcePtr>(
surf_cpu_resource_priv(ind_vm_workstation)));
/* Free the workstation resource of the VM. */
}
-e_surf_resource_state_t WorkstationVMHL13Lmm::getState()
+void WorkstationVMHL13::updateState(tmgr_trace_event_t event_type, double value, double date) {
+ THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
+}
+
+bool WorkstationVMHL13::isUsed() {
+ THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
+ return -1;
+}
+
+e_surf_resource_state_t WorkstationVMHL13::getState()
{
return (e_surf_resource_state_t) p_currentState;
}
-void WorkstationVMHL13Lmm::setState(e_surf_resource_state_t state)
+void WorkstationVMHL13::setState(e_surf_resource_state_t state)
{
p_currentState = (e_surf_vm_state_t) state;
}
-void WorkstationVMHL13Lmm::suspend()
+void WorkstationVMHL13::suspend()
{
p_action->suspend();
p_currentState = SURF_VM_STATE_SUSPENDED;
}
-void WorkstationVMHL13Lmm::resume()
+void WorkstationVMHL13::resume()
{
p_action->resume();
p_currentState = SURF_VM_STATE_RUNNING;
}
-void WorkstationVMHL13Lmm::save()
+void WorkstationVMHL13::save()
{
p_currentState = SURF_VM_STATE_SAVING;
p_currentState = SURF_VM_STATE_SAVED;
}
-void WorkstationVMHL13Lmm::restore()
+void WorkstationVMHL13::restore()
{
p_currentState = SURF_VM_STATE_RESTORING;
/*
* Update the physical host of the given VM
*/
-void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm)
+void WorkstationVMHL13::migrate(surf_resource_t ind_dst_pm)
{
/* ind_phys_workstation equals to smx_host_t */
WorkstationPtr ws_dst = dynamic_cast<WorkstationPtr>(
#endif
/* create a cpu action bound to the pm model at the destination. */
- CpuActionLmmPtr new_cpu_action = dynamic_cast<CpuActionLmmPtr>(
- dynamic_cast<CpuCas01LmmPtr>(
+ CpuActionPtr new_cpu_action = dynamic_cast<CpuActionPtr>(
+ dynamic_cast<CpuCas01Ptr>(
static_cast<ResourcePtr>(
surf_cpu_resource_priv(ind_dst_pm)))->execute(0));
XBT_DEBUG("migrate VM(%s): change PM (%s to %s)", vm_name, pm_name_src, pm_name_dst);
}
-void WorkstationVMHL13Lmm::setBound(double bound){
+void WorkstationVMHL13::setBound(double bound){
p_action->setBound(bound);
}
-void WorkstationVMHL13Lmm::setAffinity(CpuLmmPtr cpu, unsigned long mask){
+void WorkstationVMHL13::setAffinity(CpuPtr cpu, unsigned long mask){
p_action->setAffinity(cpu, mask);
}
* A surf level object will be useless in the upper layer. Returing the
* dict_elm of the host.
**/
-surf_resource_t WorkstationVMHL13Lmm::getPm()
+surf_resource_t WorkstationVMHL13::getPm()
{
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)
+ActionPtr WorkstationVMHL13::execute(double size)
{
double old_cost = p_action->getCost();
double new_cost = old_cost + size;
p_action->setCost(new_cost);
- return WorkstationCLM03Lmm::execute(size);
+ return p_cpu->execute(size);
+}
+
+ActionPtr WorkstationVMHL13::sleep(double duration) {
+ return p_cpu->sleep(duration);
}
/**********
class WorkstationVMHL13Model;
typedef WorkstationVMHL13Model *WorkstationVMHL13ModelPtr;
-class WorkstationVMHL13Lmm;
-typedef WorkstationVMHL13Lmm *WorkstationVMHL13LmmPtr;
+class WorkstationVMHL13;
+typedef WorkstationVMHL13 *WorkstationVMHL13Ptr;
/*********
* Tools *
/*********
* Model *
*********/
-class WorkstationVMHL13Model : public WorkstationVMModel, public WorkstationCLM03Model {
+class WorkstationVMHL13Model : public WorkstationVMModel {
public:
WorkstationVMHL13Model();
~WorkstationVMHL13Model(){};
void adjustWeightOfDummyCpuActions() {};
xbt_dynar_t getRoute(WorkstationPtr src, WorkstationPtr dst);
ActionPtr communicate(WorkstationPtr src, WorkstationPtr dst, double size, double rate);
+ ActionPtr executeParallelTask(int workstation_nb,
+ void **workstation_list,
+ double *computation_amount,
+ double *communication_amount,
+ double rate);
+ void updateActionsState(double /*now*/, double /*delta*/);
};
/************
* Resource *
************/
-class WorkstationVMHL13Lmm : public WorkstationVMLmm, public WorkstationCLM03Lmm {
+class WorkstationVMHL13 : public WorkstationVM {
public:
- WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
- ~WorkstationVMHL13Lmm();
+ WorkstationVMHL13(WorkstationVMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t ind_phys_workstation);
+ ~WorkstationVMHL13();
void suspend();
void resume();
surf_resource_t getPm(); // will be vm_ws_get_pm()
void setBound(double bound);
- void setAffinity(CpuLmmPtr cpu, unsigned long mask);
+ void setAffinity(CpuPtr cpu, unsigned long mask);
//FIXME: remove
- void updateState(tmgr_trace_event_t event_type, double value, double date) {
- WorkstationCLM03Lmm::updateState(event_type, value, date);
- }
- bool isUsed() {
- return WorkstationCLM03Lmm::isUsed();
- }
- xbt_dict_t getProperties() {
- return WorkstationCLM03Lmm::getProperties();
- }
- ActionPtr execute(double size);
+ void updateState(tmgr_trace_event_t event_type, double value, double date);
+ bool isUsed();
+ ActionPtr execute(double size);
+ ActionPtr sleep(double duration);
};
/**********
* Resource *
************/
-
-WorkstationVMLmm::WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu)
- : WorkstationVM(netElm, cpu)
- , WorkstationLmm()
-{}
-
/*
* A physical host does not disapper in the current SimGrid code, but a VM may
* disapper during a simulation.
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>(
+ CpuCas01Ptr cpu = dynamic_cast<CpuCas01Ptr>(
static_cast<ResourcePtr>(
surf_cpu_resource_priv(ind_vm_workstation)));
* Resource *
************/
-class WorkstationVM : virtual public Workstation {
+class WorkstationVM : public Workstation {
public:
- WorkstationVM(RoutingEdgePtr netElm, CpuPtr cpu)
- : Workstation(NULL, netElm, cpu) {};
+ WorkstationVM(ModelPtr model, const char *name, xbt_dict_t props,
+ RoutingEdgePtr netElm, CpuPtr cpu)
+ : Workstation(model, name, props, NULL, netElm, cpu) {}
~WorkstationVM();
virtual void suspend()=0;
virtual surf_resource_t getPm()=0; // will be vm_ws_get_pm()
virtual void setBound(double bound)=0;
- virtual void setAffinity(CpuLmmPtr cpu, unsigned long mask)=0;
+ virtual void setAffinity(CpuPtr cpu, unsigned long mask)=0;
/* The workstation object of the lower layer */
CpuActionPtr p_action;
e_surf_vm_state_t p_currentState;
};
-class WorkstationVMLmm : public WorkstationVM, public WorkstationLmm {
-public:
- WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu);
-};
/**********
* Action *
WorkstationPtr WorkstationCLM03Model::createResource(const char *name){
- WorkstationPtr workstation = new WorkstationCLM03Lmm(surf_workstation_model, name, NULL,
+ WorkstationPtr workstation = new WorkstationCLM03(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))));
#define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0)
if ((workstation_nb == 1)
&& (cost_or_zero(communication_amount, 0) == 0.0))
- return ((WorkstationCLM03LmmPtr)workstation_list[0])->execute(computation_amount[0]);
+ return ((WorkstationCLM03Ptr)workstation_list[0])->execute(computation_amount[0]);
else if ((workstation_nb == 1)
&& (cost_or_zero(computation_amount, 0) == 0.0))
- return communicate((WorkstationCLM03LmmPtr)workstation_list[0], (WorkstationCLM03LmmPtr)workstation_list[0],communication_amount[0], rate);
+ return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[0],communication_amount[0], rate);
else if ((workstation_nb == 2)
&& (cost_or_zero(computation_amount, 0) == 0.0)
&& (cost_or_zero(computation_amount, 1) == 0.0)) {
}
}
if (nb == 1)
- return communicate((WorkstationCLM03LmmPtr)workstation_list[0], (WorkstationCLM03LmmPtr)workstation_list[1],value, rate);
+ return communicate((WorkstationCLM03Ptr)workstation_list[0], (WorkstationCLM03Ptr)workstation_list[1],value, rate);
}
#undef cost_or_zero
/************
* Resource *
************/
-WorkstationCLM03Lmm::WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
- : Resource(model, name, properties), Workstation(storage, netElm, cpu) {}
+WorkstationCLM03::WorkstationCLM03(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+ : Workstation(model, name, properties, storage, netElm, cpu) {}
-bool WorkstationCLM03Lmm::isUsed(){
+bool WorkstationCLM03::isUsed(){
THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
return -1;
}
-void WorkstationCLM03Lmm::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/){
+void WorkstationCLM03::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/){
THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */
}
-ActionPtr WorkstationCLM03Lmm::execute(double size) {
+ActionPtr WorkstationCLM03::execute(double size) {
return p_cpu->execute(size);
}
-ActionPtr WorkstationCLM03Lmm::sleep(double duration) {
+ActionPtr WorkstationCLM03::sleep(double duration) {
return p_cpu->sleep(duration);
}
-e_surf_resource_state_t WorkstationCLM03Lmm::getState() {
+e_surf_resource_state_t WorkstationCLM03::getState() {
return p_cpu->getState();
}
-
-
-
-
-
-
-
-
-
/**********
* Action *
**********/
class WorkstationCLM03Model;
typedef WorkstationCLM03Model *WorkstationCLM03ModelPtr;
-class WorkstationCLM03Lmm;
-typedef WorkstationCLM03Lmm *WorkstationCLM03LmmPtr;
+class WorkstationCLM03;
+typedef WorkstationCLM03 *WorkstationCLM03Ptr;
-class WorkstationCLM03ActionLmm;
-typedef WorkstationCLM03ActionLmm *WorkstationCLM03ActionLmmPtr;
+class WorkstationCLM03Action;
+typedef WorkstationCLM03Action *WorkstationCLM03ActionPtr;
/*********
* Model *
* Resource *
************/
-class WorkstationCLM03Lmm : public WorkstationLmm {
+class WorkstationCLM03 : public Workstation {
public:
- WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+ WorkstationCLM03(WorkstationModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
void updateState(tmgr_trace_event_t event_type, double value, double date);
* Action *
**********/
-class WorkstationCLM03ActionLmm : public WorkstationActionLmm {
+class WorkstationCLM03Action : public WorkstationAction {
public:
- WorkstationCLM03ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), WorkstationActionLmm() {};
+ WorkstationCLM03Action(ModelPtr model, double cost, bool failed)
+ : WorkstationAction(model, cost, failed) {}
};
xbt_lib_foreach(host_lib, cursor, key, ind_host) {
WorkstationPtr ws = dynamic_cast<WorkstationPtr>(
static_cast<ResourcePtr>(ind_host[SURF_WKS_LEVEL]));
- CpuCas01LmmPtr cpu_cas01 = dynamic_cast<CpuCas01LmmPtr>(
+ CpuCas01Ptr cpu_cas01 = dynamic_cast<CpuCas01Ptr>(
static_cast<ResourcePtr>(ind_host[SURF_CPU_LEVEL]));
if (!ws)
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);
+ WorkstationVMPtr ws_vm = dynamic_cast<WorkstationVMPtr>(ws);
- int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->constraint());
+ int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->getConstraint());
// int is_active_old = constraint_is_active(cpu_cas01);
// {
/************
* Resource *
************/
-Workstation::Workstation(xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
- : p_storage(storage), p_netElm(netElm), p_cpu(cpu)
+Workstation::Workstation(ModelPtr model, const char *name, xbt_dict_t props,
+ xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+ : Resource(model, name, props)
+ , p_storage(storage), p_netElm(netElm), p_cpu(cpu)
+{}
+
+Workstation::Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
+ xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu)
+ : Resource(model, name, props, constraint)
+ , p_storage(storage), p_netElm(netElm), p_cpu(cpu)
{}
int Workstation::getCore(){
class Workstation;
typedef Workstation *WorkstationPtr;
-class WorkstationLmm;
-typedef WorkstationLmm *WorkstationLmmPtr;
-
class WorkstationAction;
typedef WorkstationAction *WorkstationActionPtr;
-class WorkstationActionLmm;
-typedef WorkstationActionLmm *WorkstationActionLmmPtr;
-
/*********
* Tools *
*********/
* Resource *
************/
-class Workstation : virtual public Resource {
+class Workstation : public Resource {
public:
Workstation(){};
- Workstation(xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+ Workstation(ModelPtr model, const char *name, xbt_dict_t props,
+ xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
+ Workstation(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
+ xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu);
xbt_dict_t getProperties();
s_ws_params_t p_params;
};
-class WorkstationLmm : virtual public Workstation, public ResourceLmm {
-public:
- WorkstationLmm() {};
-};
-
/**********
* Action *
**********/
-class WorkstationAction : virtual public Action {
+class WorkstationAction : public Action {
public:
- WorkstationAction() {};
-};
+ WorkstationAction(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed) {}
+ WorkstationAction(ModelPtr model, double cost, bool failed, lmm_variable_t var)
+ : Action(model, cost, failed, var) {}
-class WorkstationActionLmm : public ActionLmm, public WorkstationAction {
-public:
- WorkstationActionLmm(): ActionLmm(), WorkstationAction() {};
};
double WorkstationL07Model::shareResources(double /*now*/)
{
- WorkstationL07ActionLmmPtr action;
+ WorkstationL07ActionPtr action;
ActionListPtr running_actions = getRunningActionSet();
double min = this->shareResourcesMaxMin(running_actions,
for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end())
; it != itend ; ++it) {
- action = dynamic_cast<WorkstationL07ActionLmmPtr>(&*it);
+ action = dynamic_cast<WorkstationL07ActionPtr>(&*it);
if (action->m_latency > 0) {
if (min < 0) {
min = action->m_latency;
void WorkstationL07Model::updateActionsState(double /*now*/, double delta)
{
double deltap = 0.0;
- WorkstationL07ActionLmmPtr action;
+ WorkstationL07ActionPtr action;
ActionListPtr actionSet = getRunningActionSet();
for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end())
; it != itend ; it=itNext) {
++itNext;
- action = dynamic_cast<WorkstationL07ActionLmmPtr>(&*it);
+ action = dynamic_cast<WorkstationL07ActionPtr>(&*it);
deltap = delta;
if (action->m_latency > 0) {
if (action->m_latency > deltap) {
i++))) {
constraint_id = lmm_constraint_id(cnst);
- if (static_cast<WorkstationLmmPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
+ if (static_cast<WorkstationPtr>(constraint_id)->getState() == SURF_RESOURCE_OFF) {
XBT_DEBUG("Action (%p) Failed!!", action);
action->finish();
action->setState(SURF_ACTION_FAILED);
*communication_amount,
double rate)
{
- WorkstationL07ActionLmmPtr action;
+ WorkstationL07ActionPtr action;
int i, j;
unsigned int cpt;
int nb_link = 0;
if (computation_amount[i] > 0)
nb_host++;
- action = new WorkstationL07ActionLmm(this, 1, 0);
+ action = new WorkstationL07Action(this, 1, 0);
XBT_DEBUG("Creating a parallel task (%p) with %d cpus and %d links.",
action, workstation_nb, nb_link);
action->m_suspended = 0; /* Should be useless because of the
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)->constraint(),
+ static_cast<CpuPtr>(dynamic_cast<WorkstationL07Ptr>(
+ static_cast<ResourcePtr>(workstation_list[i]))->p_cpu)->getConstraint(),
action->getVariable(), computation_amount[i]);
for (i = 0; i < workstation_nb; i++) {
xbt_dynar_foreach(route, cpt, _link) {
link = dynamic_cast<LinkL07Ptr>(static_cast<ResourcePtr>(_link));
- lmm_expand_add(ptask_maxmin_system, link->constraint(),
+ lmm_expand_add(ptask_maxmin_system, link->getConstraint(),
action->getVariable(),
communication_amount[i * workstation_nb + j]);
}
************/
WorkstationL07::WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu)
- : Resource(model, name, props),
- Workstation(NULL, netElm, cpu),
- WorkstationLmm()
+ : Workstation(model, name, props, NULL, netElm, cpu)
{
}
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))
+ : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale),
+ 1, 0, 0)
{
p_power.scale = power_scale;
xbt_assert(p_power.scale > 0, "Power has to be >0");
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)
+ : NetworkLink(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, bw_initial), history, state_trace)
{
m_bwCurrent = bw_initial;
if (bw_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());
+ lmm_constraint_shared(getConstraint());
}
bool CpuL07::isUsed(){
- return lmm_constraint_used(ptask_maxmin_system, constraint());
+ return lmm_constraint_used(ptask_maxmin_system, getConstraint());
}
bool LinkL07::isUsed(){
- return lmm_constraint_used(ptask_maxmin_system, constraint());
+ return lmm_constraint_used(ptask_maxmin_system, getConstraint());
}
void CpuL07::updateState(tmgr_trace_event_t event_type, double value, double /*date*/){
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, constraint(), m_powerCurrent * p_power.scale);
+ lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_powerCurrent * p_power.scale);
if (tmgr_trace_event_free(event_type))
p_power.event = NULL;
} else if (event_type == p_stateEvent) {
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, constraint(), m_bwCurrent);
+ lmm_update_constraint_bound(ptask_maxmin_system, getConstraint(), m_bwCurrent);
if (tmgr_trace_event_free(event_type))
p_bwEvent = NULL;
} else if (event_type == p_latEvent) {
lmm_variable_t var = NULL;
- WorkstationL07ActionLmmPtr action;
+ WorkstationL07ActionPtr action;
lmm_element_t elem = NULL;
m_latCurrent = value;
- while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, constraint(), &elem))) {
- action = (WorkstationL07ActionLmmPtr) lmm_variable_id(var);
+ while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) {
+ action = (WorkstationL07ActionPtr) lmm_variable_id(var);
action->updateBound();
}
if (tmgr_trace_event_free(event_type))
ActionPtr WorkstationL07::sleep(double duration)
{
- WorkstationL07ActionLmmPtr action = NULL;
+ WorkstationL07ActionPtr action = NULL;
XBT_IN("(%s,%g)", getName(), duration);
- action = dynamic_cast<WorkstationL07ActionLmmPtr>(execute(1.0));
+ action = dynamic_cast<WorkstationL07ActionPtr>(execute(1.0));
action->m_maxDuration = duration;
action->m_suspended = 2;
lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
bool LinkL07::isShared()
{
- return lmm_constraint_is_shared(constraint());
+ return lmm_constraint_is_shared(getConstraint());
}
/**********
* Action *
**********/
-WorkstationL07ActionLmm::~WorkstationL07ActionLmm(){
+WorkstationL07Action::~WorkstationL07Action(){
free(p_workstationList);
free(p_communicationAmount);
free(p_computationAmount);
}
-void WorkstationL07ActionLmm::updateBound()
+void WorkstationL07Action::updateBound()
{
double lat_current = 0.0;
double lat_bound = -1.0;
}
}
-int WorkstationL07ActionLmm::unref()
+int WorkstationL07Action::unref()
{
m_refcount--;
if (!m_refcount) {
return 0;
}
-void WorkstationL07ActionLmm::cancel()
+void WorkstationL07Action::cancel()
{
setState(SURF_ACTION_FAILED);
return;
}
-void WorkstationL07ActionLmm::suspend()
+void WorkstationL07Action::suspend()
{
XBT_IN("(%p))", this);
if (m_suspended != 2) {
XBT_OUT();
}
-void WorkstationL07ActionLmm::resume()
+void WorkstationL07Action::resume()
{
XBT_IN("(%p)", this);
if (m_suspended != 2) {
XBT_OUT();
}
-bool WorkstationL07ActionLmm::isSuspended()
+bool WorkstationL07Action::isSuspended()
{
return m_suspended == 1;
}
-void WorkstationL07ActionLmm::setMaxDuration(double duration)
+void WorkstationL07Action::setMaxDuration(double duration)
{ /* FIXME: should inherit */
XBT_IN("(%p,%g)", this, duration);
m_maxDuration = duration;
XBT_OUT();
}
-void WorkstationL07ActionLmm::setPriority(double priority)
+void WorkstationL07Action::setPriority(double priority)
{ /* FIXME: should inherit */
XBT_IN("(%p,%g)", this, priority);
m_priority = priority;
XBT_OUT();
}
-double WorkstationL07ActionLmm::getRemains()
+double WorkstationL07Action::getRemains()
{
XBT_IN("(%p)", this);
XBT_OUT();
class LinkL07;
typedef LinkL07 *LinkL07Ptr;
-class WorkstationL07ActionLmm;
-typedef WorkstationL07ActionLmm *WorkstationL07ActionLmmPtr;
+class WorkstationL07Action;
+typedef WorkstationL07Action *WorkstationL07ActionPtr;
/*********
* Tools *
* Resource *
************/
-class WorkstationL07 : public WorkstationLmm {
+class WorkstationL07 : public Workstation {
public:
WorkstationL07(WorkstationModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu);
//bool isUsed();
double getConsumedEnergy();
};
-class CpuL07 : public CpuLmm {
+class CpuL07 : public Cpu {
public:
s_surf_metric_t p_power;
tmgr_trace_event_t p_stateEvent;
double m_powerCurrent;
};
-class LinkL07 : public NetworkLinkLmm {
+class LinkL07 : public NetworkLink {
public:
LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props,
double bw_initial,
/**********
* Action *
**********/
-class WorkstationL07ActionLmm : public WorkstationActionLmm {
+class WorkstationL07Action : public WorkstationAction {
friend ActionPtr WorkstationL07::execute(double size);
friend ActionPtr WorkstationL07::sleep(double duration);
friend ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb,
*communication_amount,
double rate);
public:
- WorkstationL07ActionLmm(ModelPtr model, double cost, bool failed)
- : Action(model, cost, failed), WorkstationActionLmm() {};
- ~WorkstationL07ActionLmm();
+ WorkstationL07Action(ModelPtr model, double cost, bool failed)
+ : WorkstationAction(model, cost, failed) {};
+ ~WorkstationL07Action();
void updateBound();