From: Paul Bédaride Date: Wed, 18 Dec 2013 17:22:17 +0000 (+0100) Subject: Merge lmm into base to avoid diamond inheritance X-Git-Tag: v3_11_beta~165 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/c39f643b5bfb0e99887c209a94e49f841a2daae4 Merge lmm into base to avoid diamond inheritance --- diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 9d99c6a86a..a55976bcb2 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -141,7 +141,7 @@ CpuPtr CpuCas01Model::createResource(const char *name, xbt_dynar_t power_peak, "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(cpu)); return cpu; @@ -165,7 +165,7 @@ void CpuCas01Model::addTraces() /* 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(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm))); + CpuCas01Ptr host = static_cast(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); @@ -175,7 +175,7 @@ void CpuCas01Model::addTraces() 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(static_cast(surf_cpu_resource_priv(surf_cpu_resource_by_name(elm)))); + CpuCas01Ptr host = dynamic_cast(static_cast(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); @@ -188,13 +188,13 @@ void CpuCas01Model::addTraces() /************ * 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; @@ -215,7 +215,7 @@ CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model_, const char *name, xbt_dynar_t p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast(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) @@ -225,12 +225,12 @@ CpuCas01Lmm::~CpuCas01Lmm(){ 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; @@ -240,7 +240,7 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl 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 @@ -249,8 +249,8 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl m_powerPeak); #endif while ((var = lmm_get_var_from_cnst - (surf_cpu_model_pm->getMaxminSystem(), constraint(), &elem))) { - CpuCas01ActionLmmPtr action = static_cast(static_cast(lmm_variable_id(var))); + (surf_cpu_model_pm->getMaxminSystem(), getConstraint(), &elem))) { + CpuCas01ActionPtr action = static_cast(static_cast(lmm_variable_id(var))); lmm_update_variable_bound(surf_cpu_model_pm->getMaxminSystem(), action->getVariable(), @@ -267,12 +267,12 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl 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(lmm_variable_id(var)); + ActionPtr action = static_cast(lmm_variable_id(var)); if (action->getState() == SURF_ACTION_RUNNING || action->getState() == SURF_ACTION_READY || @@ -292,25 +292,25 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl 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 @@ -338,7 +338,7 @@ CpuActionPtr CpuCas01Lmm::sleep(double duration) return action; } -xbt_dynar_t CpuCas01Lmm::getWattsRangeList() +xbt_dynar_t CpuCas01::getWattsRangeList() { xbt_dynar_t power_range_list; xbt_dynar_t power_tuple; @@ -387,7 +387,7 @@ xbt_dynar_t CpuCas01Lmm::getWattsRangeList() * 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; @@ -421,7 +421,7 @@ double CpuCas01Lmm::getCurrentWattsValue(double cpu_load) * 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(); @@ -437,12 +437,12 @@ void CpuCas01Lmm::updateEnergy(double cpu_load) 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)"); @@ -450,12 +450,12 @@ double CpuCas01Lmm::getPowerPeakAt(int pstate_index) 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)"); @@ -465,7 +465,7 @@ void CpuCas01Lmm::setPowerPeakAt(int pstate_index) m_powerPeak = new_power_peak; } -double CpuCas01Lmm::getConsumedEnergy() +double CpuCas01::getConsumedEnergy() { return p_energy->total_energy; } @@ -474,21 +474,20 @@ double CpuCas01Lmm::getConsumedEnergy() * 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(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(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); } @@ -496,14 +495,14 @@ CpuCas01ActionLmm::CpuCas01ActionLmm(ModelPtr model_, double cost, bool failed, * Update the CPU total energy for a finished action * */ -void CpuCas01ActionLmm::updateEnergy() +void CpuCas01Action::updateEnergy() { - CpuCas01LmmPtr cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var + CpuCas01Ptr cpu = static_cast(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); } } diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index ccac472ce1..7f54163030 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -6,11 +6,11 @@ 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 * @@ -47,15 +47,15 @@ typedef struct energy_cpu_cas01 { 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); @@ -81,13 +81,13 @@ public: /********** * 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(); }; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index fa64436210..b26d58bc09 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -13,10 +13,10 @@ CpuModelPtr surf_cpu_model_vm; 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(static_cast(xbt_heap_pop(getActionHeap()))); + action = static_cast(static_cast(xbt_heap_pop(getActionHeap()))); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); #ifdef HAVE_TRACING if (TRACE_is_enabled()) { @@ -46,7 +46,7 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) ActionListPtr actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { - action = dynamic_cast(&*it); + action = static_cast(&*it); if (smaller < 0) { smaller = action->getLastUpdate(); continue; @@ -65,13 +65,13 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) 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(&*it); + action = static_cast(&*it); #ifdef HAVE_TRACING if (TRACE_is_enabled()) { CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var @@ -112,10 +112,52 @@ void CpuModel::updateActionsStateFull(double now, double delta) * 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; @@ -132,45 +174,11 @@ int Cpu::getCore() 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; @@ -200,7 +208,7 @@ void CpuActionLmm::updateRemainingLazy(double now) 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; @@ -231,10 +239,9 @@ void CpuActionLmm::setBound(double 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(_cpu); XBT_IN("(%p,%lx)", this, mask); { diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 852e63757a..6b8c405452 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -13,15 +13,9 @@ typedef CpuModel *CpuModelPtr; class Cpu; typedef Cpu *CpuPtr; -class CpuLmm; -typedef CpuLmm *CpuLmmPtr; - class CpuAction; typedef CpuAction *CpuActionPtr; -class CpuActionLmm; -typedef CpuActionLmm *CpuActionLmmPtr; - /********* * Model * *********/ @@ -38,10 +32,15 @@ public: /************ * 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(); @@ -58,46 +57,28 @@ public: int m_core; double m_powerPeak; /*< CPU power peak */ double m_powerScale; /*< Percentage of CPU disponible */ -protected: - //virtual boost::shared_ptr execute(double size) = 0; - //virtual boost::shared_ptr 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_ */ diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 2f0d04405d..df04e5c544 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -564,8 +564,8 @@ CpuTi::CpuTi(CpuTiModelPtr 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) -, Cpu(core, 0, powerScale) { +: Cpu(model, name, properties, core, 0, powerScale) +{ p_powerEvent = NULL; m_stateCurrent = stateInitial; m_powerScale = powerScale; @@ -866,8 +866,7 @@ static void cpu_ti_action_update_index_heap(void *action, int i) 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; diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 35a85dcf7e..e2e9406b86 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -177,6 +177,7 @@ public: double getRemains(); void setAffinity(CpuPtr /*cpu*/, unsigned long /*mask*/) {}; void setBound(double /*bound*/) {}; + void updateEnergy() {}; CpuTiPtr p_cpu; int m_indexHeap; diff --git a/src/surf/lagrange.cpp b/src/surf/lagrange.cpp index 8128625240..2cd5eaa6dd 100644 --- a/src/surf/lagrange.cpp +++ b/src/surf/lagrange.cpp @@ -157,9 +157,10 @@ static double dual_objective(xbt_swag_t var_list, xbt_swag_t cnst_list) 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; } diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index 876fa33d9c..d3dd77ff2b 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -667,7 +667,7 @@ void lmm_solve(lmm_system_t sys) cnst->usage = elem->value / elem->variable->weight; make_elem_active(elem); - ActionLmmPtr action = static_cast(elem->variable->id); + ActionPtr action = static_cast(elem->variable->id); if (sys->keep_track && !action->is_linked()) sys->keep_track->push_back(*action); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 64d7128ffa..d4c1ab67fc 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -60,7 +60,7 @@ static void net_add_traces(void){ /* 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( + NetworkCm02LinkPtr link = dynamic_cast( static_cast( xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL))); @@ -75,7 +75,7 @@ static void net_add_traces(void){ 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( + NetworkCm02LinkPtr link = dynamic_cast( static_cast( xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL))); @@ -90,7 +90,7 @@ static void net_add_traces(void){ 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( + NetworkCm02LinkPtr link = dynamic_cast( static_cast( xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL))); @@ -297,8 +297,8 @@ NetworkLinkPtr NetworkCm02Model::createResource(const char *name, "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); @@ -310,10 +310,10 @@ NetworkLinkPtr NetworkCm02Model::createResource(const char *name, 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()) { @@ -323,7 +323,7 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem, action->getVariable(), i); - NetworkCm02LinkLmmPtr link = static_cast(lmm_constraint_id(constraint)); + NetworkCm02LinkPtr link = static_cast(lmm_constraint_id(constraint)); TRACE_surf_link_set_utilization(link->getName(), action->getCategory(), (lmm_variable_getvalue(action->getVariable())* @@ -365,9 +365,9 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, { 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; @@ -383,7 +383,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, src->p_name, dst->p_name); xbt_dynar_foreach(route, i, _link) { - link = dynamic_cast(static_cast(_link)); + link = dynamic_cast(static_cast(_link)); if (link->getState() == SURF_RESOURCE_OFF) { failed = 1; break; @@ -392,7 +392,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, if (sg_network_crosstraffic == 1) { routing_platf->getRouteAndLatency(dst, src, &back_route, NULL); xbt_dynar_foreach(back_route, i, _link) { - link = dynamic_cast(static_cast(_link)); + link = dynamic_cast(static_cast(_link)); if (link->getState() == SURF_RESOURCE_OFF) { failed = 1; break; @@ -400,7 +400,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, } } - action = new NetworkCm02ActionLmm(this, size, failed); + action = new NetworkCm02Action(this, size, failed); #ifdef HAVE_LATENCY_BOUND_TRACKING action->m_latencyLimited = 0; @@ -416,12 +416,12 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, bandwidth_bound = -1.0; if (sg_weight_S_parameter > 0) { xbt_dynar_foreach(route, i, _link) { - link = dynamic_cast(static_cast(_link)); + link = dynamic_cast(static_cast(_link)); action->m_weight += sg_weight_S_parameter / link->getBandwidth(); } } xbt_dynar_foreach(route, i, _link) { - link = dynamic_cast(static_cast(_link)); + link = dynamic_cast(static_cast(_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); @@ -434,8 +434,8 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, 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(*static_cast(xbt_dynar_get_ptr(route, 0))); + //link = *(NetworkCm02LinkPtr *) xbt_dynar_get_ptr(route, 0); + link = dynamic_cast(*static_cast(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, @@ -447,7 +447,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, constraints_per_variable += xbt_dynar_length(back_route); if (action->m_latency > 0) { - action->p_variable = lmm_variable_new(p_maxminSystem, static_cast(action), 0.0, -1.0, + action->p_variable = lmm_variable_new(p_maxminSystem, static_cast(action), 0.0, -1.0, constraints_per_variable); if (p_updateMechanism == UM_LAZY) { // add to the heap the event when the latency is payed @@ -456,7 +456,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, 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(action), 1.0, -1.0, constraints_per_variable); + action->p_variable = lmm_variable_new(p_maxminSystem, static_cast(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); @@ -465,15 +465,15 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, } xbt_dynar_foreach(route, i, _link) { - link = dynamic_cast(static_cast(_link)); - lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), 1.0); + link = dynamic_cast(static_cast(_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(static_cast(_link)); - lmm_expand(p_maxminSystem, link->constraint(), action->getVariable(), .05); + link = dynamic_cast(static_cast(_link)); + lmm_expand(p_maxminSystem, link->getConstraint(), action->getVariable(), .05); } } @@ -488,7 +488,7 @@ ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, /************ * 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, @@ -499,8 +499,7 @@ NetworkCm02LinkLmm::NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *na 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; @@ -516,12 +515,12 @@ NetworkCm02LinkLmm::NetworkCm02LinkLmm(NetworkCm02ModelPtr model, const char *na p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast(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 " */ @@ -534,19 +533,19 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type, (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); @@ -558,11 +557,11 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type, 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) @@ -588,7 +587,7 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type, 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; @@ -612,14 +611,14 @@ void NetworkCm02LinkLmm::updateState(tmgr_trace_event_t event_type, 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; @@ -654,7 +653,7 @@ void NetworkCm02ActionLmm::updateRemainingLazy(double now) m_lastUpdate = now; m_lastValue = lmm_variable_getvalue(getVariable()); } -void NetworkCm02ActionLmm::recycle() +void NetworkCm02Action::recycle() { return; } diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 67a20851a5..1f72f35d29 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -11,11 +11,11 @@ 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 * @@ -60,9 +60,9 @@ public: * 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, @@ -81,12 +81,12 @@ public: * 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(); }; diff --git a/src/surf/network_constant.cpp b/src/surf/network_constant.cpp index 6934835d78..af81e494ba 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -24,13 +24,13 @@ void surf_network_model_init_Constant() 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(&*it); + action = dynamic_cast(&*it); if (action->m_latency > 0) { if (min < 0) min = action->m_latency; @@ -44,12 +44,12 @@ double NetworkConstantModel::shareResources(double /*now*/) 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(&*it); + action = dynamic_cast(&*it); if (action->m_latency > 0) { if (action->m_latency > delta) { double_update(&(action->m_latency), delta); @@ -79,7 +79,7 @@ ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr d 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; @@ -88,30 +88,30 @@ ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr d /************ * 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 */ @@ -121,7 +121,7 @@ bool NetworkConstantLinkLmm::isShared() * Action * **********/ -int NetworkConstantActionLmm::unref() +int NetworkConstantAction::unref() { m_refcount--; if (!m_refcount) { @@ -133,35 +133,35 @@ int NetworkConstantActionLmm::unref() 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; } diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 8575f00867..ec632ce3d7 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -9,11 +9,11 @@ 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 * @@ -29,16 +29,16 @@ public: 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(); @@ -49,10 +49,12 @@ public: /********** * 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(); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 6bc4328dfd..49103cebbb 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -34,18 +34,24 @@ double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double / 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(this)); } -bool NetworkLinkLmm::isUsed() +bool NetworkLink::isUsed() { - return lmm_constraint_used(getModel()->getMaxminSystem(), constraint()); + return lmm_constraint_used(getModel()->getMaxminSystem(), getConstraint()); } double NetworkLink::getLatency() @@ -53,14 +59,14 @@ 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_ */ diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index ed28c8663c..fd646bb78f 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -19,15 +19,9 @@ typedef NetworkModel *NetworkModelPtr; class NetworkLink; typedef NetworkLink *NetworkLinkPtr; -class NetworkLinkLmm; -typedef NetworkLinkLmm *NetworkLinkLmmPtr; - class NetworkAction; typedef NetworkAction *NetworkActionPtr; -class NetworkActionLmm; -typedef NetworkActionLmm *NetworkActionLmmPtr; - /********* * Tools * *********/ @@ -64,8 +58,7 @@ public: 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 @@ -80,27 +73,24 @@ public: * 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; }; @@ -108,9 +98,12 @@ public: /********** * 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; @@ -125,11 +118,6 @@ public: }; -class NetworkActionLmm : public ActionLmm, public NetworkAction { -public: - NetworkActionLmm() {}; -}; - #endif /* SURF_NETWORK_INTERFACE_HPP_ */ diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index a023019e79..5e651cec32 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -99,7 +99,7 @@ NetworkSmpiModel::~NetworkSmpiModel(){ } } -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; @@ -136,11 +136,11 @@ void NetworkSmpiModel::gapAppend(double size, const NetworkLinkLmmPtr link, Netw } } -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(lmm_action); if (sg_sender_gap > 0.0 && action->p_senderLinkName && action->p_senderFifoItem) { @@ -180,6 +180,7 @@ double NetworkSmpiModel::bandwidthFactor(double size) return current; } + double NetworkSmpiModel::latencyFactor(double size) { if (!smpi_lat_factor) diff --git a/src/surf/network_smpi.hpp b/src/surf/network_smpi.hpp index 9f7e80921e..25e958cdbf 100644 --- a/src/surf/network_smpi.hpp +++ b/src/surf/network_smpi.hpp @@ -20,8 +20,8 @@ public: 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); diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index dd50e5a9d5..4869a5c329 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -34,14 +34,33 @@ StorageModel::~StorageModel(){ * 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); @@ -117,23 +136,21 @@ sg_size_t Storage::getSize(){ 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) { } diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index 634bd942d4..d11f501f3c 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -15,14 +15,14 @@ typedef StorageModel *StorageModelPtr; 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 * @@ -41,9 +41,13 @@ public: * 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(); @@ -69,12 +73,6 @@ public: 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*/ @@ -89,10 +87,13 @@ typedef enum { } 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; @@ -100,13 +101,6 @@ public: 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; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index 419f064fda..0d0e831099 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -240,7 +240,7 @@ StoragePtr StorageN11Model::createResource(const char* id, const char* type_id, 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); @@ -265,7 +265,7 @@ double StorageN11Model::shareResources(double now) unsigned int i, j; StoragePtr storage; void *_write_action; - StorageActionLmmPtr write_action; + StorageActionPtr write_action; double min_completion = shareResourcesMaxMin(getRunningActionSet(), p_maxminSystem, lmm_solve); @@ -278,7 +278,7 @@ double StorageN11Model::shareResources(double now) // Foreach write action on disk xbt_dynar_foreach(storage->p_writeActions, j, _write_action) { - write_action = dynamic_cast(static_cast(_write_action)); + write_action = dynamic_cast(static_cast(_write_action)); rate += lmm_variable_getvalue(write_action->getVariable()); } if(rate > 0) @@ -290,13 +290,13 @@ double StorageN11Model::shareResources(double now) 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(&*it); + action = dynamic_cast(&*it); if(action->m_type == WRITE) { // Update the disk usage @@ -347,17 +347,17 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) * 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); @@ -400,7 +400,7 @@ StorageActionPtr StorageN11Lmm::ls(const char* path) 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; @@ -421,21 +421,21 @@ StorageActionPtr StorageN11Lmm::open(const char* mount, const char* path) 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(static_cast(_write_action)); + write_action = dynamic_cast(static_cast(_write_action)); if ((write_action->p_file) == fd) { xbt_dynar_cursor_rm(p_writeActions, &i); write_action->unref(); @@ -444,11 +444,11 @@ StorageActionPtr StorageN11Lmm::close(surf_file_t fd) 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; @@ -457,16 +457,16 @@ StorageActionPtr StorageN11Lmm::read(surf_file_t fd, sg_size_t 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 @@ -476,7 +476,7 @@ StorageActionPtr StorageN11Lmm::write(surf_file_t fd, sg_size_t size) 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); @@ -491,7 +491,7 @@ void StorageN11Lmm::rename(const char *src, const char *dest) 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);*/ @@ -507,7 +507,7 @@ xbt_dict_t StorageN11Lmm::getContent() return content_dict; } -sg_size_t StorageN11Lmm::getSize(){ +sg_size_t StorageN11::getSize(){ return m_size; } @@ -515,13 +515,14 @@ sg_size_t StorageN11Lmm::getSize(){ * 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: @@ -529,11 +530,11 @@ StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model_, double cost, bool fail 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); @@ -543,7 +544,7 @@ StorageN11ActionLmm::StorageN11ActionLmm(ModelPtr model_, double cost, bool fail XBT_OUT(); } -int StorageN11ActionLmm::unref() +int StorageN11Action::unref() { m_refcount--; if (!m_refcount) { @@ -560,13 +561,13 @@ int StorageN11ActionLmm::unref() 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) { @@ -578,22 +579,22 @@ void StorageN11ActionLmm::suspend() 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; } diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 2c1c822aaf..0bf81a25fb 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -13,14 +13,14 @@ typedef StorageN11Model *StorageN11ModelPtr; 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; /********* @@ -41,9 +41,9 @@ public: * 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); @@ -64,10 +64,10 @@ public: * 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(); diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 00959bb04a..b54154aae7 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -434,7 +434,7 @@ void surf_vm_workstation_set_bound(surf_resource_t resource, double bound){ } 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(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){ diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index b2607b8d94..83d72ab6be 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -492,7 +492,7 @@ double Model::shareResources(double now) double Model::shareResourcesLazy(double now) { - ActionLmmPtr action = NULL; + ActionPtr action = NULL; double min = -1; double value; @@ -507,7 +507,7 @@ double Model::shareResourcesLazy(double now) p_modifiedSet->size()); while(!p_modifiedSet->empty()) { - action = dynamic_cast(&(p_modifiedSet->front())); + action = &(p_modifiedSet->front()); p_modifiedSet->pop_front(); int max_dur_flag = 0; @@ -574,7 +574,7 @@ double Model::shareResourcesMaxMin(ActionListPtr running_actions, void (*solve) (lmm_system_t)) { void *_action = NULL; - ActionLmmPtr action = NULL; + ActionPtr action = NULL; double min = -1; double value = -1; @@ -582,7 +582,7 @@ double Model::shareResourcesMaxMin(ActionListPtr running_actions, ActionList::iterator it(running_actions->begin()), itend(running_actions->end()); for(; it != itend ; ++it) { - action = dynamic_cast(&*it); + action = &*it; value = lmm_variable_getvalue(action->getVariable()); if ((value > 0) || (action->getMaxDuration() >= 0)) break; @@ -603,7 +603,7 @@ double Model::shareResourcesMaxMin(ActionListPtr running_actions, for (++it; it != itend; ++it) { - action = dynamic_cast(&*it); + action = &*it; value = lmm_variable_getvalue(action->getVariable()); if (value > 0) { if (action->getRemains() > 0) @@ -710,6 +710,11 @@ Resource::Resource(surf_model_t model, const char *name, xbt_dict_t props) , 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) @@ -746,14 +751,6 @@ void Resource::turnOff() } } -ResourceLmm::ResourceLmm() - : p_constraint(NULL) -{} - -ResourceLmm::ResourceLmm(lmm_constraint_t constraint) - : p_constraint(constraint) -{} - /********** * Action * **********/ @@ -781,6 +778,38 @@ Action::Action(ModelPtr model, double cost, bool failed) , 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; @@ -805,18 +834,6 @@ void Action::finish() { 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()) @@ -862,13 +879,6 @@ double Action::getFinishTime() 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; @@ -887,7 +897,7 @@ void Action::ref(){ m_refcount++; } -void ActionLmm::setMaxDuration(double duration) +void Action::setMaxDuration(double duration) { XBT_IN("(%p,%g)", this, duration); m_maxDuration = duration; @@ -896,9 +906,9 @@ void ActionLmm::setMaxDuration(double 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; @@ -909,7 +919,7 @@ void ActionLmm::setPriority(double 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)); @@ -917,7 +927,7 @@ void ActionLmm::cancel(){ } } -int ActionLmm::unref(){ +int Action::unref(){ m_refcount--; if (!m_refcount) { if (actionHook::is_linked()) @@ -936,7 +946,7 @@ int ActionLmm::unref(){ return 0; } -void ActionLmm::suspend() +void Action::suspend() { XBT_IN("(%p)", this); if (m_suspended != 2) { @@ -948,7 +958,7 @@ void ActionLmm::suspend() XBT_OUT(); } -void ActionLmm::resume() +void Action::resume() { XBT_IN("(%p)", this); if (m_suspended != 2) { @@ -960,7 +970,7 @@ void ActionLmm::resume() XBT_OUT(); } -bool ActionLmm::isSuspended() +bool Action::isSuspended() { return m_suspended == 1; } @@ -971,13 +981,13 @@ bool ActionLmm::isSuspended() * 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) { @@ -987,14 +997,14 @@ void ActionLmm::heapRemove(xbt_heap_t heap) /* 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 */ @@ -1005,7 +1015,7 @@ double ActionLmm::getRemains() } //FIXME split code in the right places -void ActionLmm::updateRemainingLazy(double now) +void Action::updateRemainingLazy(double now) { double delta = 0.0; @@ -1062,23 +1072,3 @@ void ActionLmm::updateRemainingLazy(double now) 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; -}*/ - diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 1221cc446d..2558c9ea8e 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -72,11 +72,8 @@ typedef boost::intrusive::list ActionList; typedef ActionList* ActionListPtr; typedef boost::intrusive::list_base_hook<> actionHook; -//class ActionLmm; -typedef ActionLmm* ActionLmmPtr; - struct lmmTag; -typedef boost::intrusive::list > > > ActionLmmList; +typedef boost::intrusive::list > > > ActionLmmList; typedef ActionLmmList* ActionLmmListPtr; typedef boost::intrusive::list_base_hook > actionLmmHook; @@ -128,11 +125,11 @@ public: 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;} @@ -187,8 +184,11 @@ protected: 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); @@ -207,25 +207,21 @@ public: 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; @@ -255,6 +251,7 @@ public: Action(); Action(ModelPtr model, double cost, bool failed); + Action(ModelPtr model, double cost, bool failed, lmm_variable_t var); virtual ~Action(); void finish(); @@ -281,13 +278,13 @@ public: 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 @@ -310,13 +307,7 @@ private: 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; @@ -326,40 +317,16 @@ protected: 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_ */ diff --git a/src/surf/vm_workstation_hl13.cpp b/src/surf/vm_workstation_hl13.cpp index b9dd19b09c..c403499423 100644 --- a/src/surf/vm_workstation_hl13.cpp +++ b/src/surf/vm_workstation_hl13.cpp @@ -27,12 +27,17 @@ WorkstationVMHL13Model::WorkstationVMHL13Model() : WorkstationVMModel() { 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 @@ -40,7 +45,7 @@ ActionPtr WorkstationVMHL13Model::communicate(WorkstationPtr src, WorkstationPtr void WorkstationVMHL13Model::createResource(const char *name, void *ind_phys_workstation) { - WorkstationVMHL13LmmPtr ws = new WorkstationVMHL13Lmm(this, name, NULL, static_cast(ind_phys_workstation)); + WorkstationVMHL13Ptr ws = new WorkstationVMHL13(this, name, NULL, static_cast(ind_phys_workstation)); xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast(ws)); @@ -49,7 +54,7 @@ void WorkstationVMHL13Model::createResource(const char *name, void *ind_phys_wor */ } -static inline double get_solved_value(CpuActionLmmPtr cpu_action) +static inline double get_solved_value(CpuActionPtr cpu_action) { return cpu_action->getVariable()->value; } @@ -112,7 +117,7 @@ double WorkstationVMHL13Model::shareResources(double now) xbt_lib_foreach(host_lib, cursor, key, ind_host) { WorkstationPtr ws = dynamic_cast( static_cast(ind_host[SURF_WKS_LEVEL])); - CpuLmmPtr cpu = dynamic_cast( + CpuPtr cpu = dynamic_cast( static_cast(ind_host[SURF_CPU_LEVEL])); if (!ws) @@ -125,7 +130,7 @@ double WorkstationVMHL13Model::shareResources(double now) /* It is a virtual machine, so we can cast it to workstation_VM2013_t */ WorkstationVMPtr ws_vm = dynamic_cast(ws); - double solved_value = get_solved_value(reinterpret_cast(ws_vm->p_action)); + double solved_value = get_solved_value(reinterpret_cast(ws_vm->p_action)); XBT_DEBUG("assign %f to vm %s @ pm %s", solved_value, ws->getName(), ws_vm->p_subWs->getName()); @@ -133,13 +138,31 @@ double WorkstationVMHL13Model::shareResources(double now) // cpu_cas01->constraint->bound = solved_value; xbt_assert(cpu->getModel() == static_cast(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 @@ -179,14 +202,46 @@ double WorkstationVMHL13Model::shareResources(double now) 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( static_cast( @@ -209,7 +264,7 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch // //// CPU RELATED STUFF //// // Roughly, create a vcpu resource by using the values of the sub_cpu one. - CpuCas01LmmPtr sub_cpu = dynamic_cast( + CpuCas01Ptr sub_cpu = dynamic_cast( static_cast( surf_cpu_resource_priv(ind_phys_workstation))); @@ -229,7 +284,7 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch /* 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(sub_cpu->execute(0)); + p_action = dynamic_cast(sub_cpu->execute(0)); /* The SURF_WKS_LEVEL at host_lib saves workstation_CLM03 objects. Please * note workstation_VM2013 objects, inheriting the workstation_CLM03 @@ -245,13 +300,13 @@ WorkstationVMHL13Lmm::WorkstationVMHL13Lmm(WorkstationVMModelPtr model, const ch * 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( + CpuCas01Ptr cpu = dynamic_cast( static_cast( surf_cpu_resource_priv(ind_vm_workstation))); @@ -285,29 +340,38 @@ WorkstationVMHL13Lmm::~WorkstationVMHL13Lmm() /* 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; @@ -316,7 +380,7 @@ void WorkstationVMHL13Lmm::save() p_currentState = SURF_VM_STATE_SAVED; } -void WorkstationVMHL13Lmm::restore() +void WorkstationVMHL13::restore() { p_currentState = SURF_VM_STATE_RESTORING; @@ -328,7 +392,7 @@ void WorkstationVMHL13Lmm::restore() /* * 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( @@ -369,8 +433,8 @@ void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm) #endif /* create a cpu action bound to the pm model at the destination. */ - CpuActionLmmPtr new_cpu_action = dynamic_cast( - dynamic_cast( + CpuActionPtr new_cpu_action = dynamic_cast( + dynamic_cast( static_cast( surf_cpu_resource_priv(ind_dst_pm)))->execute(0)); @@ -397,11 +461,11 @@ void WorkstationVMHL13Lmm::migrate(surf_resource_t ind_dst_pm) 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); } @@ -409,13 +473,13 @@ void WorkstationVMHL13Lmm::setAffinity(CpuLmmPtr cpu, unsigned long 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; @@ -426,7 +490,11 @@ ActionPtr WorkstationVMHL13Lmm::execute(double 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); } /********** diff --git a/src/surf/vm_workstation_hl13.hpp b/src/surf/vm_workstation_hl13.hpp index 4278426505..88e726de53 100644 --- a/src/surf/vm_workstation_hl13.hpp +++ b/src/surf/vm_workstation_hl13.hpp @@ -22,8 +22,8 @@ void surf_vm_workstation_model_init(void); class WorkstationVMHL13Model; typedef WorkstationVMHL13Model *WorkstationVMHL13ModelPtr; -class WorkstationVMHL13Lmm; -typedef WorkstationVMHL13Lmm *WorkstationVMHL13LmmPtr; +class WorkstationVMHL13; +typedef WorkstationVMHL13 *WorkstationVMHL13Ptr; /********* * Tools * @@ -32,7 +32,7 @@ typedef WorkstationVMHL13Lmm *WorkstationVMHL13LmmPtr; /********* * Model * *********/ -class WorkstationVMHL13Model : public WorkstationVMModel, public WorkstationCLM03Model { +class WorkstationVMHL13Model : public WorkstationVMModel { public: WorkstationVMHL13Model(); ~WorkstationVMHL13Model(){}; @@ -41,16 +41,22 @@ public: 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(); @@ -66,20 +72,14 @@ public: 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); }; /********** diff --git a/src/surf/vm_workstation_interface.cpp b/src/surf/vm_workstation_interface.cpp index 4c4959162e..7572e71224 100644 --- a/src/surf/vm_workstation_interface.cpp +++ b/src/surf/vm_workstation_interface.cpp @@ -24,12 +24,6 @@ WorkstationVMModel::WorkstationVMModel() : WorkstationModel("Virtual Workstation * 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. @@ -40,7 +34,7 @@ WorkstationVM::~WorkstationVM() 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( + CpuCas01Ptr cpu = dynamic_cast( static_cast( surf_cpu_resource_priv(ind_vm_workstation))); diff --git a/src/surf/vm_workstation_interface.hpp b/src/surf/vm_workstation_interface.hpp index 9c067ed8ee..5624de0492 100644 --- a/src/surf/vm_workstation_interface.hpp +++ b/src/surf/vm_workstation_interface.hpp @@ -43,10 +43,11 @@ public: * 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; @@ -60,7 +61,7 @@ public: 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; @@ -68,10 +69,6 @@ public: e_surf_vm_state_t p_currentState; }; -class WorkstationVMLmm : public WorkstationVM, public WorkstationLmm { -public: - WorkstationVMLmm(RoutingEdgePtr netElm, CpuPtr cpu); -}; /********** * Action * diff --git a/src/surf/workstation_clm03.cpp b/src/surf/workstation_clm03.cpp index 7b45c6aee7..ba59999caa 100644 --- a/src/surf/workstation_clm03.cpp +++ b/src/surf/workstation_clm03.cpp @@ -63,7 +63,7 @@ void WorkstationCLM03Model::parseInit(sg_platf_host_cbarg_t host){ 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(static_cast(xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL)))); @@ -108,10 +108,10 @@ ActionPtr WorkstationCLM03Model::executeParallelTask(int workstation_nb, #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)) { @@ -125,7 +125,7 @@ ActionPtr WorkstationCLM03Model::executeParallelTask(int workstation_nb, } } 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 @@ -149,39 +149,30 @@ ActionPtr WorkstationCLM03Model::communicate(WorkstationPtr src, WorkstationPtr /************ * 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 * **********/ diff --git a/src/surf/workstation_clm03.hpp b/src/surf/workstation_clm03.hpp index ccf2480e9b..56534fffae 100644 --- a/src/surf/workstation_clm03.hpp +++ b/src/surf/workstation_clm03.hpp @@ -13,11 +13,11 @@ 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 * @@ -47,9 +47,9 @@ public: * 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); @@ -71,9 +71,10 @@ public: * 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) {} }; diff --git a/src/surf/workstation_interface.cpp b/src/surf/workstation_interface.cpp index ddcfab7e04..8e8e83220a 100644 --- a/src/surf/workstation_interface.cpp +++ b/src/surf/workstation_interface.cpp @@ -41,7 +41,7 @@ void WorkstationModel::adjustWeightOfDummyCpuActions() xbt_lib_foreach(host_lib, cursor, key, ind_host) { WorkstationPtr ws = dynamic_cast( static_cast(ind_host[SURF_WKS_LEVEL])); - CpuCas01LmmPtr cpu_cas01 = dynamic_cast( + CpuCas01Ptr cpu_cas01 = dynamic_cast( static_cast(ind_host[SURF_CPU_LEVEL])); if (!ws) @@ -52,9 +52,9 @@ void WorkstationModel::adjustWeightOfDummyCpuActions() 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(ws); + WorkstationVMPtr ws_vm = dynamic_cast(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); // { @@ -81,8 +81,16 @@ void WorkstationModel::adjustWeightOfDummyCpuActions() /************ * 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(){ diff --git a/src/surf/workstation_interface.hpp b/src/surf/workstation_interface.hpp index a4622e7933..2432c0f2b4 100644 --- a/src/surf/workstation_interface.hpp +++ b/src/surf/workstation_interface.hpp @@ -16,15 +16,9 @@ typedef WorkstationModel *WorkstationModelPtr; class Workstation; typedef Workstation *WorkstationPtr; -class WorkstationLmm; -typedef WorkstationLmm *WorkstationLmmPtr; - class WorkstationAction; typedef WorkstationAction *WorkstationActionPtr; -class WorkstationActionLmm; -typedef WorkstationActionLmm *WorkstationActionLmmPtr; - /********* * Tools * *********/ @@ -55,10 +49,13 @@ public: * 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(); @@ -102,22 +99,16 @@ public: 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() {}; }; diff --git a/src/surf/workstation_ptask_L07.cpp b/src/surf/workstation_ptask_L07.cpp index c93b29da9d..54d3dbe9d2 100644 --- a/src/surf/workstation_ptask_L07.cpp +++ b/src/surf/workstation_ptask_L07.cpp @@ -43,7 +43,7 @@ WorkstationL07Model::~WorkstationL07Model() { double WorkstationL07Model::shareResources(double /*now*/) { - WorkstationL07ActionLmmPtr action; + WorkstationL07ActionPtr action; ActionListPtr running_actions = getRunningActionSet(); double min = this->shareResourcesMaxMin(running_actions, @@ -52,7 +52,7 @@ double WorkstationL07Model::shareResources(double /*now*/) for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()) ; it != itend ; ++it) { - action = dynamic_cast(&*it); + action = dynamic_cast(&*it); if (action->m_latency > 0) { if (min < 0) { min = action->m_latency; @@ -74,14 +74,14 @@ double WorkstationL07Model::shareResources(double /*now*/) 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(&*it); + action = dynamic_cast(&*it); deltap = delta; if (action->m_latency > 0) { if (action->m_latency > deltap) { @@ -123,7 +123,7 @@ void WorkstationL07Model::updateActionsState(double /*now*/, double delta) i++))) { constraint_id = lmm_constraint_id(cnst); - if (static_cast(constraint_id)->getState() == SURF_RESOURCE_OFF) { + if (static_cast(constraint_id)->getState() == SURF_RESOURCE_OFF) { XBT_DEBUG("Action (%p) Failed!!", action); action->finish(); action->setState(SURF_ACTION_FAILED); @@ -142,7 +142,7 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb, *communication_amount, double rate) { - WorkstationL07ActionLmmPtr action; + WorkstationL07ActionPtr action; int i, j; unsigned int cpt; int nb_link = 0; @@ -190,7 +190,7 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb, 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 @@ -211,8 +211,8 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb, for (i = 0; i < workstation_nb; i++) lmm_expand(ptask_maxmin_system, - static_cast(dynamic_cast( - static_cast(workstation_list[i]))->p_cpu)->constraint(), + static_cast(dynamic_cast( + static_cast(workstation_list[i]))->p_cpu)->getConstraint(), action->getVariable(), computation_amount[i]); for (i = 0; i < workstation_nb; i++) { @@ -232,7 +232,7 @@ ActionPtr WorkstationL07Model::executeParallelTask(int workstation_nb, xbt_dynar_foreach(route, cpt, _link) { link = dynamic_cast(static_cast(_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]); } @@ -410,9 +410,7 @@ void WorkstationL07Model::addTraces() ************/ 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) { } @@ -443,8 +441,8 @@ CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props, double power_scale, double power_initial, tmgr_trace_t power_trace, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace) - : Resource(model, name, props) - , CpuLmm(lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale)) + : 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"); @@ -466,8 +464,7 @@ LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props, 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) @@ -480,22 +477,22 @@ LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props, p_latEvent = tmgr_history_add_trace(history, lat_trace, 0.0, 0, static_cast(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) { @@ -516,17 +513,17 @@ void LinkL07::updateState(tmgr_trace_event_t event_type, double value, double da 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)) @@ -582,11 +579,11 @@ ActionPtr WorkstationL07::execute(double size) ActionPtr WorkstationL07::sleep(double duration) { - WorkstationL07ActionLmmPtr action = NULL; + WorkstationL07ActionPtr action = NULL; XBT_IN("(%s,%g)", getName(), duration); - action = dynamic_cast(execute(1.0)); + action = dynamic_cast(execute(1.0)); action->m_maxDuration = duration; action->m_suspended = 2; lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0); @@ -607,20 +604,20 @@ double LinkL07::getLatency() 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; @@ -652,7 +649,7 @@ void WorkstationL07ActionLmm::updateBound() } } -int WorkstationL07ActionLmm::unref() +int WorkstationL07Action::unref() { m_refcount--; if (!m_refcount) { @@ -666,13 +663,13 @@ int WorkstationL07ActionLmm::unref() 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) { @@ -682,7 +679,7 @@ void WorkstationL07ActionLmm::suspend() XBT_OUT(); } -void WorkstationL07ActionLmm::resume() +void WorkstationL07Action::resume() { XBT_IN("(%p)", this); if (m_suspended != 2) { @@ -692,26 +689,26 @@ void WorkstationL07ActionLmm::resume() 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(); diff --git a/src/surf/workstation_ptask_L07.hpp b/src/surf/workstation_ptask_L07.hpp index 1c7cf5030d..0dcf31e43c 100644 --- a/src/surf/workstation_ptask_L07.hpp +++ b/src/surf/workstation_ptask_L07.hpp @@ -25,8 +25,8 @@ typedef CpuL07 *CpuL07Ptr; class LinkL07; typedef LinkL07 *LinkL07Ptr; -class WorkstationL07ActionLmm; -typedef WorkstationL07ActionLmm *WorkstationL07ActionLmmPtr; +class WorkstationL07Action; +typedef WorkstationL07Action *WorkstationL07ActionPtr; /********* * Tools * @@ -98,7 +98,7 @@ public: * 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(); @@ -113,7 +113,7 @@ public: double getConsumedEnergy(); }; -class CpuL07 : public CpuLmm { +class CpuL07 : public Cpu { public: s_surf_metric_t p_power; tmgr_trace_event_t p_stateEvent; @@ -141,7 +141,7 @@ public: 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, @@ -169,7 +169,7 @@ public: /********** * 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, @@ -179,9 +179,9 @@ class WorkstationL07ActionLmm : public WorkstationActionLmm { *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();