From 54e35ebda7e4ffacd769653b8ebb8ba93c7298bf Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Mon, 20 Jul 2015 10:31:24 +0200 Subject: [PATCH] Get ride of ???Ptr types in C++: make pointers explicit Making pointers explicit is not what we did in C so far, but what we did was a bad idea. It's easier to code when you know what is a pointer and what is not. Also: - Convert a bunch of C-typecast into static_cast - Kill some dead or dupplicated code --- include/simgrid/host.h | 7 +- .../java/org/simgrid/surf/surfJAVA_wrap.cxx | 2 +- src/bindings/java/surf.i | 2 +- src/bindings/java/surf_swig.cpp | 2 +- src/simgrid/host.cpp | 10 +- src/surf/cpu_cas01.cpp | 30 +++--- src/surf/cpu_cas01.hpp | 21 ++-- src/surf/cpu_interface.cpp | 43 ++++---- src/surf/cpu_interface.hpp | 38 +++---- src/surf/cpu_ti.cpp | 60 +++++------ src/surf/cpu_ti.hpp | 51 ++++----- src/surf/host_clm03.cpp | 32 +++--- src/surf/host_clm03.hpp | 17 ++- src/surf/host_interface.cpp | 60 +++++------ src/surf/host_interface.hpp | 59 +++++----- src/surf/host_ptask_L07.cpp | 90 ++++++++-------- src/surf/host_ptask_L07.hpp | 53 ++++----- src/surf/maxmin.cpp | 2 +- src/surf/network_cm02.cpp | 38 +++---- src/surf/network_cm02.hpp | 11 +- src/surf/network_constant.cpp | 18 ++-- src/surf/network_constant.hpp | 11 +- src/surf/network_ib.cpp | 6 +- src/surf/network_ib.hpp | 6 +- src/surf/network_interface.cpp | 16 +-- src/surf/network_interface.hpp | 25 ++--- src/surf/network_ns3.cpp | 20 ++-- src/surf/network_ns3.hpp | 15 ++- src/surf/network_smpi.cpp | 6 +- src/surf/network_smpi.hpp | 5 +- src/surf/plugins/energy.cpp | 34 +++--- src/surf/plugins/energy.hpp | 7 +- src/surf/storage_interface.cpp | 26 ++--- src/surf/storage_interface.hpp | 41 ++++--- src/surf/storage_n11.cpp | 46 ++++---- src/surf/storage_n11.hpp | 28 ++--- src/surf/surf_c_bindings.cpp | 52 ++++----- src/surf/surf_interface.cpp | 34 +++--- src/surf/surf_interface.hpp | 29 ++--- src/surf/surf_routing.cpp | 102 +++++++++--------- src/surf/surf_routing.hpp | 47 ++++---- src/surf/surf_routing_cluster.cpp | 20 ++-- src/surf/surf_routing_cluster.hpp | 11 +- src/surf/surf_routing_cluster_fat_tree.cpp | 4 +- src/surf/surf_routing_cluster_fat_tree.hpp | 2 +- src/surf/surf_routing_cluster_torus.cpp | 2 +- src/surf/surf_routing_cluster_torus.hpp | 6 +- src/surf/surf_routing_dijkstra.cpp | 22 ++-- src/surf/surf_routing_dijkstra.hpp | 3 +- src/surf/surf_routing_floyd.cpp | 14 +-- src/surf/surf_routing_floyd.hpp | 9 +- src/surf/surf_routing_full.cpp | 14 +-- src/surf/surf_routing_full.hpp | 9 +- src/surf/surf_routing_generic.cpp | 78 +++++++------- src/surf/surf_routing_generic.hpp | 17 ++- src/surf/surf_routing_none.cpp | 12 +-- src/surf/surf_routing_none.hpp | 8 +- src/surf/surf_routing_private.hpp | 6 +- src/surf/surf_routing_vivaldi.cpp | 4 +- src/surf/surf_routing_vivaldi.hpp | 9 +- src/surf/vm_hl13.cpp | 50 ++++----- src/surf/vm_hl13.hpp | 17 ++- src/surf/vm_interface.cpp | 12 +-- src/surf/vm_interface.hpp | 26 ++--- 64 files changed, 722 insertions(+), 835 deletions(-) diff --git a/include/simgrid/host.h b/include/simgrid/host.h index 2a7af9a36b..fd0c576217 100644 --- a/include/simgrid/host.h +++ b/include/simgrid/host.h @@ -47,15 +47,14 @@ XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host); // ========== SURF CPU ============ DEFINE_EXTERNAL_CLASS(Cpu); typedef Cpu *surf_cpu_t; -typedef Cpu *CpuPtr; XBT_PUBLIC(surf_cpu_t) sg_host_surfcpu(sg_host_t host); XBT_PUBLIC(void) sg_host_surfcpu_set(sg_host_t host, surf_cpu_t cpu); XBT_PUBLIC(void) sg_host_surfcpu_destroy(sg_host_t host); // ========== RoutingEdge ============ -typedef struct RoutingEdge *RoutingEdgePtr; -XBT_PUBLIC(RoutingEdgePtr) sg_host_edge(sg_host_t host); -XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, RoutingEdgePtr edge); +DEFINE_EXTERNAL_CLASS(RoutingEdge); +XBT_PUBLIC(RoutingEdge*) sg_host_edge(sg_host_t host); +XBT_PUBLIC(void) sg_host_edge_set(sg_host_t host, RoutingEdge* edge); XBT_PUBLIC(void) sg_host_edge_destroy(sg_host_t host, int do_callback); diff --git a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx index be2e89b0e0..4c0dfa42d5 100644 --- a/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx +++ b/src/bindings/java/org/simgrid/surf/surfJAVA_wrap.cxx @@ -2226,7 +2226,7 @@ SWIGEXPORT jlongArray JNICALL Java_org_simgrid_surf_SurfJNI_ActionList_1getArray jlong *elts = jenv->GetLongArrayElements(jresult, NULL); l = 0; for(ActionList::iterator it(result->begin()), itend(result->end()); it != itend ; ++it) { - elts[l++] = (jlong)static_cast(&*it); + elts[l++] = (jlong)static_cast(&*it); } jenv->ReleaseLongArrayElements(jresult, elts, 0); } diff --git a/src/bindings/java/surf.i b/src/bindings/java/surf.i index a9e121ea85..68fc94dd73 100644 --- a/src/bindings/java/surf.i +++ b/src/bindings/java/surf.i @@ -121,7 +121,7 @@ JAVA_ARRAYSOFCLASSES(Action); jlong *elts = jenv->GetLongArrayElements($result, NULL); l = 0; for(ActionList::iterator it($1->begin()), itend($1->end()); it != itend ; ++it) { - elts[l++] = (jlong)static_cast(&*it); + elts[l++] = (jlong)static_cast(&*it); } jenv->ReleaseLongArrayElements($result, elts, 0); } diff --git a/src/bindings/java/surf_swig.cpp b/src/bindings/java/surf_swig.cpp index b3066cd363..b7f62f851a 100644 --- a/src/bindings/java/surf_swig.cpp +++ b/src/bindings/java/surf_swig.cpp @@ -43,7 +43,7 @@ LinkDynar getRoute(char *srcName, char *dstName) { RoutingEdge *dst = sg_host_edge(sg_host_by_name(dstName)); xbt_assert(src,"Cannot get the route from a NULL source"); xbt_assert(dst,"Cannot get the route to a NULL destination"); - xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); + xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdge*), NULL); routing_platf->getRouteAndLatency(src, dst, &route, NULL); return route; } diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index af11f632bf..63655a9a9f 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -52,10 +52,10 @@ int SURF_CPU_LEVEL; #include "surf/surf_routing.hpp" static XBT_INLINE void surf_cpu_free(void *r) { - delete static_cast(r); + delete static_cast(r); } static XBT_INLINE void routing_asr_host_free(void *p) { - delete static_cast(p); + delete static_cast(p); } @@ -111,10 +111,10 @@ void sg_host_surfcpu_destroy(sg_host_t host) { xbt_lib_unset(host_lib,host->key,SURF_CPU_LEVEL,1); } // ========== RoutingEdge ============ -RoutingEdgePtr sg_host_edge(sg_host_t host) { - return (RoutingEdgePtr) xbt_lib_get_level(host, ROUTING_HOST_LEVEL); +RoutingEdge *sg_host_edge(sg_host_t host) { + return (RoutingEdge*) xbt_lib_get_level(host, ROUTING_HOST_LEVEL); } -void sg_host_edge_set(sg_host_t host, RoutingEdgePtr edge) { +void sg_host_edge_set(sg_host_t host, RoutingEdge *edge) { xbt_lib_set(host_lib, host->key, ROUTING_HOST_LEVEL, edge); } void sg_host_edge_destroy(sg_host_t host, int do_callback) { diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 564d49bc63..617e2da989 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -33,8 +33,8 @@ void surf_cpu_model_init_Cas01() sg_platf_host_add_cb(cpu_parse_init); sg_platf_postparse_add_cb(cpu_add_traces); - ModelPtr model_pm = surf_cpu_model_pm; - ModelPtr model_vm = surf_cpu_model_vm; + Model *model_pm = surf_cpu_model_pm; + Model *model_vm = surf_cpu_model_vm; xbt_dynar_push(model_list, &model_pm); xbt_dynar_push(model_list, &model_vm); } @@ -97,14 +97,14 @@ CpuCas01Model::~CpuCas01Model() delete p_cpuRunningActionSetThatDoesNotNeedBeingChecked; } -CpuPtr CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak, +Cpu *CpuCas01Model::createCpu(const char *name, xbt_dynar_t power_peak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace, xbt_dict_t cpu_properties) { - CpuPtr cpu = NULL; + Cpu *cpu = NULL; sg_host_t host = sg_host_by_name(name); xbt_assert(!sg_host_surfcpu(host), "Host '%s' declared several times in the platform file", @@ -137,7 +137,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); - CpuCas01Ptr host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuCas01 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -147,7 +147,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); - CpuCas01Ptr host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuCas01 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -159,7 +159,7 @@ void CpuCas01Model::addTraces() /************ * Resource * ************/ -CpuCas01::CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak, +CpuCas01::CpuCas01(CpuCas01Model *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) @@ -228,7 +228,7 @@ void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double d m_powerPeak); while ((var = lmm_get_var_from_cnst (getModel()->getMaxminSystem(), getConstraint(), &elem))) { - CpuCas01ActionPtr action = static_cast(lmm_variable_id(var)); + CpuCas01Action *action = static_cast(lmm_variable_id(var)); lmm_update_variable_bound(getModel()->getMaxminSystem(), action->getVariable(), @@ -250,7 +250,7 @@ void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double d setState(SURF_RESOURCE_OFF); while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) { - ActionPtr action = static_cast(lmm_variable_id(var)); + Action *action = static_cast(lmm_variable_id(var)); if (action->getState() == SURF_ACTION_RUNNING || action->getState() == SURF_ACTION_READY || @@ -270,24 +270,24 @@ void CpuCas01::updateState(tmgr_trace_event_t event_type, double value, double d return; } -CpuActionPtr CpuCas01::execute(double size) +CpuAction *CpuCas01::execute(double size) { XBT_IN("(%s,%g)", getName(), size); - CpuCas01ActionPtr action = new CpuCas01Action(getModel(), size, getState() != SURF_RESOURCE_ON, + CpuCas01Action *action = new CpuCas01Action(getModel(), size, getState() != SURF_RESOURCE_ON, m_powerScale * m_powerPeak, getConstraint()); XBT_OUT(); return action; } -CpuActionPtr CpuCas01::sleep(double duration) +CpuAction *CpuCas01::sleep(double duration) { if (duration > 0) duration = MAX(duration, sg_surf_precision); XBT_IN("(%s,%g)", getName(), duration); - CpuCas01ActionPtr action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON, + CpuCas01Action *action = new CpuCas01Action(getModel(), 1.0, getState() != SURF_RESOURCE_ON, m_powerScale * m_powerPeak, getConstraint()); @@ -298,7 +298,7 @@ CpuActionPtr CpuCas01::sleep(double duration) /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action)); - action->p_stateSet = static_cast(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; + action->p_stateSet = static_cast(getModel())->p_cpuRunningActionSetThatDoesNotNeedBeingChecked; action->getStateSet()->push_back(*action); } @@ -353,7 +353,7 @@ int CpuCas01::getPstate() * Action * **********/ -CpuCas01Action::CpuCas01Action(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint) +CpuCas01Action::CpuCas01Action(Model *model, double cost, bool failed, double power, lmm_constraint_t constraint) : CpuAction(model, cost, failed, lmm_variable_new(model->getMaxminSystem(), this, 1.0, power, 1)) diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index b40cd044fd..a763abf890 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -10,13 +10,8 @@ * Classes * ***********/ class CpuCas01Model; -typedef CpuCas01Model *CpuCas01ModelPtr; - class CpuCas01; -typedef CpuCas01 *CpuCas01Ptr; - class CpuCas01Action; -typedef CpuCas01Action *CpuCas01ActionPtr; /********* * Model * @@ -29,7 +24,7 @@ public: double (CpuCas01Model::*shareResources)(double now); void (CpuCas01Model::*updateActionsState)(double now, double delta); - CpuPtr createCpu(const char *name, xbt_dynar_t power_peak, int pstate, + Cpu *createCpu(const char *name, xbt_dynar_t power_peak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, @@ -37,7 +32,7 @@ public: xbt_dict_t cpu_properties); double shareResourcesFull(double now); void addTraces(); - ActionListPtr p_cpuRunningActionSetThatDoesNotNeedBeingChecked; + ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked; }; /************ @@ -46,14 +41,14 @@ public: class CpuCas01 : public Cpu { public: - CpuCas01(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak, + CpuCas01(CpuCas01Model *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) ; ~CpuCas01(); void updateState(tmgr_trace_event_t event_type, double value, double date); - CpuActionPtr execute(double size); - CpuActionPtr sleep(double duration); + CpuAction *execute(double size); + CpuAction *sleep(double duration); double getCurrentPowerPeak(); double getPowerPeakAt(int pstate_index); @@ -78,10 +73,10 @@ private: * Action * **********/ class CpuCas01Action: public CpuAction { - friend CpuActionPtr CpuCas01::execute(double size); - friend CpuActionPtr CpuCas01::sleep(double duration); + friend CpuAction *CpuCas01::execute(double size); + friend CpuAction *CpuCas01::sleep(double duration); public: - CpuCas01Action(ModelPtr model, double cost, bool failed, double power, + CpuCas01Action(Model *model, double cost, bool failed, double power, lmm_constraint_t constraint); ~CpuCas01Action() {}; diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 906e07e783..23929b021b 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -13,22 +13,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf, int autoload_surf_cpu_model = 1; void_f_void_t surf_cpu_model_init_preparse = NULL; -CpuModelPtr surf_cpu_model_pm; -CpuModelPtr surf_cpu_model_vm; +CpuModel *surf_cpu_model_pm; +CpuModel *surf_cpu_model_vm; /************* * Callbacks * *************/ -CpuPtr getActionCpu(CpuActionPtr action) { - return static_cast(lmm_constraint_id(lmm_get_cnst_from_var +Cpu *getActionCpu(CpuAction *action) { + return static_cast(lmm_constraint_id(lmm_get_cnst_from_var (action->getModel()->getMaxminSystem(), action->getVariable(), 0))); } -surf_callback(void, CpuPtr) cpuCreatedCallbacks; -surf_callback(void, CpuPtr) cpuDestructedCallbacks; -surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; -surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; +surf_callback(void, Cpu*) cpuCreatedCallbacks; +surf_callback(void, Cpu*) cpuDestructedCallbacks; +surf_callback(void, Cpu*, e_surf_resource_state_t, e_surf_resource_state_t) cpuStateChangedCallbacks; +surf_callback(void, CpuAction*, e_surf_action_state_t, e_surf_action_state_t) cpuActionStateChangedCallbacks; void cpu_parse_init(sg_platf_host_cbarg_t host){ surf_cpu_model_pm->createCpu( @@ -52,13 +52,13 @@ void cpu_add_traces(){ *********/ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) { - CpuActionPtr action; + CpuAction *action; while ((xbt_heap_size(getActionHeap()) > 0) && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) { - action = static_cast(xbt_heap_pop(getActionHeap())); + action = static_cast(xbt_heap_pop(getActionHeap())); XBT_CDEBUG(surf_kernel, "Something happened to action %p", action); if (TRACE_is_enabled()) { - CpuPtr cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0))); + Cpu *cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0))); TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(), lmm_variable_getvalue(action->getVariable()), action->getLastUpdate(), @@ -77,10 +77,10 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) //defining the last timestamp that we can safely dump to trace file //without losing the event ascending order (considering all CPU's) double smaller = -1; - ActionListPtr actionSet = getRunningActionSet(); + ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { - action = static_cast(&*it); + action = static_cast(&*it); if (smaller < 0) { smaller = action->getLastUpdate(); continue; @@ -98,16 +98,15 @@ void CpuModel::updateActionsStateLazy(double now, double /*delta*/) void CpuModel::updateActionsStateFull(double now, double delta) { - CpuActionPtr action = NULL; - ActionListPtr running_actions = getRunningActionSet(); + CpuAction *action = NULL; + ActionList *running_actions = getRunningActionSet(); for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + action = static_cast(&*it); if (TRACE_is_enabled()) { - CpuPtr x = (CpuPtr) lmm_constraint_id(lmm_get_cnst_from_var - (getMaxminSystem(), action->getVariable(), 0)); + Cpu *x = static_cast (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) ); TRACE_surf_host_set_utilization(x->getName(), action->getCategory(), @@ -146,7 +145,7 @@ Cpu::Cpu(){ surf_callback_emit(cpuCreatedCallbacks, this); } -Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *model, const char *name, xbt_dict_t props, int core, double powerPeak, double powerScale) : Resource(model, name, props) , m_core(core) @@ -158,7 +157,7 @@ Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props, surf_callback_emit(cpuCreatedCallbacks, this); } -Cpu::Cpu(ModelPtr model, const char *name, xbt_dict_t props, +Cpu::Cpu(Model *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) @@ -246,7 +245,7 @@ void CpuAction::updateRemainingLazy(double now) double_update(&(m_remains), m_lastValue * delta, sg_maxmin_precision*sg_surf_precision); if (TRACE_is_enabled()) { - CpuPtr cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); + Cpu *cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate); } XBT_CDEBUG(surf_kernel, "Updating action(%p): remains is now %f", this, m_remains); @@ -276,7 +275,7 @@ void CpuAction::updateRemainingLazy(double now) * action object does not have the information about the location where the * action is being executed. */ -void CpuAction::setAffinity(CpuPtr cpu, unsigned long mask) +void CpuAction::setAffinity(Cpu *cpu, unsigned long mask) { lmm_variable_t var_obj = getVariable(); XBT_IN("(%p,%lx)", this, mask); diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 045e6fe567..6375ce014c 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -14,44 +14,38 @@ * Classes * ***********/ class CpuModel; -typedef CpuModel *CpuModelPtr; - class Cpu; - class CpuAction; -typedef CpuAction *CpuActionPtr; - class CpuPlugin; -typedef CpuPlugin *CpuPluginPtr; /************* * Callbacks * *************/ -XBT_PUBLIC(CpuPtr) getActionCpu(CpuActionPtr action); +XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action); /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Cpu creation * * @details Callback functions have the following signature: `void(CpuPtr)` */ -XBT_PUBLIC_DATA( surf_callback(void, CpuPtr)) cpuCreatedCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, Cpu*)) cpuCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Cpu destruction * * @details Callback functions have the following signature: `void(CpuPtr)` */ -XBT_PUBLIC_DATA( surf_callback(void, CpuPtr)) cpuDestructedCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, Cpu*)) cpuDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Cpu State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` + * @details Callback functions have the following signature: `void(CpuAction *action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -XBT_PUBLIC_DATA( surf_callback(void, CpuPtr, e_surf_resource_state_t, e_surf_resource_state_t)) cpuStateChangedCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, Cpu*, e_surf_resource_state_t, e_surf_resource_state_t)) cpuStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after CpuAction State changed * - * @details Callback functions have the following signature: `void(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` + * @details Callback functions have the following signature: `void(CpuAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -XBT_PUBLIC_DATA( surf_callback(void, CpuActionPtr, e_surf_action_state_t, e_surf_action_state_t)) cpuActionStateChangedCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, CpuAction*, e_surf_action_state_t, e_surf_action_state_t)) cpuActionStateChangedCallbacks; XBT_PUBLIC(void) cpu_parse_init(sg_platf_host_cbarg_t host); @@ -87,7 +81,7 @@ public: * @param state_trace [TODO] * @param cpu_properties Dictionary of properties associated to this Cpu */ - virtual CpuPtr createCpu(const char *name, xbt_dynar_t power_peak, + virtual Cpu *createCpu(const char *name, xbt_dynar_t power_peak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, @@ -124,7 +118,7 @@ public: * @param powerPeak The power peak of this Cpu * @param powerScale The power scale of this Cpu */ - Cpu(ModelPtr model, const char *name, xbt_dict_t props, + Cpu(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, int core, double powerPeak, double powerScale); /** @@ -137,7 +131,7 @@ public: * @param powerPeak The power peak of this Cpu in [TODO] * @param powerScale The power scale of this Cpu in [TODO] */ - Cpu(ModelPtr model, const char *name, xbt_dict_t props, + Cpu(Model *model, const char *name, xbt_dict_t props, int core, double powerPeak, double powerScale); /** @@ -151,7 +145,7 @@ public: * @param size The value of the processing amount (in flop) needed to process * @return The CpuAction corresponding to the processing */ - virtual CpuActionPtr execute(double size)=0; + virtual CpuAction *execute(double size)=0; /** * @brief Make a process sleep for duration (in seconds) @@ -159,7 +153,7 @@ public: * @param duration The number of seconds to sleep * @return The CpuAction corresponding to the sleeping */ - virtual CpuActionPtr sleep(double duration)=0; + virtual CpuAction *sleep(double duration)=0; /** * @brief Get the number of cores of the current Cpu @@ -222,7 +216,7 @@ public: * @details A CpuAction represent the execution of code on a Cpu */ XBT_PUBLIC_CLASS CpuAction : public Action { -friend XBT_PUBLIC(CpuPtr) getActionCpu(CpuActionPtr action); +friend XBT_PUBLIC(Cpu*) getActionCpu(CpuAction *action); public: /** * @brief CpuAction constructor @@ -231,7 +225,7 @@ public: * @param cost [TODO] * @param failed [TODO] */ - CpuAction(ModelPtr model, double cost, bool failed) + CpuAction(Model *model, double cost, bool failed) : Action(model, cost, failed) {} //FIXME:REMOVE /** @@ -242,7 +236,7 @@ public: * @param failed [TODO] * @param var The lmm variable associated to this CpuAction if it is part of a LMM component */ - CpuAction(ModelPtr model, double cost, bool failed, lmm_variable_t var) + CpuAction(Model *model, double cost, bool failed, lmm_variable_t var) : Action(model, cost, failed, var) {} /** @@ -252,7 +246,7 @@ public: * @param cpu [TODO] * @param mask [TODO] */ - virtual void setAffinity(CpuPtr cpu, unsigned long mask); + virtual void setAffinity(Cpu *cpu, unsigned long mask); void setState(e_surf_action_state_t state); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 5d3cbf3bc1..160fa74c85 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -395,11 +395,11 @@ void surf_cpu_model_init_ti() xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen."); surf_cpu_model_pm = new CpuTiModel(); - surf_cpu_model_vm = new CpuTiModel(); + surf_cpu_model_vm = new CpuTiModel(); cpu_ti_define_callbacks(); - ModelPtr model_pm = static_cast(surf_cpu_model_pm); - ModelPtr model_vm = static_cast(surf_cpu_model_vm); + Model *model_pm = static_cast(surf_cpu_model_pm); + Model *model_vm = static_cast(surf_cpu_model_vm); xbt_dynar_push(model_list, &model_pm); xbt_dynar_push(model_list, &model_vm); } @@ -423,7 +423,7 @@ CpuTiModel::~CpuTiModel() xbt_heap_free(p_tiActionHeap); } -CpuPtr CpuTiModel::createCpu(const char *name, +Cpu *CpuTiModel::createCpu(const char *name, xbt_dynar_t powerPeak, int pstate, double powerScale, @@ -440,7 +440,7 @@ CpuPtr CpuTiModel::createCpu(const char *name, name); xbt_assert(xbt_dynar_getfirst_as(powerPeak, double) > 0.0, "Power has to be >0.0. Did you forget to specify the mandatory power attribute?"); - CpuTiPtr cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace, + CpuTi *cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace, core, stateInitial, stateTrace, cpuProperties); sg_host_surfcpu_set(host, cpu); return cpu; @@ -453,7 +453,7 @@ double CpuTiModel::shareResources(double now) /* iterates over modified cpus to update share resources */ for(CpuTiList::iterator it(p_modifiedCpu->begin()), itend(p_modifiedCpu->end()) ; it != itend ;) { - CpuTiPtr ti = &*it; + CpuTi *ti = &*it; ++it; ti->updateActionsFinishTime(now); } @@ -471,7 +471,7 @@ void CpuTiModel::updateActionsState(double now, double /*delta*/) { while ((xbt_heap_size(p_tiActionHeap) > 0) && (xbt_heap_maxkey(p_tiActionHeap) <= now)) { - CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(p_tiActionHeap); + CpuTiAction *action = (CpuTiAction*) xbt_heap_pop(p_tiActionHeap); XBT_DEBUG("Action %p: finish", action); action->finish(); /* set the remains to 0 due to precision problems when updating the remaining amount */ @@ -496,7 +496,7 @@ void CpuTiModel::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); - CpuTiPtr cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuTi *cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(cpu, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -512,7 +512,7 @@ void CpuTiModel::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); - CpuTiPtr cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuTi *cpu = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(cpu, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -542,7 +542,7 @@ void CpuTiModel::addTraces() /************ * Resource * ************/ -CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak, +CpuTi::CpuTi(CpuTiModel *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) @@ -590,11 +590,11 @@ CpuTi::~CpuTi(){ void CpuTi::updateState(tmgr_trace_event_t event_type, double value, double date) { - CpuTiActionPtr action; + CpuTiAction *action; if (event_type == p_powerEvent) { tmgr_trace_t power_trace; - CpuTiTgmrPtr trace; + CpuTiTgmr *trace; s_tmgr_event_t val; XBT_DEBUG("Finish trace date: %f value %f date %f", surf_get_clock(), @@ -637,8 +637,8 @@ void CpuTi::updateState(tmgr_trace_event_t event_type, action->setFinishTime(date); action->setState(SURF_ACTION_FAILED); if (action->m_indexHeap >= 0) { - CpuTiActionPtr heap_act = (CpuTiActionPtr) - xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, action->m_indexHeap); + CpuTiAction *heap_act = (CpuTiAction*) + xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, action->m_indexHeap); if (heap_act != action) DIE_IMPOSSIBLE; } @@ -657,7 +657,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type, void CpuTi::updateActionsFinishTime(double now) { - CpuTiActionPtr action; + CpuTiAction *action; double sum_priority = 0.0, total_area, min_finish = -1; /* update remaning amount of actions */ @@ -716,13 +716,13 @@ updateRemainingAmount(now); /* add in action heap */ XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap); if (action->m_indexHeap >= 0) { - CpuTiActionPtr heap_act = (CpuTiActionPtr) - xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, action->m_indexHeap); + CpuTiAction *heap_act = (CpuTiAction*) + xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, action->m_indexHeap); if (heap_act != action) DIE_IMPOSSIBLE; } if (min_finish != NO_MAX_DURATION) - xbt_heap_push(static_cast(getModel())->p_tiActionHeap, action, min_finish); + xbt_heap_push(static_cast(getModel())->p_tiActionHeap, action, min_finish); XBT_DEBUG ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f", @@ -753,7 +753,7 @@ double CpuTi::getAvailableSpeed() void CpuTi::updateRemainingAmount(double now) { double area_total; - CpuTiActionPtr action; + CpuTiAction *action; /* already updated */ if (m_lastUpdate >= now) @@ -797,10 +797,10 @@ void CpuTi::updateRemainingAmount(double now) m_lastUpdate = now; } -CpuActionPtr CpuTi::execute(double size) +CpuAction *CpuTi::execute(double size) { XBT_IN("(%s,%g)", getName(), size); - CpuTiActionPtr action = new CpuTiAction(static_cast(getModel()), size, getState() != SURF_RESOURCE_ON, this); + CpuTiAction *action = new CpuTiAction(static_cast(getModel()), size, getState() != SURF_RESOURCE_ON, this); p_actionSet->push_back(*action); @@ -809,13 +809,13 @@ CpuActionPtr CpuTi::execute(double size) } -CpuActionPtr CpuTi::sleep(double duration) +CpuAction *CpuTi::sleep(double duration) { if (duration > 0) duration = MAX(duration, sg_surf_precision); XBT_IN("(%s,%g)", getName(), duration); - CpuTiActionPtr action = new CpuTiAction(static_cast(getModel()), 1.0, getState() != SURF_RESOURCE_ON, this); + CpuTiAction *action = new CpuTiAction(static_cast(getModel()), 1.0, getState() != SURF_RESOURCE_ON, this); action->m_maxDuration = duration; action->m_suspended = 2; @@ -823,7 +823,7 @@ CpuActionPtr CpuTi::sleep(double duration) /* Move to the *end* of the corresponding action set. This convention is used to speed up update_resource_state */ action->getStateSet()->erase(action->getStateSet()->iterator_to(*action)); - action->p_stateSet = static_cast(getModel())->p_runningActionSetThatDoesNotNeedBeingChecked; + action->p_stateSet = static_cast(getModel())->p_runningActionSetThatDoesNotNeedBeingChecked; action->getStateSet()->push_back(*action); } @@ -834,7 +834,7 @@ CpuActionPtr CpuTi::sleep(double duration) } void CpuTi::modified(bool modified){ - CpuTiListPtr modifiedCpu = static_cast(getModel())->p_modifiedCpu; + CpuTiList *modifiedCpu = static_cast(getModel())->p_modifiedCpu; if (modified) { if (!is_linked()) { modifiedCpu->push_back(*this); @@ -852,11 +852,11 @@ void CpuTi::modified(bool modified){ static void cpu_ti_action_update_index_heap(void *action, int i) { -((CpuTiActionPtr)action)->updateIndexHeap(i); +((CpuTiAction*)action)->updateIndexHeap(i); } -CpuTiAction::CpuTiAction(CpuTiModelPtr model_, double cost, bool failed, - CpuTiPtr cpu) +CpuTiAction::CpuTiAction(CpuTiModel *model_, double cost, bool failed, + CpuTi *cpu) : CpuAction(model_, cost, failed) { m_suspended = 0; /* Should be useless because of the @@ -887,7 +887,7 @@ int CpuTiAction::unref() if (actionTiHook::is_linked()) p_cpu->p_actionSet->erase(p_cpu->p_actionSet->iterator_to(*this)); /* remove from heap */ - xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, this->m_indexHeap); + xbt_heap_remove(static_cast(getModel())->p_tiActionHeap, this->m_indexHeap); p_cpu->modified(true); delete this; return 1; @@ -950,7 +950,7 @@ void CpuTiAction::setMaxDuration(double duration) /* add in action heap */ if (m_indexHeap >= 0) { - CpuTiActionPtr heap_act = (CpuTiActionPtr) + CpuTiAction *heap_act = (CpuTiAction*) xbt_heap_remove(getModel()->getActionHeap(), m_indexHeap); if (heap_act != this) DIE_IMPOSSIBLE; diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 80679ad6f6..022e2ce62a 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -15,27 +15,16 @@ * Classes * ***********/ class CpuTiTrace; -typedef CpuTiTrace *CpuTiTracePtr; - class CpuTiTgmr; -typedef CpuTiTgmr *CpuTiTgmrPtr; - class CpuTiModel; -typedef CpuTiModel *CpuTiModelPtr; - class CpuTi; -typedef CpuTi *CpuTiPtr; - class CpuTiAction; -typedef CpuTiAction *CpuTiActionPtr; typedef boost::intrusive::list CpuTiList; -typedef CpuTiList* CpuTiListPtr; typedef boost::intrusive::list_base_hook<> cpuTiHook; struct tiTag; typedef boost::intrusive::list > > > ActionTiList; -typedef ActionTiList* ActionTiListPtr; typedef boost::intrusive::list_base_hook > actionTiHook; /********* @@ -82,7 +71,7 @@ public: double m_lastTime; /*< Integral interval last point (discret time) */ double m_total; /*< Integral total between 0 and last_pointn */ - CpuTiTracePtr p_trace; + CpuTiTrace *p_trace; tmgr_trace_t p_powerTrace; }; @@ -93,7 +82,7 @@ class CpuTiModel : public CpuModel { public: CpuTiModel(); ~CpuTiModel(); - CpuPtr createCpu(const char *name, xbt_dynar_t powerPeak, + Cpu *createCpu(const char *name, xbt_dynar_t powerPeak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, @@ -103,17 +92,17 @@ public: void updateActionsState(double now, double delta); void addTraces(); - ActionListPtr p_runningActionSetThatDoesNotNeedBeingChecked; - CpuTiListPtr p_modifiedCpu; + ActionList *p_runningActionSetThatDoesNotNeedBeingChecked; + CpuTiList *p_modifiedCpu; xbt_heap_t p_tiActionHeap; protected: - void NotifyResourceTurnedOn(ResourcePtr){}; - void NotifyResourceTurnedOff(ResourcePtr){}; + void NotifyResourceTurnedOn(Resource*){}; + void NotifyResourceTurnedOff(Resource*){}; - void NotifyActionCancel(ActionPtr){}; - void NotifyActionResume(ActionPtr){}; - void NotifyActionSuspend(ActionPtr){}; + void NotifyActionCancel(Action*){}; + void NotifyActionResume(Action*){}; + void NotifyActionSuspend(Action*){}; }; /************ @@ -122,7 +111,7 @@ protected: class CpuTi : public cpuTiHook, public Cpu { public: CpuTi() {}; - CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak, + CpuTi(CpuTiModel *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) ; @@ -132,8 +121,8 @@ public: void updateActionsFinishTime(double now); bool isUsed(); void printCpuTiModel(); - CpuActionPtr execute(double size); - CpuActionPtr sleep(double duration); + CpuAction *execute(double size); + CpuAction *sleep(double duration); double getAvailableSpeed(); double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;}; @@ -143,10 +132,10 @@ public: int getPstate() { THROW_UNIMPLEMENTED;} void modified(bool modified); - CpuTiTgmrPtr p_availTrace; /*< Structure with data needed to integrate trace file */ + CpuTiTgmr *p_availTrace; /*< Structure with data needed to integrate trace file */ tmgr_trace_event_t p_stateEvent; /*< trace file with states events (ON or OFF) */ tmgr_trace_event_t p_powerEvent; /*< trace file with availability events */ - ActionTiListPtr p_actionSet; /*< set with all actions running on cpu */ + ActionTiList *p_actionSet; /*< set with all actions running on cpu */ double m_sumPriority; /*< the sum of actions' priority that are running on cpu */ double m_lastUpdate; /*< last update of actions' remaining amount done */ @@ -160,14 +149,14 @@ public: **********/ class CpuTiAction: public actionTiHook, public CpuAction { - friend CpuActionPtr CpuTi::execute(double size); - friend CpuActionPtr CpuTi::sleep(double duration); + friend CpuAction *CpuTi::execute(double size); + friend CpuAction *CpuTi::sleep(double duration); friend void CpuTi::updateActionsFinishTime(double now);//FIXME friend void CpuTi::updateRemainingAmount(double now);//FIXME public: - CpuTiAction(CpuTiModelPtr model, double cost, bool failed, - CpuTiPtr cpu); + CpuTiAction(CpuTiModel *model, double cost, bool failed, + CpuTi *cpu); void setState(e_surf_action_state_t state); int unref(); @@ -180,9 +169,9 @@ public: void setMaxDuration(double duration); void setPriority(double priority); double getRemains(); - void setAffinity(CpuPtr /*cpu*/, unsigned long /*mask*/) {}; + void setAffinity(Cpu */*cpu*/, unsigned long /*mask*/) {}; - CpuTiPtr p_cpu; + CpuTi *p_cpu; int m_indexHeap; int m_suspended; private: diff --git a/src/surf/host_clm03.cpp b/src/surf/host_clm03.cpp index 0a34da940d..345fd1a771 100644 --- a/src/surf/host_clm03.cpp +++ b/src/surf/host_clm03.cpp @@ -28,7 +28,7 @@ void surf_host_model_init_current_default(void) surf_network_model_init_LegrandVelho(); surf_host_model->p_cpuModel = surf_cpu_model_pm; - ModelPtr model = surf_host_model; + Model *model = surf_host_model; xbt_dynar_push(model_list, &model); xbt_dynar_push(model_list_invoke, &model); sg_platf_host_add_cb(host_parse_init); @@ -41,7 +41,7 @@ void surf_host_model_init_compound() xbt_assert(surf_network_model, "No network model defined yet!"); surf_host_model = new HostCLM03Model(); - ModelPtr model = surf_host_model; + Model *model = surf_host_model; xbt_dynar_push(model_list, &model); xbt_dynar_push(model_list_invoke, &model); sg_platf_host_add_cb(host_parse_init); @@ -55,9 +55,9 @@ HostCLM03Model::HostCLM03Model() HostCLM03Model::~HostCLM03Model() {} -HostPtr HostCLM03Model::createHost(const char *name){ +Host *HostCLM03Model::createHost(const char *name){ sg_host_t sg_host = sg_host_by_name(name); - HostPtr host = new HostCLM03(surf_host_model, name, NULL, + Host *host = new HostCLM03(surf_host_model, name, NULL, (xbt_dynar_t)xbt_lib_get_or_null(storage_lib, name, ROUTING_STORAGE_HOST_LEVEL), sg_host_edge(sg_host), sg_host_surfcpu(sg_host)); @@ -94,20 +94,20 @@ void HostCLM03Model::updateActionsState(double /*now*/, double /*delta*/){ return; } -ActionPtr HostCLM03Model::executeParallelTask(int host_nb, +Action *HostCLM03Model::executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, double rate){ #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0) - ActionPtr action =NULL; + Action *action =NULL; if ((host_nb == 1) && (cost_or_zero(bytes_amount, 0) == 0.0)){ - action = ((HostCLM03Ptr)host_list[0])->execute(flops_amount[0]); + action = static_cast(host_list[0])->execute(flops_amount[0]); } else if ((host_nb == 1) && (cost_or_zero(flops_amount, 0) == 0.0)) { - action = communicate((HostCLM03Ptr)host_list[0], - (HostCLM03Ptr)host_list[0],bytes_amount[0], rate); + action = communicate(static_cast(host_list[0]), + static_cast(host_list[0]),bytes_amount[0], rate); } else if ((host_nb == 2) && (cost_or_zero(flops_amount, 0) == 0.0) && (cost_or_zero(flops_amount, 1) == 0.0)) { @@ -121,17 +121,17 @@ ActionPtr HostCLM03Model::executeParallelTask(int host_nb, } } if (nb == 1){ - action = communicate((HostCLM03Ptr)host_list[0], - (HostCLM03Ptr)host_list[1],value, rate); + action = communicate(static_cast(host_list[0]), + static_cast(host_list[1]),value, rate); } } else THROW_UNIMPLEMENTED; /* This model does not implement parallel tasks */ #undef cost_or_zero - xbt_free((HostCLM03Ptr)host_list); + xbt_free(host_list); return action; } -ActionPtr HostCLM03Model::communicate(HostPtr src, HostPtr dst, double size, double rate){ +Action *HostCLM03Model::communicate(Host *src, Host *dst, double size, double rate){ return surf_network_model->communicate(src->p_netElm, dst->p_netElm, size, rate); } @@ -140,7 +140,7 @@ ActionPtr HostCLM03Model::communicate(HostPtr src, HostPtr dst, double size, dou /************ * Resource * ************/ -HostCLM03::HostCLM03(HostModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu) +HostCLM03::HostCLM03(HostModel *model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu) : Host(model, name, properties, storage, netElm, cpu) {} bool HostCLM03::isUsed(){ @@ -152,11 +152,11 @@ void HostCLM03::updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, THROW_IMPOSSIBLE; /* This model does not implement parallel tasks */ } -ActionPtr HostCLM03::execute(double size) { +Action *HostCLM03::execute(double size) { return p_cpu->execute(size); } -ActionPtr HostCLM03::sleep(double duration) { +Action *HostCLM03::sleep(double duration) { return p_cpu->sleep(duration); } diff --git a/src/surf/host_clm03.hpp b/src/surf/host_clm03.hpp index b362a72441..3a935eb0a9 100644 --- a/src/surf/host_clm03.hpp +++ b/src/surf/host_clm03.hpp @@ -17,13 +17,8 @@ ***********/ class HostCLM03Model; -typedef HostCLM03Model *HostCLM03ModelPtr; - class HostCLM03; -typedef HostCLM03 *HostCLM03Ptr; - class HostCLM03Action; -typedef HostCLM03Action *HostCLM03ActionPtr; /********* * Model * @@ -33,17 +28,17 @@ class HostCLM03Model : public HostModel { public: HostCLM03Model(); ~HostCLM03Model(); - HostPtr createHost(const char *name); + Host *createHost(const char *name); double shareResources(double now); void updateActionsState(double now, double delta); - ActionPtr executeParallelTask(int host_nb, + Action *executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, double rate); - ActionPtr communicate(HostPtr src, HostPtr dst, double size, double rate); + Action *communicate(Host *src, Host *dst, double size, double rate); }; /************ @@ -52,12 +47,12 @@ public: class HostCLM03 : public Host { public: - HostCLM03(HostModelPtr model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu); + HostCLM03(HostModel *model, const char* name, xbt_dict_t properties, xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu); void updateState(tmgr_trace_event_t event_type, double value, double date); - virtual ActionPtr execute(double size); - virtual ActionPtr sleep(double duration); + virtual Action *execute(double size); + virtual Action *sleep(double duration); e_surf_resource_state_t getState(); bool isUsed(); diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index 40ba2faf14..99ce613fc2 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -16,16 +16,16 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_host, surf, "Logging specific to the SURF host module"); -HostModelPtr surf_host_model = NULL; +HostModel *surf_host_model = NULL; /************* * Callbacks * *************/ -surf_callback(void, HostPtr) hostCreatedCallbacks; -surf_callback(void, HostPtr) hostDestructedCallbacks; -surf_callback(void, HostPtr, e_surf_resource_state_t, e_surf_resource_state_t) hostStateChangedCallbacks; -surf_callback(void, HostActionPtr, e_surf_action_state_t, e_surf_action_state_t) hostActionStateChangedCallbacks; +surf_callback(void, Host*) hostCreatedCallbacks; +surf_callback(void, Host*) hostDestructedCallbacks; +surf_callback(void, Host*, e_surf_resource_state_t, e_surf_resource_state_t) hostStateChangedCallbacks; +surf_callback(void, HostAction*, e_surf_action_state_t, e_surf_action_state_t) hostActionStateChangedCallbacks; void host_parse_init(sg_platf_host_cbarg_t host) { @@ -64,8 +64,8 @@ void HostModel::adjustWeightOfDummyCpuActions() VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) { - VMPtr ws_vm = &*iter; - CpuCas01Ptr cpu_cas01 = static_cast(ws_vm->p_cpu); + VM *ws_vm = &*iter; + CpuCas01 *cpu_cas01 = static_cast(ws_vm->p_cpu); xbt_assert(cpu_cas01, "cpu-less host"); int is_active = lmm_constraint_used(cpu_cas01->getModel()->getMaxminSystem(), cpu_cas01->getConstraint()); @@ -91,8 +91,8 @@ void HostModel::adjustWeightOfDummyCpuActions() /************ * Resource * ************/ -Host::Host(ModelPtr model, const char *name, xbt_dict_t props, - xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu) +Host::Host(Model *model, const char *name, xbt_dict_t props, + xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu) : Resource(model, name, props) , p_storage(storage), p_netElm(netElm), p_cpu(cpu) { @@ -100,8 +100,8 @@ Host::Host(ModelPtr model, const char *name, xbt_dict_t props, surf_callback_emit(hostCreatedCallbacks, this); } -Host::Host(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, - xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu) +Host::Host(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, + xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu) : Resource(model, name, props, constraint) , p_storage(storage), p_netElm(netElm), p_cpu(cpu) { @@ -161,9 +161,9 @@ xbt_dict_t Host::getProperties() return p_cpu->getProperties(); } -StoragePtr Host::findStorageOnMountList(const char* mount) +Storage *Host::findStorageOnMountList(const char* mount) { - StoragePtr st = NULL; + Storage *st = NULL; s_mount_t mnt; unsigned int cursor; @@ -172,7 +172,7 @@ StoragePtr Host::findStorageOnMountList(const char* mount) { XBT_DEBUG("See '%s'",mnt.name); if(!strcmp(mount,mnt.name)){ - st = static_cast(mnt.storage); + st = static_cast(mnt.storage); break; } } @@ -188,7 +188,7 @@ xbt_dict_t Host::getMountedStorageList() char *storage_name = NULL; xbt_dynar_foreach(p_storage,i,mnt){ - storage_name = (char *)static_cast(mnt.storage)->getName(); + storage_name = (char *)static_cast(mnt.storage)->getName(); xbt_dict_set(storage_list,mnt.name,storage_name,NULL); } return storage_list; @@ -202,7 +202,7 @@ xbt_dynar_t Host::getAttachedStorageList() xbt_dynar_t result = xbt_dynar_new(sizeof(void*), NULL); xbt_lib_foreach(storage_lib, cursor, key, data) { if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) { - StoragePtr storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); + Storage *storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); if(!strcmp((const char*)storage->p_attach,this->getName())){ xbt_dynar_push_as(result, void *, (void*)storage->getName()); } @@ -211,9 +211,9 @@ xbt_dynar_t Host::getAttachedStorageList() return result; } -ActionPtr Host::open(const char* fullpath) { +Action *Host::open(const char* fullpath) { - StoragePtr st = NULL; + Storage *st = NULL; s_mount_t mnt; unsigned int cursor; size_t longest_prefix_length = 0; @@ -232,7 +232,7 @@ ActionPtr Host::open(const char* fullpath) { if(!strcmp(file_mount_name,mnt.name) && strlen(mnt.name)>longest_prefix_length) {/* The current mount name is found in the full path and is bigger than the previous*/ longest_prefix_length = strlen(mnt.name); - st = static_cast(mnt.storage); + st = static_cast(mnt.storage); } free(file_mount_name); } @@ -249,26 +249,26 @@ ActionPtr Host::open(const char* fullpath) { xbt_die("Can't find mount point for '%s' on '%s'", fullpath, getName()); XBT_DEBUG("OPEN %s on disk '%s'",path, st->getName()); - ActionPtr action = st->open((const char*)mount_name, (const char*)path); + Action *action = st->open((const char*)mount_name, (const char*)path); free((char*)path); free((char*)mount_name); return action; } -ActionPtr Host::close(surf_file_t fd) { - StoragePtr st = findStorageOnMountList(fd->mount); +Action *Host::close(surf_file_t fd) { + Storage *st = findStorageOnMountList(fd->mount); XBT_DEBUG("CLOSE %s on disk '%s'",fd->name, st->getName()); return st->close(fd); } -ActionPtr Host::read(surf_file_t fd, sg_size_t size) { - StoragePtr st = findStorageOnMountList(fd->mount); +Action *Host::read(surf_file_t fd, sg_size_t size) { + Storage *st = findStorageOnMountList(fd->mount); XBT_DEBUG("READ %s on disk '%s'",fd->name, st->getName()); return st->read(fd, size); } -ActionPtr Host::write(surf_file_t fd, sg_size_t size) { - StoragePtr st = findStorageOnMountList(fd->mount); +Action *Host::write(surf_file_t fd, sg_size_t size) { + Storage *st = findStorageOnMountList(fd->mount); XBT_DEBUG("WRITE %s on disk '%s'",fd->name, st->getName()); return st->write(fd, size); } @@ -279,7 +279,7 @@ int Host::unlink(surf_file_t fd) { return -1; } else { - StoragePtr st = findStorageOnMountList(fd->mount); + Storage *st = findStorageOnMountList(fd->mount); /* Check if the file is on this storage */ if (!xbt_dict_get_or_null(st->p_content, fd->name)){ XBT_WARN("File %s is not on disk %s. Impossible to unlink", fd->name, @@ -306,7 +306,7 @@ sg_size_t Host::getSize(surf_file_t fd){ xbt_dynar_t Host::getInfo( surf_file_t fd) { - StoragePtr st = findStorageOnMountList(fd->mount); + Storage *st = findStorageOnMountList(fd->mount); sg_size_t *psize = xbt_new(sg_size_t, 1); *psize = fd->size; xbt_dynar_t info = xbt_dynar_new(sizeof(void*), NULL); @@ -372,14 +372,14 @@ int Host::fileMove(surf_file_t fd, const char* fullpath){ xbt_dynar_t Host::getVms() { - xbt_dynar_t dyn = xbt_dynar_new(sizeof(VMPtr), NULL); + xbt_dynar_t dyn = xbt_dynar_new(sizeof(VM*), NULL); /* iterate for all virtual machines */ for (VMModel::vm_list_t::iterator iter = VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) { - VMPtr ws_vm = &*iter; + VM *ws_vm = &*iter; if (this == ws_vm->p_subWs) xbt_dynar_push(dyn, &ws_vm); } diff --git a/src/surf/host_interface.hpp b/src/surf/host_interface.hpp index 4fcfa4313b..5752a64a53 100644 --- a/src/surf/host_interface.hpp +++ b/src/surf/host_interface.hpp @@ -17,13 +17,8 @@ ***********/ class HostModel; -typedef HostModel *HostModelPtr; - class Host; -typedef Host *HostPtr; - class HostAction; -typedef HostAction *HostActionPtr; /************* * Callbacks * @@ -33,30 +28,30 @@ typedef HostAction *HostActionPtr; * @brief Callbacks handler which emit the callbacks after Host creation * * @details Callback functions have the following signature: `void(HostPtr)` */ -XBT_PUBLIC_DATA(surf_callback(void, HostPtr)) hostCreatedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Host*)) hostCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Host destruction * * @details Callback functions have the following signature: `void(HostPtr)` */ -XBT_PUBLIC_DATA(surf_callback(void, HostPtr)) hostDestructedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Host*)) hostDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Host State changed * - * @details Callback functions have the following signature: `void(HostActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` + * @details Callback functions have the following signature: `void(HostAction *action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -XBT_PUBLIC_DATA(surf_callback(void, HostPtr, e_surf_resource_state_t, e_surf_resource_state_t)) hostStateChangedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Host*, e_surf_resource_state_t, e_surf_resource_state_t)) hostStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after HostAction State changed * - * @details Callback functions have the following signature: `void(HostActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` + * @details Callback functions have the following signature: `void(HostAction *action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -XBT_PUBLIC_DATA(surf_callback(void, HostActionPtr, e_surf_action_state_t, e_surf_action_state_t)) hostActionStateChangedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, HostAction*, e_surf_action_state_t, e_surf_action_state_t)) hostActionStateChangedCallbacks; /********* * Tools * *********/ -XBT_PUBLIC_DATA(HostModelPtr) surf_host_model; +XBT_PUBLIC_DATA(HostModel*) surf_host_model; XBT_PUBLIC(void) host_parse_init(sg_platf_host_cbarg_t host); XBT_PUBLIC(void) host_add_traces(); @@ -82,7 +77,7 @@ public: /** @brief HostModel destructor */ ~HostModel(); - virtual HostPtr createHost(const char *name)=0; + virtual Host *createHost(const char *name)=0; void addTraces(){DIE_IMPOSSIBLE;} /** @@ -102,7 +97,7 @@ public: * @param rate [description] * @return [description] */ - virtual ActionPtr executeParallelTask(int host_nb, + virtual Action *executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, @@ -118,9 +113,9 @@ public: * @param rate [description] * @return [description] */ - virtual ActionPtr communicate(HostPtr src, HostPtr dst, double size, double rate)=0; + virtual Action *communicate(Host *src, Host *dst, double size, double rate)=0; - CpuModelPtr p_cpuModel; + CpuModel *p_cpuModel; }; /************ @@ -142,8 +137,8 @@ public: * @param netElm The RoutingEdge associated to this Host * @param cpu The Cpu associated to this Host */ - Host(ModelPtr model, const char *name, xbt_dict_t props, - xbt_dynar_t storage, RoutingEdgePtr netElm, CpuPtr cpu); + Host(Model *model, const char *name, xbt_dict_t props, + xbt_dynar_t storage, RoutingEdge *netElm, Cpu *cpu); /** * @brief Host constructor @@ -156,9 +151,9 @@ public: * @param netElm The RoutingEdge associated to this Host * @param cpu The Cpu associated to this Host */ - Host(ModelPtr model, const char *name, xbt_dict_t props, - lmm_constraint_t constraint, xbt_dynar_t storage, RoutingEdgePtr netElm, - CpuPtr cpu); + Host(Model *model, const char *name, xbt_dict_t props, + lmm_constraint_t constraint, xbt_dynar_t storage, RoutingEdge *netElm, + Cpu *cpu); /** @brief Host destructor */ ~ Host(); @@ -179,7 +174,7 @@ public: * @return The CpuAction corresponding to the processing * @see Cpu */ - virtual ActionPtr execute(double flops_amount)=0; + virtual Action *execute(double flops_amount)=0; /** * @brief Make a process sleep for duration seconds @@ -188,7 +183,7 @@ public: * @return The CpuAction corresponding to the sleeping * @see Cpu */ - virtual ActionPtr sleep(double duration)=0; + virtual Action *sleep(double duration)=0; /** * @brief Get the number of cores of the associated Cpu @@ -235,7 +230,7 @@ public: * @param storage The mount point * @return The corresponding Storage */ - virtual StoragePtr findStorageOnMountList(const char* storage); + virtual Storage *findStorageOnMountList(const char* storage); /** * @brief Get the xbt_dict_t of mount_point: Storage @@ -258,7 +253,7 @@ public: * * @return The StorageAction corresponding to the opening */ - virtual ActionPtr open(const char* fullpath); + virtual Action *open(const char* fullpath); /** * @brief Close a file @@ -266,7 +261,7 @@ public: * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ - virtual ActionPtr close(surf_file_t fd); + virtual Action *close(surf_file_t fd); /** * @brief Unlink a file @@ -292,7 +287,7 @@ public: * @param size The size in bytes to read * @return The StorageAction corresponding to the reading */ - virtual ActionPtr read(surf_file_t fd, sg_size_t size); + virtual Action *read(surf_file_t fd, sg_size_t size); /** * @brief Write a file @@ -301,7 +296,7 @@ public: * @param size The size in bytes to write * @return The StorageAction corresponding to the writing */ - virtual ActionPtr write(surf_file_t fd, sg_size_t size); + virtual Action *write(surf_file_t fd, sg_size_t size); /** * @brief Get the informations of a file descriptor @@ -351,8 +346,8 @@ public: virtual int fileMove(surf_file_t fd, const char* fullpath); xbt_dynar_t p_storage; - RoutingEdgePtr p_netElm; - CpuPtr p_cpu; + RoutingEdge *p_netElm; + Cpu *p_cpu; /** * @brief Get the list of virtual machines on the current Host @@ -396,7 +391,7 @@ public: * @param cost The cost of this HostAction in [TODO] * @param failed [description] */ - HostAction(ModelPtr model, double cost, bool failed) + HostAction(Model *model, double cost, bool failed) : Action(model, cost, failed) {} /** @@ -407,7 +402,7 @@ public: * @param failed [description] * @param var The lmm variable associated to this StorageAction if it is part of a LMM component */ - HostAction(ModelPtr model, double cost, bool failed, lmm_variable_t var) + HostAction(Model *model, double cost, bool failed, lmm_variable_t var) : Action(model, cost, failed, var) {} void setState(e_surf_action_state_t state); diff --git a/src/surf/host_ptask_L07.cpp b/src/surf/host_ptask_L07.cpp index d0a6c5114b..ea1518c75e 100644 --- a/src/surf/host_ptask_L07.cpp +++ b/src/surf/host_ptask_L07.cpp @@ -41,7 +41,7 @@ void surf_host_model_init_ptask_L07(void) xbt_assert(!surf_network_model, "network model type already defined"); ptask_define_callbacks(); surf_host_model = new HostL07Model(); - ModelPtr model = surf_host_model; + Model *model = surf_host_model; xbt_dynar_push(model_list, &model); xbt_dynar_push(model_list_invoke, &model); } @@ -77,16 +77,16 @@ HostL07Model::~HostL07Model() { double HostL07Model::shareResources(double /*now*/) { - HostL07ActionPtr action; + HostL07Action *action; - ActionListPtr running_actions = getRunningActionSet(); + ActionList *running_actions = getRunningActionSet(); double min = this->shareResourcesMaxMin(running_actions, ptask_maxmin_system, bottleneck_solve); for(ActionList::iterator it(running_actions->begin()), itend(running_actions->end()) ; it != itend ; ++it) { - action = static_cast(&*it); + action = static_cast(&*it); if (action->m_latency > 0) { if (min < 0) { min = action->m_latency; @@ -108,14 +108,14 @@ double HostL07Model::shareResources(double /*now*/) void HostL07Model::updateActionsState(double /*now*/, double delta) { double deltap = 0.0; - HostL07ActionPtr action; + HostL07Action *action; - ActionListPtr actionSet = getRunningActionSet(); + ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext = it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + action = static_cast(&*it); deltap = delta; if (action->m_latency > 0) { if (action->m_latency > deltap) { @@ -157,7 +157,7 @@ void HostL07Model::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); @@ -169,13 +169,13 @@ void HostL07Model::updateActionsState(double /*now*/, double delta) return; } -ActionPtr HostL07Model::executeParallelTask(int host_nb, +Action *HostL07Model::executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, double rate) { - HostL07ActionPtr action; + HostL07Action *action; int i, j; unsigned int cpt; int nb_link = 0; @@ -196,16 +196,16 @@ ActionPtr HostL07Model::executeParallelTask(int host_nb, double lat=0.0; unsigned int cpt; void *_link; - LinkL07Ptr link; + LinkL07 *link; - routing_platf->getRouteAndLatency(static_cast(host_list[i])->p_netElm, - static_cast(host_list[j])->p_netElm, + routing_platf->getRouteAndLatency(static_cast(host_list[i])->p_netElm, + static_cast(host_list[j])->p_netElm, &route, &lat); latency = MAX(latency, lat); xbt_dynar_foreach(route, cpt, _link) { - link = static_cast(_link); + link = static_cast(_link); xbt_dict_set(ptask_parallel_task_link_set, link->getName(), link, NULL); } } @@ -225,7 +225,7 @@ ActionPtr HostL07Model::executeParallelTask(int host_nb, action->m_suspended = 0; /* Should be useless because of the calloc but it seems to help valgrind... */ action->m_hostNb = host_nb; - action->p_hostList = (HostPtr *) host_list; + action->p_hostList = (Host **) host_list; action->p_computationAmount = flops_amount; action->p_communicationAmount = bytes_amount; action->m_latency = latency; @@ -240,24 +240,24 @@ ActionPtr HostL07Model::executeParallelTask(int host_nb, for (i = 0; i < host_nb; i++) lmm_expand(ptask_maxmin_system, - static_cast(host_list[i])->p_cpu->getConstraint(), + static_cast(host_list[i])->p_cpu->getConstraint(), action->getVariable(), flops_amount[i]); for (i = 0; i < host_nb; i++) { for (j = 0; j < host_nb; j++) { void *_link; - LinkL07Ptr link; + LinkL07 *link; xbt_dynar_t route=NULL; if (bytes_amount[i * host_nb + j] == 0.0) continue; - routing_platf->getRouteAndLatency(static_cast(host_list[i])->p_netElm, - static_cast(host_list[j])->p_netElm, + routing_platf->getRouteAndLatency(static_cast(host_list[i])->p_netElm, + static_cast(host_list[j])->p_netElm, &route, NULL); xbt_dynar_foreach(route, cpt, _link) { - link = static_cast(_link); + link = static_cast(_link); lmm_expand_add(ptask_maxmin_system, link->getConstraint(), action->getVariable(), bytes_amount[i * host_nb + j]); @@ -273,9 +273,9 @@ ActionPtr HostL07Model::executeParallelTask(int host_nb, return action; } -HostPtr HostL07Model::createHost(const char *name) +Host *HostL07Model::createHost(const char *name) { - HostL07Ptr wk = NULL; + HostL07 *wk = NULL; sg_host_t sg_host = sg_host_by_name(name); xbt_assert(!surf_host_resource_priv(sg_host), @@ -291,13 +291,13 @@ HostPtr HostL07Model::createHost(const char *name) return wk;//FIXME:xbt_lib_get_elm_or_null(host_lib, name); } -ActionPtr HostL07Model::communicate(HostPtr src, HostPtr dst, +Action *HostL07Model::communicate(Host *src, Host *dst, double size, double rate) { void **host_list = xbt_new0(void *, 2); double *flops_amount = xbt_new0(double, 2); double *bytes_amount = xbt_new0(double, 4); - ActionPtr res = NULL; + Action *res = NULL; host_list[0] = src; host_list[1] = dst; @@ -310,14 +310,14 @@ ActionPtr HostL07Model::communicate(HostPtr src, HostPtr dst, return res; } -xbt_dynar_t HostL07Model::getRoute(HostPtr src, HostPtr dst) +xbt_dynar_t HostL07Model::getRoute(Host *src, Host *dst) { xbt_dynar_t route=NULL; routing_platf->getRouteAndLatency(src->p_netElm, dst->p_netElm, &route, NULL); return route; } -CpuPtr CpuL07Model::createCpu(const char *name, xbt_dynar_t powerPeak, +Cpu *CpuL07Model::createCpu(const char *name, xbt_dynar_t powerPeak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, @@ -332,7 +332,7 @@ CpuPtr CpuL07Model::createCpu(const char *name, xbt_dynar_t powerPeak, "Host '%s' declared several times in the platform file.", name); - CpuL07Ptr cpu = new CpuL07(this, name, cpu_properties, + CpuL07 *cpu = new CpuL07(this, name, cpu_properties, power_initial, power_scale, power_trace, core, state_initial, state_trace); @@ -356,7 +356,7 @@ Link* NetworkL07Model::createLink(const char *name, "Link '%s' declared several times in the platform file.", name); - LinkL07Ptr nw_link = new LinkL07(this, name, properties, + LinkL07 *nw_link = new LinkL07(this, name, properties, bw_initial, bw_trace, lat_initial, lat_trace, state_initial, state_trace, @@ -376,7 +376,7 @@ void HostL07Model::addTraces() /* Connect traces relative to cpu */ 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); - CpuL07Ptr host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuL07 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -386,7 +386,7 @@ void HostL07Model::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); - CpuL07Ptr host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); + CpuL07 *host = static_cast(sg_host_surfcpu(sg_host_by_name(elm))); xbt_assert(host, "Host %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -397,7 +397,7 @@ void HostL07Model::addTraces() /* Connect 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); - LinkL07Ptr link = static_cast(Link::byName(elm)); + LinkL07 *link = static_cast(Link::byName(elm)); xbt_assert(link, "Link %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -407,7 +407,7 @@ void HostL07Model::addTraces() 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); - LinkL07Ptr link = static_cast(Link::byName(elm)); + LinkL07 *link = static_cast(Link::byName(elm)); xbt_assert(link, "Link %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -417,7 +417,7 @@ void HostL07Model::addTraces() 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); - LinkL07Ptr link = static_cast(Link::byName(elm)); + LinkL07 *link = static_cast(Link::byName(elm)); xbt_assert(link, "Link %s undefined", elm); xbt_assert(trace, "Trace %s undefined", trace_name); @@ -430,7 +430,7 @@ void HostL07Model::addTraces() * Resource * ************/ -HostL07::HostL07(HostModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu) +HostL07::HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu) : Host(model, name, props, NULL, netElm, cpu) { } @@ -460,7 +460,7 @@ double HostL07::getConsumedEnergy() THROW_UNIMPLEMENTED; } -CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props, +CpuL07::CpuL07(CpuL07Model *model, const char* name, xbt_dict_t props, double power_initial, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace) : Cpu(model, name, props, lmm_constraint_new(ptask_maxmin_system, this, power_initial * power_scale), @@ -478,7 +478,7 @@ CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props, p_stateEvent = tmgr_history_add_trace(history, state_trace, 0.0, 0, this); } -LinkL07::LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props, +LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bw_initial, tmgr_trace_t bw_trace, double lat_initial, @@ -560,7 +560,7 @@ e_surf_resource_state_t HostL07::getState() return p_cpu->getState(); } -ActionPtr HostL07::execute(double size) +Action *HostL07::execute(double size) { void **host_list = xbt_new0(void *, 1); double *flops_amount = xbt_new0(double, 1); @@ -570,18 +570,18 @@ ActionPtr HostL07::execute(double size) bytes_amount[0] = 0.0; flops_amount[0] = size; - return static_cast(getModel())->executeParallelTask(1, host_list, + return static_cast(getModel())->executeParallelTask(1, host_list, flops_amount, bytes_amount, -1); } -ActionPtr HostL07::sleep(double duration) +Action *HostL07::sleep(double duration) { - HostL07ActionPtr action = NULL; + HostL07Action *action = NULL; XBT_IN("(%s,%g)", getName(), duration); - action = static_cast(execute(1.0)); + action = static_cast(execute(1.0)); action->m_maxDuration = duration; action->m_suspended = 2; lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0); @@ -609,12 +609,12 @@ double LinkL07::getLatency() void LinkL07::updateLatency(double value, double date) { lmm_variable_t var = NULL; - HostL07ActionPtr action; + HostL07Action *action; lmm_element_t elem = NULL; m_latCurrent = value; while ((var = lmm_get_var_from_cnst(ptask_maxmin_system, getConstraint(), &elem))) { - action = (HostL07ActionPtr) lmm_variable_id(var); + action = static_cast(lmm_variable_id(var)); action->updateBound(); } } @@ -647,8 +647,8 @@ void HostL07Action::updateBound() if (p_communicationAmount[i * m_hostNb + j] > 0) { double lat = 0.0; - routing_platf->getRouteAndLatency(static_cast(((void**)p_hostList)[i])->p_netElm, - static_cast(((void**)p_hostList)[j])->p_netElm, + routing_platf->getRouteAndLatency(static_cast(((void**)p_hostList)[i])->p_netElm, + static_cast(((void**)p_hostList)[j])->p_netElm, &route, &lat); lat_current = MAX(lat_current, lat * p_communicationAmount[i * m_hostNb + j]); diff --git a/src/surf/host_ptask_L07.hpp b/src/surf/host_ptask_L07.hpp index 93038d3d95..dc91dc1957 100644 --- a/src/surf/host_ptask_L07.hpp +++ b/src/surf/host_ptask_L07.hpp @@ -14,25 +14,14 @@ ***********/ class HostL07Model; -typedef HostL07Model *HostL07ModelPtr; - class CpuL07Model; -typedef CpuL07Model *CpuL07ModelPtr; - class NetworkL07Model; -typedef NetworkL07Model *NetworkL07ModelPtr; class HostL07; -typedef HostL07 *HostL07Ptr; - class CpuL07; -typedef CpuL07 *CpuL07Ptr; - class LinkL07; -typedef LinkL07 *LinkL07Ptr; class HostL07Action; -typedef HostL07Action *HostL07ActionPtr; /********* * Tools * @@ -48,23 +37,23 @@ public: double shareResources(double now); void updateActionsState(double now, double delta); - HostPtr createHost(const char *name); - ActionPtr executeParallelTask(int host_nb, + Host *createHost(const char *name); + Action *executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, double rate); - xbt_dynar_t getRoute(HostPtr src, HostPtr dst); - ActionPtr communicate(HostPtr src, HostPtr dst, double size, double rate); + xbt_dynar_t getRoute(Host *src, Host *dst); + Action *communicate(Host *src, Host *dst, double size, double rate); void addTraces(); - NetworkModelPtr p_networkModel; + NetworkModel *p_networkModel; }; class CpuL07Model : public CpuModel { public: CpuL07Model() : CpuModel("cpuL07") {}; ~CpuL07Model() {surf_cpu_model_pm = NULL;}; - CpuPtr createCpu(const char *name, xbt_dynar_t powerPeak, + Cpu *createCpu(const char *name, xbt_dynar_t powerPeak, int pstate, double power_scale, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, @@ -72,7 +61,7 @@ public: xbt_dict_t cpu_properties); void addTraces() {DIE_IMPOSSIBLE;}; - HostL07ModelPtr p_hostModel; + HostL07Model *p_hostModel; }; class NetworkL07Model : public NetworkModel { @@ -90,9 +79,9 @@ public: e_surf_link_sharing_policy_t policy, xbt_dict_t properties); - ActionPtr communicate(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;}; + Action *communicate(RoutingEdge */*src*/, RoutingEdge */*dst*/, double /*size*/, double /*rate*/) {DIE_IMPOSSIBLE;}; void addTraces() {DIE_IMPOSSIBLE;}; - HostL07ModelPtr p_hostModel; + HostL07Model *p_hostModel; }; /************ @@ -101,12 +90,12 @@ public: class HostL07 : public Host { public: - HostL07(HostModelPtr model, const char* name, xbt_dict_t props, RoutingEdgePtr netElm, CpuPtr cpu); + HostL07(HostModel *model, const char* name, xbt_dict_t props, RoutingEdge *netElm, Cpu *cpu); //bool isUsed(); bool isUsed() {DIE_IMPOSSIBLE;}; void updateState(tmgr_trace_event_t /*event_type*/, double /*value*/, double /*date*/) {DIE_IMPOSSIBLE;}; - ActionPtr execute(double size); - ActionPtr sleep(double duration); + Action *execute(double size); + Action *sleep(double duration); e_surf_resource_state_t getState(); double getPowerPeakAt(int pstate_index); int getNbPstates(); @@ -120,14 +109,14 @@ class CpuL07 : public Cpu { tmgr_trace_event_t p_stateEvent; tmgr_trace_event_t p_powerEvent; public: - CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t properties, + CpuL07(CpuL07Model *model, const char* name, xbt_dict_t properties, double power_scale, double power_initial, tmgr_trace_t power_trace, int core, e_surf_resource_state_t state_initial, tmgr_trace_t state_trace); bool isUsed(); //bool isUsed() {DIE_IMPOSSIBLE;}; void updateState(tmgr_trace_event_t event_type, double value, double date); - CpuActionPtr execute(double /*size*/) {DIE_IMPOSSIBLE;}; - CpuActionPtr sleep(double /*duration*/) {DIE_IMPOSSIBLE;}; + CpuAction *execute(double /*size*/) {DIE_IMPOSSIBLE;}; + CpuAction *sleep(double /*duration*/) {DIE_IMPOSSIBLE;}; double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;}; double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;}; @@ -139,7 +128,7 @@ public: class LinkL07 : public Link { public: - LinkL07(NetworkL07ModelPtr model, const char* name, xbt_dict_t props, + LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bw_initial, tmgr_trace_t bw_trace, double lat_initial, @@ -168,15 +157,15 @@ public: * Action * **********/ class HostL07Action : public HostAction { - friend ActionPtr HostL07::execute(double size); - friend ActionPtr HostL07::sleep(double duration); - friend ActionPtr HostL07Model::executeParallelTask(int host_nb, + friend Action *HostL07::execute(double size); + friend Action *HostL07::sleep(double duration); + friend Action *HostL07Model::executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, double rate); public: - HostL07Action(ModelPtr model, double cost, bool failed) + HostL07Action(Model *model, double cost, bool failed) : HostAction(model, cost, failed) {}; ~HostL07Action(); @@ -192,7 +181,7 @@ public: double getRemains(); int m_hostNb; - HostPtr *p_hostList; + Host **p_hostList; double *p_computationAmount; double *p_communicationAmount; double m_latency; diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index fc8b453746..7f9a358fd3 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -676,7 +676,7 @@ void lmm_solve(lmm_system_t sys) cnst->usage = elem->value / elem->variable->weight; make_elem_active(elem); - ActionPtr action = static_cast(elem->variable->id); + Action *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 d49e20b064..fd81be35cf 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -54,7 +54,7 @@ void surf_network_model_init_LegrandVelho(void) surf_network_model = new NetworkCm02Model(); net_define_callbacks(); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", @@ -83,7 +83,7 @@ void surf_network_model_init_CM02(void) surf_network_model = new NetworkCm02Model(); net_define_callbacks(); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0); @@ -109,7 +109,7 @@ void surf_network_model_init_Reno(void) surf_network_model = new NetworkCm02Model(); net_define_callbacks(); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); lmm_set_default_protocol_function(func_reno_f, func_reno_fp, func_reno_fpi); @@ -129,7 +129,7 @@ void surf_network_model_init_Reno2(void) surf_network_model = new NetworkCm02Model(); net_define_callbacks(); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp, func_reno2_fpi); @@ -149,7 +149,7 @@ void surf_network_model_init_Vegas(void) surf_network_model = new NetworkCm02Model(); net_define_callbacks(); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp, func_vegas_fpi); @@ -220,10 +220,10 @@ Link* NetworkCm02Model::createLink(const char *name, void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) { - NetworkCm02ActionPtr action; + NetworkCm02Action *action; while ((xbt_heap_size(p_actionHeap) > 0) && (double_equals(xbt_heap_maxkey(p_actionHeap), now, sg_surf_precision))) { - action = (NetworkCm02ActionPtr) xbt_heap_pop(p_actionHeap); + action = static_cast (xbt_heap_pop(p_actionHeap)); XBT_DEBUG("Something happened to action %p", action); if (TRACE_is_enabled()) { int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable()); @@ -271,14 +271,14 @@ void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/) void NetworkCm02Model::updateActionsStateFull(double now, double delta) { - NetworkCm02ActionPtr action; - ActionListPtr running_actions = getRunningActionSet(); + NetworkCm02Action *action; + ActionList *running_actions = getRunningActionSet(); for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end()) ; it != itend ; it=itNext) { ++itNext; - action = (NetworkCm02ActionPtr) &*it; + action = static_cast (&*it); XBT_DEBUG("Something happened to action %p", action); double deltap = delta; if (action->m_latency > 0) { @@ -339,20 +339,20 @@ void NetworkCm02Model::updateActionsStateFull(double now, double delta) return; } -ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, +Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate) { unsigned int i; void *_link; NetworkCm02Link *link; int failed = 0; - NetworkCm02ActionPtr action = NULL; + NetworkCm02Action *action = NULL; double bandwidth_bound; double latency = 0.0; xbt_dynar_t back_route = NULL; int constraints_per_variable = 0; - xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdgePtr), NULL); + xbt_dynar_t route = xbt_dynar_new(sizeof(RoutingEdge*), NULL); XBT_IN("(%s,%s,%g,%g)", src->getName(), dst->getName(), size, rate); @@ -515,7 +515,7 @@ void NetworkCm02Model::addTraces(){ /************ * Resource * ************/ -NetworkCm02Link::NetworkCm02Link(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props, +NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, lmm_system_t system, double constraint_value, tmgr_history_t history, @@ -572,7 +572,7 @@ void NetworkCm02Link::updateState(tmgr_trace_event_t event_type, setState(SURF_RESOURCE_OFF); while ((var = lmm_get_var_from_cnst(getModel()->getMaxminSystem(), cnst, &elem))) { - ActionPtr action = (ActionPtr) lmm_variable_id(var); + Action *action = static_cast( lmm_variable_id(var) ); if (action->getState() == SURF_ACTION_RUNNING || action->getState() == SURF_ACTION_READY) { @@ -602,7 +602,7 @@ void NetworkCm02Link::updateBandwidth(double value, double date){ lmm_element_t nextelem = NULL; int numelem = 0; - NetworkCm02ActionPtr action = NULL; + NetworkCm02Action *action = NULL; p_power.peak = value; lmm_update_constraint_bound(getModel()->getMaxminSystem(), @@ -612,7 +612,7 @@ void NetworkCm02Link::updateBandwidth(double value, double date){ TRACE_surf_link_set_bandwidth(date, getName(), sg_bandwidth_factor * p_power.peak * p_power.scale); if (sg_weight_S_parameter > 0) { while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action = (NetworkCm02Action*) lmm_variable_id(var); action->m_weight += delta; if (!action->isSuspended()) lmm_update_variable_weight(getModel()->getMaxminSystem(), action->getVariable(), action->m_weight); @@ -626,11 +626,11 @@ void NetworkCm02Link::updateLatency(double value, double date){ lmm_element_t elem = NULL; lmm_element_t nextelem = NULL; int numelem = 0; - NetworkCm02ActionPtr action = NULL; + NetworkCm02Action *action = NULL; m_latCurrent = value; while ((var = lmm_get_var_from_cnst_safe(getModel()->getMaxminSystem(), getConstraint(), &elem, &nextelem, &numelem))) { - action = (NetworkCm02ActionPtr) lmm_variable_id(var); + action = (NetworkCm02Action*) lmm_variable_id(var); action->m_latCurrent += delta; action->m_weight += delta; if (action->m_rate < 0) diff --git a/src/surf/network_cm02.hpp b/src/surf/network_cm02.hpp index 84b0e992c8..f9d418ab69 100644 --- a/src/surf/network_cm02.hpp +++ b/src/surf/network_cm02.hpp @@ -15,10 +15,7 @@ * Classes * ***********/ class NetworkCm02Model; -typedef NetworkCm02Model *NetworkCm02ModelPtr; - class NetworkCm02Action; -typedef NetworkCm02Action *NetworkCm02ActionPtr; /********* * Tools * @@ -57,7 +54,7 @@ public: void addTraces(); void updateActionsStateLazy(double now, double delta); void updateActionsStateFull(double now, double delta); - ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, + Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate); }; @@ -67,7 +64,7 @@ public: class NetworkCm02Link : public Link { public: - NetworkCm02Link(NetworkCm02ModelPtr model, const char *name, xbt_dict_t props, + NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props, lmm_system_t system, double constraint_value, tmgr_history_t history, @@ -89,10 +86,10 @@ public: **********/ class NetworkCm02Action : public NetworkAction { - friend ActionPtr NetworkCm02Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate); + friend Action *NetworkCm02Model::communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate); public: - NetworkCm02Action(ModelPtr model, double cost, bool failed) + NetworkCm02Action(Model *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 06001baa61..65744733c9 100644 --- a/src/surf/network_constant.cpp +++ b/src/surf/network_constant.cpp @@ -24,19 +24,19 @@ void surf_network_model_init_Constant() sg_platf_host_add_cb(netcste_count_hosts); - ModelPtr model = surf_network_model; + Model *model = surf_network_model; xbt_dynar_push(model_list, &model); } double NetworkConstantModel::shareResources(double /*now*/) { - NetworkConstantActionPtr action = NULL; + NetworkConstantAction *action = NULL; double min = -1.0; - ActionListPtr actionSet = getRunningActionSet(); + ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end()) ; it != itend ; ++it) { - action = static_cast(&*it); + action = static_cast(&*it); if (action->m_latency > 0 && (min < 0 || action->m_latency < min)) min = action->m_latency; } @@ -46,12 +46,12 @@ double NetworkConstantModel::shareResources(double /*now*/) void NetworkConstantModel::updateActionsState(double /*now*/, double delta) { - NetworkConstantActionPtr action = NULL; - ActionListPtr actionSet = getRunningActionSet(); + NetworkConstantAction *action = NULL; + ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + action = static_cast(&*it); if (action->m_latency > 0) { if (action->m_latency > delta) { double_update(&(action->m_latency), delta, sg_surf_precision); @@ -74,14 +74,14 @@ void NetworkConstantModel::updateActionsState(double /*now*/, double delta) } } -ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, +Action *NetworkConstantModel::communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate) { char *src_name = src->getName(); char *dst_name = dst->getName(); XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate); - NetworkConstantActionPtr action = new NetworkConstantAction(this, size, sg_latency_factor); + NetworkConstantAction *action = new NetworkConstantAction(this, size, sg_latency_factor); XBT_OUT(); surf_callback_emit(networkCommunicateCallbacks, action, src, dst, size, rate); diff --git a/src/surf/network_constant.hpp b/src/surf/network_constant.hpp index 13f2833af9..ecff72a5a3 100644 --- a/src/surf/network_constant.hpp +++ b/src/surf/network_constant.hpp @@ -13,10 +13,7 @@ * Classes * ***********/ class NetworkConstantModel; -typedef NetworkConstantModel *NetworkConstantModelPtr; - class NetworkConstantAction; -typedef NetworkConstantAction *NetworkConstantActionPtr; /********* * Model * @@ -30,9 +27,9 @@ public: }; double shareResources(double now); void updateActionsState(double now, double delta); - ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, + Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate); - void gapRemove(ActionPtr action); + void gapRemove(Action *action); }; /************ @@ -40,7 +37,7 @@ public: ************/ class NetworkConstantLink : public NetworkCm02Link { public: - NetworkConstantLink(NetworkCm02ModelPtr model, const char* name, xbt_dict_t properties); + NetworkConstantLink(NetworkCm02Model *model, const char* name, xbt_dict_t properties); bool isUsed(); void updateState(tmgr_trace_event_t event_type, double value, double date); double getBandwidth(); @@ -53,7 +50,7 @@ public: **********/ class NetworkConstantAction : public NetworkCm02Action { public: - NetworkConstantAction(NetworkConstantModelPtr model_, double size, double latency) + NetworkConstantAction(NetworkConstantModel *model_, double size, double latency) : NetworkCm02Action(model_, size, false) , m_latInit(latency) { diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 9c9854c7a7..cecdfc8d7e 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -24,7 +24,7 @@ static void IB_create_host_callback(sg_platf_host_cbarg_t t){ } -static void IB_action_state_changed_callback(NetworkActionPtr action, e_surf_action_state_t statein, e_surf_action_state_t stateout){ +static void IB_action_state_changed_callback(NetworkAction *action, e_surf_action_state_t statein, e_surf_action_state_t stateout){ if(statein!=SURF_ACTION_RUNNING|| stateout!=SURF_ACTION_DONE) return; std::pair pair = ((NetworkIBModel*)surf_network_model)->active_comms[action]; @@ -37,7 +37,7 @@ static void IB_action_state_changed_callback(NetworkActionPtr action, e_surf_act } -static void IB_action_init_callback(NetworkActionPtr action,RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate){ +static void IB_action_init_callback(NetworkAction *action,RoutingEdge *src, RoutingEdge *dst, double size, double rate){ if(((NetworkIBModel*)surf_network_model)->active_nodes==NULL) xbt_die("IB comm added, without any node connected !"); @@ -184,7 +184,7 @@ void NetworkIBModel::updateIBfactors_rec(IBNode *root, bool* updatedlist) { } -void NetworkIBModel::updateIBfactors(NetworkActionPtr action, IBNode *from, IBNode * to, int remove) { +void NetworkIBModel::updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove) { if (from == to)//disregard local comms (should use loopback) return; diff --git a/src/surf/network_ib.hpp b/src/surf/network_ib.hpp index 7328b97234..77e361e92c 100644 --- a/src/surf/network_ib.hpp +++ b/src/surf/network_ib.hpp @@ -15,7 +15,7 @@ class ActiveComm{ public : //IBNode* origin; IBNode* destination; - NetworkActionPtr action; + NetworkAction *action; double init_rate; ActiveComm() : destination(NULL),action(NULL),init_rate(-1){}; ~ActiveComm(){}; @@ -42,10 +42,10 @@ public: NetworkIBModel(); NetworkIBModel(const char *name); ~NetworkIBModel(); - void updateIBfactors(NetworkActionPtr action, IBNode *from, IBNode * to, int remove); + void updateIBfactors(NetworkAction *action, IBNode *from, IBNode * to, int remove); xbt_dict_t active_nodes; - std::map > active_comms; + std::map > active_comms; double Bs; double Be; diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 548671759e..37ee98e702 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -87,8 +87,8 @@ void Link::linksExit() { surf_callback(void, Link*) networkLinkCreatedCallbacks; surf_callback(void, Link*) networkLinkDestructedCallbacks; surf_callback(void, Link*, e_surf_resource_state_t, e_surf_resource_state_t) networkLinkStateChangedCallbacks; -surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; -surf_callback(void, NetworkActionPtr, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate) networkCommunicateCallbacks; +surf_callback(void, NetworkAction*, e_surf_action_state_t, e_surf_action_state_t) networkActionStateChangedCallbacks; +surf_callback(void, NetworkAction*, RoutingEdge *src, RoutingEdge *dst, double size, double rate) networkCommunicateCallbacks; void netlink_parse_init(sg_platf_link_cbarg_t link){ if (link->policy == SURF_LINK_FULLDUPLEX) { @@ -130,7 +130,7 @@ void net_add_traces(){ * Model * *********/ -NetworkModelPtr surf_network_model = NULL; +NetworkModel *surf_network_model = NULL; double NetworkModel::latencyFactor(double /*size*/) { return sg_latency_factor; @@ -146,15 +146,15 @@ double NetworkModel::bandwidthConstraint(double rate, double /*bound*/, double / double NetworkModel::shareResourcesFull(double now) { - NetworkActionPtr action = NULL; - ActionListPtr runningActions = surf_network_model->getRunningActionSet(); + NetworkAction *action = NULL; + ActionList *runningActions = surf_network_model->getRunningActionSet(); double minRes; minRes = shareResourcesMaxMin(runningActions, surf_network_model->p_maxminSystem, surf_network_model->f_networkSolve); for(ActionList::iterator it(runningActions->begin()), itend(runningActions->end()) ; it != itend ; ++it) { - action = static_cast(&*it); + action = static_cast(&*it); #ifdef HAVE_LATENCY_BOUND_TRACKING if (lmm_is_variable_limited_by_latency(action->getVariable())) { action->m_latencyLimited = 1; @@ -176,7 +176,7 @@ double NetworkModel::shareResourcesFull(double now) * Resource * ************/ -Link::Link(NetworkModelPtr model, const char *name, xbt_dict_t props) +Link::Link(NetworkModel *model, const char *name, xbt_dict_t props) : Resource(model, name, props) , p_latEvent(NULL) { @@ -186,7 +186,7 @@ Link::Link(NetworkModelPtr model, const char *name, xbt_dict_t props) XBT_DEBUG("Create link '%s'",name); } -Link::Link(NetworkModelPtr model, const char *name, xbt_dict_t props, +Link::Link(NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace) diff --git a/src/surf/network_interface.hpp b/src/surf/network_interface.hpp index 171a047f30..1893836524 100644 --- a/src/surf/network_interface.hpp +++ b/src/surf/network_interface.hpp @@ -19,10 +19,7 @@ * Classes * ***********/ class NetworkModel; -typedef NetworkModel *NetworkModelPtr; - class NetworkAction; -typedef NetworkAction *NetworkActionPtr; /************* * Callbacks * @@ -42,21 +39,21 @@ XBT_PUBLIC_DATA( surf_callback(void, Link*)) networkLinkDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emits the callbacks after Link State changed - * @details Callback functions have the following signature: `void(LinkActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` + * @details Callback functions have the following signature: `void(LinkAction *action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ XBT_PUBLIC_DATA( surf_callback(void, Link*, e_surf_resource_state_t, e_surf_resource_state_t)) networkLinkStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emits the callbacks after NetworkAction State changed - * @details Callback functions have the following signature: `void(NetworkActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` + * @details Callback functions have the following signature: `void(NetworkAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -XBT_PUBLIC_DATA( surf_callback(void, NetworkActionPtr, e_surf_action_state_t, e_surf_action_state_t)) networkActionStateChangedCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, NetworkAction*, e_surf_action_state_t, e_surf_action_state_t)) networkActionStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emits the callbacks after communication created - * @details Callback functions have the following signature: `void(NetworkActionPtr action, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate)` + * @details Callback functions have the following signature: `void(NetworkAction *action, RoutingEdge *src, RoutingEdge *dst, double size, double rate)` */ -XBT_PUBLIC_DATA( surf_callback(void, NetworkActionPtr, RoutingEdgePtr src, RoutingEdgePtr dst, double size, double rate)) networkCommunicateCallbacks; +XBT_PUBLIC_DATA( surf_callback(void, NetworkAction*, RoutingEdge *src, RoutingEdge *dst, double size, double rate)) networkCommunicateCallbacks; /********* * Tools * @@ -118,7 +115,7 @@ public: e_surf_link_sharing_policy_t policy, xbt_dict_t properties)=0; - virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkActionPtr /*action*/) {}; + virtual void gapAppend(double /*size*/, const Link* /*link*/, NetworkAction */*action*/) {}; /** * @brief Create a communication between two hosts. @@ -132,7 +129,7 @@ public: * unlimited. * @return The action representing the communication */ - virtual ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, + virtual Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate)=0; /** @@ -196,7 +193,7 @@ public: * @param name The name of the Link * @param props Dictionary of properties associated to this Link */ - Link(NetworkModelPtr model, const char *name, xbt_dict_t props); + Link(NetworkModel *model, const char *name, xbt_dict_t props); /** * @brief Link constructor @@ -208,7 +205,7 @@ public: * @param history [TODO] * @param state_trace [TODO] */ - Link(NetworkModelPtr model, const char *name, xbt_dict_t props, + Link(NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint, tmgr_history_t history, tmgr_trace_t state_trace); @@ -282,7 +279,7 @@ public: * @param cost The cost of this NetworkAction in [TODO] * @param failed [description] */ - NetworkAction(ModelPtr model, double cost, bool failed) + NetworkAction(Model *model, double cost, bool failed) : Action(model, cost, failed) {} /** @@ -294,7 +291,7 @@ public: * @param var The lmm variable associated to this Action if it is part of a * LMM component */ - NetworkAction(ModelPtr model, double cost, bool failed, lmm_variable_t var) + NetworkAction(Model *model, double cost, bool failed, lmm_variable_t var) : Action(model, cost, failed, var) {}; void setState(e_surf_action_state_t state); diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index af2046786c..4e8cccc7a2 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -198,7 +198,7 @@ static void create_ns3_topology(void) xbt_die("There is no routes!"); XBT_DEBUG("Have get_onelink_routes, found %ld routes",onelink_routes->used); //save them in trace file - OnelinkPtr onelink; + Onelink *onelink; unsigned int iter; xbt_dynar_foreach(onelink_routes, iter, onelink) { char *src = onelink->p_src->getName(); @@ -308,7 +308,7 @@ Link* NetworkNS3Model::createLink(const char *name, return new NetworkNS3Link(this, name, properties, bw_initial, lat_initial); } -xbt_dynar_t NetworkNS3Model::getRoute(RoutingEdgePtr src, RoutingEdgePtr dst) +xbt_dynar_t NetworkNS3Model::getRoute(RoutingEdge *src, RoutingEdge *dst) { xbt_dynar_t route = NULL; routing_get_route_and_latency(src, dst, &route, NULL); @@ -316,11 +316,11 @@ xbt_dynar_t NetworkNS3Model::getRoute(RoutingEdgePtr src, RoutingEdgePtr dst) return route; } -ActionPtr NetworkNS3Model::communicate(RoutingEdgePtr src, RoutingEdgePtr dst, +Action *NetworkNS3Model::communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate) { XBT_DEBUG("Communicate from %s to %s", src->getName(), dst->getName()); - NetworkNS3ActionPtr action = new NetworkNS3Action(this, size, 0); + NetworkNS3Action *action = new NetworkNS3Action(this, size, 0); ns3_create_flow(src->getName(), dst->getName(), surf_get_clock(), size, action); @@ -370,9 +370,9 @@ void NetworkNS3Model::updateActionsState(double now, double delta) return; } - NetworkNS3ActionPtr action; + NetworkNS3Action *action; xbt_dict_foreach(dict_socket,cursor,key,data){ - action = static_cast(ns3_get_socket_action(data)); + action = static_cast(ns3_get_socket_action(data)); XBT_DEBUG("Processing socket %p (action %p)",data,action); action->setRemains(action->getCost() - ns3_get_socket_sent(data)); @@ -386,7 +386,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) routing_get_route_and_latency (action->p_srcElm, action->p_dstElm, &route, NULL); unsigned int i; for (i = 0; i < xbt_dynar_length (route); i++){ - NetworkNS3Link* link = ((NetworkNS3Link*)xbt_dynar_get_ptr (route, i)); + NetworkNS3Link* link = ((NetworkNS3Link*)xbt_dynar_get_ptr(route, i)); TRACE_surf_link_set_utilization (link->getName(), action->getCategory(), (data_delta_sent)/delta, @@ -408,7 +408,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) xbt_dynar_pop(socket_to_destroy,&key); void *data = xbt_dict_get (dict_socket, key); - action = static_cast(ns3_get_socket_action(data)); + action = static_cast(ns3_get_socket_action(data)); XBT_DEBUG ("Removing socket %p of action %p", key, action); xbt_dict_remove(dict_socket, key); } @@ -419,7 +419,7 @@ void NetworkNS3Model::updateActionsState(double now, double delta) * Resource * ************/ -NetworkNS3Link::NetworkNS3Link(NetworkNS3ModelPtr model, const char *name, xbt_dict_t props, +NetworkNS3Link::NetworkNS3Link(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bw_initial, double lat_initial) : Link(model, name, props) , p_lat(bprintf("%f", lat_initial)) @@ -441,7 +441,7 @@ void NetworkNS3Link::updateState(tmgr_trace_event_t event_type, double value, do * Action * **********/ -NetworkNS3Action::NetworkNS3Action(ModelPtr model, double cost, bool failed) +NetworkNS3Action::NetworkNS3Action(Model *model, double cost, bool failed) : NetworkAction(model, cost, failed) {} diff --git a/src/surf/network_ns3.hpp b/src/surf/network_ns3.hpp index b04d5c98b0..b296eb2347 100644 --- a/src/surf/network_ns3.hpp +++ b/src/surf/network_ns3.hpp @@ -14,10 +14,7 @@ * Classes * ***********/ class NetworkNS3Model; -typedef NetworkNS3Model *NetworkNS3ModelPtr; - class NetworkNS3Action; -typedef NetworkNS3Action *NetworkNS3ActionPtr; /********* * Tools * @@ -43,8 +40,8 @@ public: tmgr_trace_t state_trace, e_surf_link_sharing_policy_t policy, xbt_dict_t properties); - xbt_dynar_t getRoute(RoutingEdgePtr src, RoutingEdgePtr dst); - ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst, + xbt_dynar_t getRoute(RoutingEdge *src, RoutingEdge *dst); + Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate); double shareResources(double now); void updateActionsState(double now, double delta); @@ -56,7 +53,7 @@ public: ************/ class NetworkNS3Link : public Link { public: - NetworkNS3Link(NetworkNS3ModelPtr model, const char *name, xbt_dict_t props, + NetworkNS3Link(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bw_initial, double lat_initial); ~NetworkNS3Link(); @@ -78,7 +75,7 @@ public: **********/ class NetworkNS3Action : public NetworkAction { public: - NetworkNS3Action(ModelPtr model, double cost, bool failed); + NetworkNS3Action(Model *model, double cost, bool failed); #ifdef HAVE_LATENCY_BOUND_TRACKING int getLatencyLimited(); @@ -91,8 +88,8 @@ void resume(); //private: double m_lastSent; - RoutingEdgePtr p_srcElm; - RoutingEdgePtr p_dstElm; + RoutingEdge *p_srcElm; + RoutingEdge *p_dstElm; }; diff --git a/src/surf/network_smpi.cpp b/src/surf/network_smpi.cpp index 706e05369a..da209275a8 100644 --- a/src/surf/network_smpi.cpp +++ b/src/surf/network_smpi.cpp @@ -104,7 +104,7 @@ NetworkSmpiModel::~NetworkSmpiModel(){ } } -void NetworkSmpiModel::gapAppend(double size, Link* link, NetworkActionPtr action) +void NetworkSmpiModel::gapAppend(double size, Link* link, NetworkAction *action) { const char *src = link->getName(); xbt_fifo_t fifo; @@ -139,11 +139,11 @@ void NetworkSmpiModel::gapAppend(double size, Link* link, NetworkActionPtr actio } } -void NetworkSmpiModel::gapRemove(ActionPtr lmm_action) +void NetworkSmpiModel::gapRemove(Action *lmm_action) { xbt_fifo_t fifo; size_t size; - NetworkCm02ActionPtr action = static_cast(lmm_action); + NetworkCm02Action *action = static_cast(lmm_action); if (sg_sender_gap > 0.0 && action->p_senderLinkName && action->p_senderFifoItem) { diff --git a/src/surf/network_smpi.hpp b/src/surf/network_smpi.hpp index 879d59caf1..6d7bd4462a 100644 --- a/src/surf/network_smpi.hpp +++ b/src/surf/network_smpi.hpp @@ -11,7 +11,6 @@ ***********/ class NetworkSmpiModel; -typedef NetworkSmpiModel *NetworkSmpiModelPtr; /********* * Tools * @@ -26,8 +25,8 @@ public: NetworkSmpiModel(); ~NetworkSmpiModel(); - void gapAppend(double size, Link* link, NetworkActionPtr action); - void gapRemove(ActionPtr action); + void gapAppend(double size, Link* link, NetworkAction *action); + void gapRemove(Action *action); double latencyFactor(double size); double bandwidthFactor(double size); double bandwidthConstraint(double rate, double bound, double size); diff --git a/src/surf/plugins/energy.cpp b/src/surf/plugins/energy.cpp index 627ad9b0ae..8be806887d 100644 --- a/src/surf/plugins/energy.cpp +++ b/src/surf/plugins/energy.cpp @@ -50,13 +50,13 @@ XBT_LOG_EXTERNAL_CATEGORY(surf_kernel); XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_energy, surf, "Logging specific to the SURF energy plugin"); -std::map *surf_energy=NULL; +std::map *surf_energy=NULL; -static void energyCpuCreatedCallback(CpuPtr cpu){ +static void energyCpuCreatedCallback(Cpu *cpu){ (*surf_energy)[cpu] = new CpuEnergy(cpu); } -static void update_consumption_running(CpuPtr cpu, CpuEnergyPtr cpu_energy) { +static void update_consumption_running(Cpu *cpu, CpuEnergy *cpu_energy) { double cpu_load = lmm_constraint_get_usage(cpu->getConstraint()) / cpu->m_powerPeak; double start_time = cpu_energy->last_updated; double finish_time = surf_get_clock(); @@ -70,7 +70,7 @@ static void update_consumption_running(CpuPtr cpu, CpuEnergyPtr cpu_energy) { XBT_DEBUG("[cpu_update_energy] period=[%.2f-%.2f]; current power peak=%.0E flop/s; consumption change: %.2f J -> %.2f J", start_time, finish_time, cpu->m_powerPeak, previous_energy, energy_this_step); } -static void update_consumption_off(CpuPtr cpu, CpuEnergyPtr cpu_energy) { +static void update_consumption_off(Cpu *cpu, CpuEnergy *cpu_energy) { double start_time = cpu_energy->last_updated; double finish_time = surf_get_clock(); @@ -84,11 +84,11 @@ static void update_consumption_off(CpuPtr cpu, CpuEnergyPtr cpu_energy) { start_time, finish_time, previous_energy, energy_this_step); } -static void energyCpuDestructedCallback(CpuPtr cpu){ - std::map::iterator cpu_energy_it = surf_energy->find(cpu); +static void energyCpuDestructedCallback(Cpu *cpu){ + std::map::iterator cpu_energy_it = surf_energy->find(cpu); xbt_assert(cpu_energy_it != surf_energy->end(), "The cpu is not in surf_energy."); - CpuEnergyPtr cpu_energy = cpu_energy_it->second; + CpuEnergy *cpu_energy = cpu_energy_it->second; if (cpu->getState() == SURF_RESOURCE_OFF) update_consumption_off(cpu, cpu_energy); else @@ -99,17 +99,17 @@ static void energyCpuDestructedCallback(CpuPtr cpu){ surf_energy->erase(cpu_energy_it); } -static void energyCpuActionStateChangedCallback(CpuActionPtr action, e_surf_action_state_t old, e_surf_action_state_t cur){ - CpuPtr cpu = getActionCpu(action); - CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; +static void energyCpuActionStateChangedCallback(CpuAction *action, e_surf_action_state_t old, e_surf_action_state_t cur){ + Cpu *cpu = getActionCpu(action); + CpuEnergy *cpu_energy = (*surf_energy)[cpu]; if(cpu_energy->last_updated < surf_get_clock()) { update_consumption_running(cpu, cpu_energy); } } -static void energyStateChangedCallback(CpuPtr cpu, e_surf_resource_state_t oldState, e_surf_resource_state_t newState){ - CpuEnergyPtr cpu_energy = (*surf_energy)[cpu]; +static void energyStateChangedCallback(Cpu *cpu, e_surf_resource_state_t oldState, e_surf_resource_state_t newState){ + CpuEnergy *cpu_energy = (*surf_energy)[cpu]; if(cpu_energy->last_updated < surf_get_clock()) { if (oldState == SURF_RESOURCE_OFF) @@ -131,7 +131,7 @@ static void sg_energy_plugin_exit() */ void sg_energy_plugin_init() { if (surf_energy == NULL) { - surf_energy = new std::map(); + surf_energy = new std::map(); surf_callback_connect(cpuCreatedCallbacks, energyCpuCreatedCallback); surf_callback_connect(cpuDestructedCallbacks, energyCpuDestructedCallback); surf_callback_connect(cpuActionStateChangedCallbacks, energyCpuActionStateChangedCallback); @@ -143,7 +143,7 @@ void sg_energy_plugin_init() { /** * */ -CpuEnergy::CpuEnergy(CpuPtr ptr) +CpuEnergy::CpuEnergy(Cpu *ptr) : cpu(ptr) { total_energy = 0; @@ -172,14 +172,14 @@ CpuEnergy::~CpuEnergy(){ double CpuEnergy::getWattMinAt(int pstate) { xbt_dynar_t power_range_list = power_range_watts_list; xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); - xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); + xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); double min_power = xbt_dynar_get_as(current_power_values, 0, double); return min_power; } double CpuEnergy::getWattMaxAt(int pstate) { xbt_dynar_t power_range_list = power_range_watts_list; xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); - xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); + xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); double max_power = xbt_dynar_get_as(current_power_values, 1, double); return max_power; } @@ -194,7 +194,7 @@ double CpuEnergy::getCurrentWattsValue(double cpu_load) xbt_assert(power_range_watts_list, "No power range properties specified for host %s", cpu->getName()); /* retrieve the power values associated with the current pstate */ - xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); + xbt_dynar_t current_power_values = xbt_dynar_get_as(power_range_list, static_cast(cpu)->getPState(), xbt_dynar_t); /* min_power corresponds to the idle power (cpu load = 0) */ /* max_power is the power consumed at 100% cpu load */ diff --git a/src/surf/plugins/energy.hpp b/src/surf/plugins/energy.hpp index 9b776be2a4..7185b5726f 100644 --- a/src/surf/plugins/energy.hpp +++ b/src/surf/plugins/energy.hpp @@ -11,13 +11,12 @@ #define CALLBACK_HPP_ class CpuEnergy; -typedef CpuEnergy *CpuEnergyPtr; -extern std::map *surf_energy; +extern std::map *surf_energy; class CpuEnergy { public: - CpuEnergy(CpuPtr ptr); + CpuEnergy(Cpu *ptr); ~CpuEnergy(); double getCurrentWattsValue(double cpu_load); @@ -30,7 +29,7 @@ public: double watts_off; /*< Consumption when the machine is turned off (shutdown) */ double total_energy; /*< Total energy consumed by the host */ double last_updated; /*< Timestamp of the last energy update event*/ - CpuPtr cpu; + Cpu *cpu; }; #endif /* CALLBACK_HPP_ */ diff --git a/src/surf/storage_interface.cpp b/src/surf/storage_interface.cpp index 7d6a8b70a6..996c771432 100644 --- a/src/surf/storage_interface.cpp +++ b/src/surf/storage_interface.cpp @@ -18,16 +18,16 @@ int SURF_STORAGE_LEVEL; xbt_lib_t storage_type_lib; int ROUTING_STORAGE_TYPE_LEVEL; //Routing for storage_type level xbt_dynar_t mount_list = NULL; -StorageModelPtr surf_storage_model = NULL; +StorageModel *surf_storage_model = NULL; /************* * Callbacks * *************/ -surf_callback(void, StoragePtr) storageCreatedCallbacks; -surf_callback(void, StoragePtr) storageDestructedCallbacks; -surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; -surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; +surf_callback(void, Storage*) storageCreatedCallbacks; +surf_callback(void, Storage*) storageDestructedCallbacks; +surf_callback(void, Storage*, e_surf_resource_state_t, e_surf_resource_state_t) storageStateChangedCallbacks; +surf_callback(void, StorageAction*, e_surf_action_state_t, e_surf_action_state_t) storageActionStateChangedCallbacks; /********* * Model * @@ -49,21 +49,21 @@ StorageModel::~StorageModel(){ * Resource * ************/ -Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, +Storage::Storage(Model *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_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) { surf_callback_emit(storageCreatedCallbacks, this); p_content = parseContent(content_name); setState(SURF_RESOURCE_ON); } -Storage::Storage(ModelPtr model, const char *name, xbt_dict_t props, +Storage::Storage(Model *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, char *attach) @@ -71,7 +71,7 @@ Storage::Storage(ModelPtr model, const char *name, xbt_dict_t 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_writeActions(xbt_dynar_new(sizeof(Action*),NULL)) { surf_callback_emit(storageCreatedCallbacks, this); p_content = parseContent(content_name); p_attach = xbt_strdup(attach); @@ -175,15 +175,15 @@ sg_size_t Storage::getUsedSize(){ /********** * Action * **********/ -StorageAction::StorageAction(ModelPtr model, double cost, bool failed, - StoragePtr storage, e_surf_action_storage_type_t type) +StorageAction::StorageAction(Model *model, double cost, bool failed, + Storage *storage, e_surf_action_storage_type_t type) : Action(model, cost, failed) , m_type(type), p_storage(storage), p_file(NULL){ progress = 0; }; -StorageAction::StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var, - StoragePtr storage, e_surf_action_storage_type_t type) +StorageAction::StorageAction(Model *model, double cost, bool failed, lmm_variable_t var, + Storage *storage, e_surf_action_storage_type_t type) : Action(model, cost, failed, var) , m_type(type), p_storage(storage), p_file(NULL){ progress = 0; diff --git a/src/surf/storage_interface.hpp b/src/surf/storage_interface.hpp index 56cd226721..241cb67152 100644 --- a/src/surf/storage_interface.hpp +++ b/src/surf/storage_interface.hpp @@ -16,13 +16,8 @@ extern xbt_dynar_t mount_list; ***********/ class StorageModel; -typedef StorageModel *StorageModelPtr; - class Storage; -typedef Storage *StoragePtr; - class StorageAction; -typedef StorageAction *StorageActionPtr; /************* * Callbacks * @@ -30,27 +25,27 @@ typedef StorageAction *StorageActionPtr; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage creation * - * @details Callback functions have the following signature: `void(StoragePtr)` + * @details Callback functions have the following signature: `void(Storage*)` */ -XBT_PUBLIC_DATA(surf_callback(void, StoragePtr)) storageCreatedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Storage*)) storageCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage destruction * * @details Callback functions have the following signature: `void(StoragePtr)` */ -XBT_PUBLIC_DATA(surf_callback(void, StoragePtr)) storageDestructedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Storage*)) storageDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after Storage State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_resource_state_t old, e_surf_resource_state_t current)` + * @details Callback functions have the following signature: `void(StorageAction *action, e_surf_resource_state_t old, e_surf_resource_state_t current)` */ -XBT_PUBLIC_DATA(surf_callback(void, StoragePtr, e_surf_resource_state_t, e_surf_resource_state_t)) storageStateChangedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, Storage*, e_surf_resource_state_t, e_surf_resource_state_t)) storageStateChangedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after StorageAction State changed * - * @details Callback functions have the following signature: `void(StorageActionPtr action, e_surf_action_state_t old, e_surf_action_state_t current)` + * @details Callback functions have the following signature: `void(StorageAction *action, e_surf_action_state_t old, e_surf_action_state_t current)` */ -XBT_PUBLIC_DATA(surf_callback(void, StorageActionPtr, e_surf_action_state_t, e_surf_action_state_t)) storageActionStateChangedCallbacks; +XBT_PUBLIC_DATA(surf_callback(void, StorageAction*, e_surf_action_state_t, e_surf_action_state_t)) storageActionStateChangedCallbacks; /********* * Model * @@ -82,7 +77,7 @@ public: * @param attach [description] * @return The created Storage */ - virtual StoragePtr createStorage(const char* id, + virtual Storage *createStorage(const char* id, const char* type_id, const char* content_name, const char* content_type, @@ -112,7 +107,7 @@ public: * @param content_type [description] * @param size [description] */ - Storage(ModelPtr model, const char *name, xbt_dict_t props, + Storage(Model *model, const char *name, xbt_dict_t props, const char* type_id, char *content_name, char *content_type, sg_size_t size); @@ -132,7 +127,7 @@ public: * @param size [description] * @param attach [description] */ - Storage(ModelPtr model, const char *name, xbt_dict_t props, + Storage(Model *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, @@ -176,7 +171,7 @@ public: * * @return The StorageAction corresponding to the opening */ - virtual StorageActionPtr open(const char* mount, const char* path)=0; + virtual StorageAction *open(const char* mount, const char* path)=0; /** * @brief Close a file @@ -184,7 +179,7 @@ public: * @param fd The file descriptor to close * @return The StorageAction corresponding to the closing */ - virtual StorageActionPtr close(surf_file_t fd)=0; + virtual StorageAction *close(surf_file_t fd)=0; /** * @brief Read a file @@ -193,7 +188,7 @@ public: * @param size The size in bytes to read * @return The StorageAction corresponding to the reading */ - virtual StorageActionPtr read(surf_file_t fd, sg_size_t size)=0; + virtual StorageAction *read(surf_file_t fd, sg_size_t size)=0; /** * @brief Write a file @@ -202,7 +197,7 @@ public: * @param size The size in bytes to write * @return The StorageAction corresponding to the writing */ - virtual StorageActionPtr write(surf_file_t fd, sg_size_t size)=0; + virtual StorageAction *write(surf_file_t fd, sg_size_t size)=0; /** * @brief Get the content of the current Storage @@ -270,7 +265,7 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, + StorageAction(Model *model, double cost, bool failed, Storage *storage, e_surf_action_storage_type_t type); /** @@ -283,13 +278,13 @@ public: * @param storage The Storage associated to this StorageAction * @param type [description] */ - StorageAction(ModelPtr model, double cost, bool failed, lmm_variable_t var, - StoragePtr storage, e_surf_action_storage_type_t type); + StorageAction(Model *model, double cost, bool failed, lmm_variable_t var, + Storage *storage, e_surf_action_storage_type_t type); void setState(e_surf_action_state_t state); e_surf_action_storage_type_t m_type; - StoragePtr p_storage; + Storage *p_storage; surf_file_t p_file; double progress; }; diff --git a/src/surf/storage_n11.cpp b/src/surf/storage_n11.cpp index e1dc8f1bd3..3b914b9b55 100644 --- a/src/surf/storage_n11.cpp +++ b/src/surf/storage_n11.cpp @@ -31,7 +31,7 @@ static XBT_INLINE void routing_storage_type_free(void *r) static XBT_INLINE void surf_storage_resource_free(void *r) { // specific to storage - StoragePtr storage = static_cast(r); + Storage *storage = static_cast(r); // generic resource delete storage; } @@ -218,7 +218,7 @@ void surf_storage_model_init_default(void) } StorageN11Model::StorageN11Model() : StorageModel() { - ActionPtr action = NULL; + Action *action = NULL; XBT_DEBUG("surf_storage_model_init_internal"); @@ -234,7 +234,7 @@ StorageN11Model::~StorageN11Model(){ storage_running_action_set_that_does_not_need_being_checked = NULL; } -StoragePtr StorageN11Model::createStorage(const char* id, const char* type_id, +Storage *StorageN11Model::createStorage(const char* id, const char* type_id, const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach) { @@ -249,7 +249,7 @@ StoragePtr StorageN11Model::createStorage(const char* id, const char* type_id, double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite")); double Bconnection = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection")); - StoragePtr storage = new StorageN11(this, id, properties, p_maxminSystem, + Storage *storage = new StorageN11(this, id, properties, p_maxminSystem, Bread, Bwrite, Bconnection, type_id, (char *)content_name, xbt_strdup(content_type), storage_type->size, (char *) attach); @@ -272,9 +272,9 @@ double StorageN11Model::shareResources(double now) { XBT_DEBUG("storage_share_resources %f", now); unsigned int i, j; - StoragePtr storage; + Storage *storage; void *_write_action; - StorageActionPtr write_action; + StorageAction *write_action; double min_completion = shareResourcesMaxMin(getRunningActionSet(), p_maxminSystem, lmm_solve); @@ -287,7 +287,7 @@ double StorageN11Model::shareResources(double now) // Foreach write action on disk xbt_dynar_foreach(storage->p_writeActions, j, _write_action) { - write_action = static_cast(_write_action); + write_action = static_cast(_write_action); rate += lmm_variable_getvalue(write_action->getVariable()); } if(rate > 0) @@ -299,13 +299,13 @@ double StorageN11Model::shareResources(double now) void StorageN11Model::updateActionsState(double /*now*/, double delta) { - StorageActionPtr action = NULL; + StorageAction *action = NULL; - ActionListPtr actionSet = getRunningActionSet(); + ActionList *actionSet = getRunningActionSet(); for(ActionList::iterator it(actionSet->begin()), itNext=it, itend(actionSet->end()) ; it != itend ; it=itNext) { ++itNext; - action = static_cast(&*it); + action = static_cast(&*it); if(action->m_type == WRITE) { @@ -371,7 +371,7 @@ void StorageN11Model::updateActionsState(double /*now*/, double delta) * Resource * ************/ -StorageN11::StorageN11(StorageModelPtr model, const char* name, +StorageN11::StorageN11(StorageModel *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, char *attach) @@ -380,7 +380,7 @@ StorageN11::StorageN11(StorageModelPtr model, const char* name, XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%llu'", bconnection, bread, bwrite, size); } -StorageActionPtr StorageN11::open(const char* mount, const char* path) +StorageAction *StorageN11::open(const char* mount, const char* path) { XBT_DEBUG("\tOpen file '%s'",path); @@ -402,22 +402,22 @@ StorageActionPtr StorageN11::open(const char* mount, const char* path) file->mount = xbt_strdup(mount); file->current_position = 0; - StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN); + StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, OPEN); action->p_file = file; return action; } -StorageActionPtr StorageN11::close(surf_file_t fd) +StorageAction *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; - StorageActionPtr write_action; + StorageAction *write_action; unsigned int i; xbt_dynar_foreach(p_writeActions, i, _write_action) { - write_action = static_cast(_write_action); + write_action = static_cast(_write_action); if ((write_action->p_file) == fd) { xbt_dynar_cursor_rm(p_writeActions, &i); write_action->unref(); @@ -426,11 +426,11 @@ StorageActionPtr StorageN11::close(surf_file_t fd) free(fd->name); free(fd->mount); xbt_free(fd); - StorageActionPtr action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, CLOSE); + StorageAction *action = new StorageN11Action(getModel(), 0, getState() != SURF_RESOURCE_ON, this, CLOSE); return action; } -StorageActionPtr StorageN11::read(surf_file_t fd, sg_size_t size) +StorageAction *StorageN11::read(surf_file_t fd, sg_size_t size) { if(fd->current_position + size > fd->size){ size = fd->size - fd->current_position; @@ -439,16 +439,16 @@ StorageActionPtr StorageN11::read(surf_file_t fd, sg_size_t size) else fd->current_position += size; - StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, READ); + StorageAction *action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, READ); return action; } -StorageActionPtr StorageN11::write(surf_file_t fd, sg_size_t size) +StorageAction *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); - StorageActionPtr action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE); + StorageAction *action = new StorageN11Action(getModel(), size, getState() != SURF_RESOURCE_ON, this, WRITE); action->p_file = fd; /* Substract the part of the file that might disappear from the used sized on * the storage element */ @@ -464,7 +464,7 @@ StorageActionPtr StorageN11::write(surf_file_t fd, sg_size_t size) * Action * **********/ -StorageN11Action::StorageN11Action(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type) +StorageN11Action::StorageN11Action(Model *model, double cost, bool failed, Storage *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) { @@ -486,7 +486,7 @@ StorageN11Action::StorageN11Action(ModelPtr model, double cost, bool failed, Sto getVariable(), 1.0); //TODO there is something annoying with what's below. Have to sort it out... -// ActionPtr action = this; +// Action *action = this; // xbt_dynar_push(storage->p_writeActions, &action); // ref(); break; diff --git a/src/surf/storage_n11.hpp b/src/surf/storage_n11.hpp index 2ec11237f6..a65620ac64 100644 --- a/src/surf/storage_n11.hpp +++ b/src/surf/storage_n11.hpp @@ -14,20 +14,8 @@ ***********/ class StorageN11Model; -typedef StorageN11Model *StorageN11ModelPtr; - -class StorageN11; -typedef StorageN11 *StorageN11Ptr; - class StorageN11; -typedef StorageN11 *StorageN11Ptr; - class StorageN11Action; -typedef StorageN11Action *StorageN11ActionPtr; - -class StorageN11Action; -typedef StorageN11Action *StorageN11ActionPtr; - /********* * Model * @@ -37,7 +25,7 @@ class StorageN11Model : public StorageModel { public: StorageN11Model(); ~StorageN11Model(); - StoragePtr createStorage(const char* id, const char* type_id, + Storage *createStorage(const char* id, const char* type_id, const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach); void addTraces(){DIE_IMPOSSIBLE;} double shareResources(double now); @@ -50,15 +38,15 @@ public: class StorageN11 : public Storage { public: - StorageN11(StorageModelPtr model, const char* name, xbt_dict_t properties, + StorageN11(StorageModel *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, char *attach); - StorageActionPtr open(const char* mount, const char* path); - StorageActionPtr close(surf_file_t fd); - StorageActionPtr ls(const char *path); - StorageActionPtr read(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param ptr ?? - StorageActionPtr write(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param ptr ?? + StorageAction *open(const char* mount, const char* path); + StorageAction *close(surf_file_t fd); + StorageAction *ls(const char *path); + StorageAction *read(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param *?? + StorageAction *write(surf_file_t fd, sg_size_t size);//FIXME:why we have a useless param *?? void rename(const char *src, const char *dest); lmm_constraint_t p_constraintWrite; /* Constraint for maximum write bandwidth*/ @@ -71,7 +59,7 @@ public: class StorageN11Action : public StorageAction { public: - StorageN11Action(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type); + StorageN11Action(Model *model, double cost, bool failed, Storage *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 50f59b4c92..7d3554ec3a 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -18,12 +18,12 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel); * TOOLS * *********/ -static HostPtr get_casted_host(surf_resource_t resource){ - return static_cast(surf_host_resource_priv(resource)); +static Host *get_casted_host(surf_resource_t resource){ + return static_cast(surf_host_resource_priv(resource)); } -static VMPtr get_casted_vm(surf_resource_t resource){ - return static_cast(surf_host_resource_priv(resource)); +static VM *get_casted_vm(surf_resource_t resource){ + return static_cast(surf_host_resource_priv(resource)); } char *surf_routing_edge_name(sg_routing_edge_t edge){ @@ -40,8 +40,8 @@ void surf_presolve(void) double next_event_date = -1.0; tmgr_trace_event_t event = NULL; double value = -1.0; - ResourcePtr resource = NULL; - ModelPtr model = NULL; + Resource *resource = NULL; + Model *model = NULL; unsigned int iter; XBT_DEBUG @@ -98,8 +98,8 @@ double surf_solve(double max_date) double next_event_date = -1.0; double model_next_action_end = -1.0; double value = -1.0; - ResourcePtr resource = NULL; - ModelPtr model = NULL; + Resource *resource = NULL; + Model *model = NULL; tmgr_trace_event_t event = NULL; unsigned int iter; @@ -119,7 +119,7 @@ double surf_solve(double max_date) /* sequential version */ xbt_dynar_foreach(model_list_invoke, iter, model) { - surf_share_resources(static_cast(model)); + surf_share_resources(static_cast(model)); } unsigned i; @@ -215,16 +215,16 @@ void routing_get_route_and_latency(sg_routing_edge_t src, sg_routing_edge_t dst, surf_model_t surf_resource_model(const void *host, int level) { /* If level is SURF_WKS_LEVEL, ws is a host_CLM03 object. It has * surf_resource at the generic_resource field. */ - ResourcePtr ws = static_cast(xbt_lib_get_level((xbt_dictelm_t) host, level)); + Resource *ws = static_cast(xbt_lib_get_level((xbt_dictelm_t) host, level)); return ws->getModel(); } void *surf_as_cluster_get_backbone(AS_t as){ - return static_cast(as)->p_backbone; + return static_cast(as)->p_backbone; } void surf_as_cluster_set_backbone(AS_t as, void* backbone){ - static_cast(as)->p_backbone = static_cast(backbone); + static_cast(as)->p_backbone = static_cast(backbone); } const char *surf_model_name(surf_model_t model){ @@ -273,7 +273,7 @@ surf_action_t surf_host_model_execute_parallel_task(surf_host_model_t model, double *flops_amount, double *bytes_amount, double rate){ - return static_cast(model->executeParallelTask(host_nb, host_list, flops_amount, bytes_amount, rate)); + return static_cast(model->executeParallelTask(host_nb, host_list, flops_amount, bytes_amount, rate)); } surf_action_t surf_host_model_communicate(surf_host_model_t model, surf_resource_t src, surf_resource_t dst, double size, double rate){ @@ -352,18 +352,18 @@ int surf_host_get_pstate(surf_resource_t resource){ } double surf_host_get_wattmin_at(surf_resource_t resource, int pstate){ xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); - std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); + std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); return cpuIt->second->getWattMinAt(pstate); } double surf_host_get_wattmax_at(surf_resource_t resource, int pstate){ xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); - std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); + std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); return cpuIt->second->getWattMaxAt(pstate); } double surf_host_get_consumed_energy(surf_resource_t resource){ xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization."); - std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); + std::map::iterator cpuIt = surf_energy->find(get_casted_host(resource)->p_cpu); return cpuIt->second->getConsumedEnergy(); } @@ -420,7 +420,7 @@ xbt_dynar_t surf_host_get_vms(surf_resource_t host){ xbt_dynar_t vms = get_casted_host(host)->getVms(); xbt_dynar_t vms_ = xbt_dynar_new(sizeof(sg_host_t), NULL); unsigned int cpt; - VMPtr vm; + VM *vm; xbt_dynar_foreach(vms, cpt, vm) { sg_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName()); xbt_dynar_push(vms_, &vm_); @@ -439,7 +439,7 @@ void surf_host_set_params(surf_resource_t host, ws_params_t params){ void surf_vm_destroy(surf_resource_t resource){ /* Before clearing the entries in host_lib, we have to pick up resources. */ - VMPtr vm = get_casted_vm(resource); + VM *vm = get_casted_vm(resource); char* name = xbt_dict_get_elm_key(resource); /* We deregister objects from host_lib, without invoking the freeing callback * of each level. @@ -490,23 +490,23 @@ void surf_vm_set_affinity(surf_resource_t vm, surf_resource_t cpu, unsigned long } xbt_dict_t surf_storage_get_content(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getContent(); + return static_cast(surf_storage_resource_priv(resource))->getContent(); } sg_size_t surf_storage_get_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getSize(); + return static_cast(surf_storage_resource_priv(resource))->getSize(); } sg_size_t surf_storage_get_free_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getFreeSize(); + return static_cast(surf_storage_resource_priv(resource))->getFreeSize(); } sg_size_t surf_storage_get_used_size(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->getUsedSize(); + return static_cast(surf_storage_resource_priv(resource))->getUsedSize(); } const char* surf_storage_get_host(surf_resource_t resource){ - return static_cast(surf_storage_resource_priv(resource))->p_attach; + return static_cast(surf_storage_resource_priv(resource))->p_attach; } surf_action_t surf_cpu_execute(surf_resource_t cpu, double size){ @@ -570,11 +570,11 @@ double surf_action_get_cost(surf_action_t action){ } void surf_cpu_action_set_affinity(surf_action_t action, surf_resource_t cpu, unsigned long mask) { - static_cast(action)->setAffinity(sg_host_surfcpu(cpu), mask); + static_cast(action)->setAffinity(sg_host_surfcpu(cpu), mask); } void surf_cpu_action_set_bound(surf_action_t action, double bound) { - static_cast(action)->setBound(bound); + static_cast(action)->setBound(bound); } #ifdef HAVE_LATENCY_BOUND_TRACKING @@ -584,5 +584,5 @@ double surf_network_action_get_latency_limited(surf_action_t action) { #endif surf_file_t surf_storage_action_get_file(surf_action_t action){ - return static_cast(action)->p_file; + return static_cast(action)->p_file; } diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 0399c01a45..0124e39ea8 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -367,12 +367,12 @@ static XBT_INLINE void surf_link_free(void *r) static XBT_INLINE void surf_host_free(void *r) { - delete static_cast(r); + delete static_cast(r); } static XBT_INLINE void surf_storage_free(void *r) { - delete static_cast(r); + delete static_cast(r); } @@ -403,9 +403,9 @@ void surf_init(int *argc, char **argv) xbt_init(argc, argv); if (!model_list) - model_list = xbt_dynar_new(sizeof(ModelPtr), NULL); + model_list = xbt_dynar_new(sizeof(Model*), NULL); if (!model_list_invoke) - model_list_invoke = xbt_dynar_new(sizeof(ModelPtr), NULL); + model_list_invoke = xbt_dynar_new(sizeof(Model*), NULL); if (!history) history = tmgr_history_new(); @@ -421,7 +421,7 @@ void surf_init(int *argc, char **argv) void surf_exit(void) { unsigned int iter; - ModelPtr model = NULL; + Model *model = NULL; TRACE_end(); /* Just in case it was not called by the upper * layer (or there is no upper layer) */ @@ -509,7 +509,7 @@ double Model::shareResources(double now) double Model::shareResourcesLazy(double now) { - ActionPtr action = NULL; + Action *action = NULL; double min = -1; double share; @@ -588,11 +588,11 @@ double Model::shareResourcesFull(double /*now*/) { THROW_UNIMPLEMENTED; } -double Model::shareResourcesMaxMin(ActionListPtr running_actions, +double Model::shareResourcesMaxMin(ActionList *running_actions, lmm_system_t sys, void (*solve) (lmm_system_t)) { - ActionPtr action = NULL; + Action *action = NULL; double min = -1; double value = -1; @@ -671,17 +671,17 @@ Resource::Resource() : p_name(NULL), p_properties(NULL), p_model(NULL) {} -Resource::Resource(ModelPtr model, const char *name, xbt_dict_t props) +Resource::Resource(Model *model, const char *name, xbt_dict_t props) : p_name(xbt_strdup(name)), p_properties(props), p_model(model) , m_running(true), m_stateCurrent(SURF_RESOURCE_ON) {} -Resource::Resource(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint) +Resource::Resource(Model *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(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit) +Resource::Resource(Model *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) {} @@ -720,7 +720,7 @@ void Resource::turnOff() } } -ModelPtr Resource::getModel() { +Model *Resource::getModel() { return p_model; } @@ -751,7 +751,7 @@ const char *surf_action_state_names[6] = { "SURF_ACTION_NOT_IN_THE_SYSTEM" }; -void Action::initialize(ModelPtr model, double cost, bool failed, +void Action::initialize(Model *model, double cost, bool failed, lmm_variable_t var) { m_priority = 1.0; @@ -771,7 +771,7 @@ void Action::initialize(ModelPtr model, double cost, bool failed, m_hat = NOTSET; } -Action::Action(ModelPtr model, double cost, bool failed) +Action::Action(Model *model, double cost, bool failed) { initialize(model, cost, failed); p_category = NULL; @@ -785,7 +785,7 @@ Action::Action(ModelPtr model, double cost, bool failed) p_stateSet->push_back(*this); } -Action::Action(ModelPtr model, double cost, bool failed, lmm_variable_t var) +Action::Action(Model *model, double cost, bool failed, lmm_variable_t var) { initialize(model, cost, failed, var); p_category = NULL; @@ -995,7 +995,7 @@ void Action::heapUpdate(xbt_heap_t heap, double key, enum heap_action_type hat) /* added to manage the communication action's heap */ void surf_action_lmm_update_index_heap(void *action, int i) { - ((ActionPtr)action)->updateIndexHeap(i); + static_cast(action)->updateIndexHeap(i); } void Action::updateIndexHeap(int i) { @@ -1044,7 +1044,7 @@ void Action::updateRemainingLazy(double now) double_update(&m_remains, m_lastValue * delta, sg_surf_precision*sg_maxmin_precision); if (getModel() == surf_cpu_model_pm && TRACE_is_enabled()) { - ResourcePtr cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); + Resource *cpu = static_cast(lmm_constraint_id(lmm_get_cnst_from_var(getModel()->getMaxminSystem(), getVariable(), 0))); TRACE_surf_host_set_utilization(cpu->getName(), getCategory(), m_lastValue, m_lastUpdate, now - m_lastUpdate); } XBT_DEBUG("Updating action(%p): remains is now %f", this, m_remains); diff --git a/src/surf/surf_interface.hpp b/src/surf/surf_interface.hpp index 95ac8a6ec7..62e74e153c 100644 --- a/src/surf/surf_interface.hpp +++ b/src/surf/surf_interface.hpp @@ -68,15 +68,6 @@ int __surf_is_absolute_file_path(const char *file_path); /*********** * Classes * ***********/ -//class Model; -typedef Model* ModelPtr; - -//class Resource; -typedef Resource* ResourcePtr; - -//class Action; -typedef Action* ActionPtr; - typedef boost::intrusive::list ActionList; typedef ActionList* ActionListPtr; typedef boost::intrusive::list_base_hook<> actionHook; @@ -267,7 +258,7 @@ public: * @param name The name of the Resource * @param props Dictionary of properties associated to this Resource */ - Resource(ModelPtr model, const char *name, xbt_dict_t props); + Resource(Model *model, const char *name, xbt_dict_t props); /** * @brief Resource constructor @@ -277,7 +268,7 @@ public: * @param props Dictionary of properties associated to this Resource * @param constraint The lmm constraint associated to this Resource if it is part of a LMM component */ - Resource(ModelPtr model, const char *name, xbt_dict_t props, lmm_constraint_t constraint); + Resource(Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint); /** * @brief Resource constructor * @@ -286,7 +277,7 @@ public: * @param props Dictionary of properties associated to this Resource * @param stateInit the initial state of the Resource */ - Resource(ModelPtr model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit); + Resource(Model *model, const char *name, xbt_dict_t props, e_surf_resource_state_t stateInit); /** * @brief Resource destructor @@ -298,7 +289,7 @@ public: * * @return The Model of the current Resource */ - ModelPtr getModel(); + Model *getModel(); /** * @brief Get the name of the current Resource @@ -364,7 +355,7 @@ public: private: const char *p_name; xbt_dict_t p_properties; - ModelPtr p_model; + Model *p_model; bool m_running; e_surf_resource_state_t m_stateCurrent; @@ -394,7 +385,7 @@ private: /** * @brief Common initializations for the constructors */ - void initialize(ModelPtr model, double cost, bool failed, + void initialize(Model *model, double cost, bool failed, lmm_variable_t var = NULL); public: @@ -405,7 +396,7 @@ public: * @param cost The cost of the Action * @param failed If the action is impossible (e.g.: execute something on a switched off host) */ - Action(ModelPtr model, double cost, bool failed); + Action(Model *model, double cost, bool failed); /** * @brief Action constructor @@ -415,7 +406,7 @@ public: * @param failed If the action is impossible (e.g.: execute something on a switched off host) * @param var The lmm variable associated to this Action if it is part of a LMM component */ - Action(ModelPtr model, double cost, bool failed, lmm_variable_t var); + Action(Model *model, double cost, bool failed, lmm_variable_t var); /** * @brief Action destructor @@ -630,7 +621,7 @@ public: s_xbt_swag_hookup_t p_stateHookup; - ModelPtr getModel() {return p_model;} + Model *getModel() {return p_model;} protected: ActionListPtr p_stateSet; @@ -649,7 +640,7 @@ private: int m_latencyLimited; /**< Set to 1 if is limited by latency, 0 otherwise */ #endif double m_cost; - ModelPtr p_model; + Model *p_model; void *p_data; /**< for your convenience */ /* LMM */ diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 1446b55f1d..dbde9520ff 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -46,17 +46,17 @@ static xbt_dict_t random_value = NULL; * * Routing edges are either host and routers, whatever */ -RoutingEdgePtr sg_routing_edge_by_name_or_null(const char *name) { +RoutingEdge *sg_routing_edge_by_name_or_null(const char *name) { sg_host_t h = sg_host_by_name(name); - RoutingEdgePtr net_elm = h==NULL?NULL: sg_host_edge(h); + RoutingEdge *net_elm = h==NULL?NULL: sg_host_edge(h); if (!net_elm) - net_elm = (RoutingEdgePtr) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL); + net_elm = (RoutingEdge*) xbt_lib_get_or_null(as_router_lib, name, ROUTING_ASR_LEVEL); return net_elm; } /* Global vars */ -RoutingPlatfPtr routing_platf = NULL; -AsPtr current_routing = NULL; +RoutingPlatf *routing_platf = NULL; +As *current_routing = NULL; /* global parse functions */ extern xbt_dynar_t mount_list; @@ -112,7 +112,7 @@ struct s_model_type routing_models[] = { */ static void parse_S_host_link(sg_platf_host_link_cbarg_t host) { - RoutingEdgePtr info = sg_host_edge(sg_host_by_name(host->id)); + RoutingEdge *info = sg_host_edge(sg_host_by_name(host->id)); xbt_assert(info, "Host '%s' not found!", host->id); xbt_assert(current_routing->p_modelDesc == &routing_models[SURF_MODEL_CLUSTER] || current_routing->p_modelDesc == &routing_models[SURF_MODEL_VIVALDI], @@ -147,7 +147,7 @@ static void parse_S_host(sg_platf_host_cbarg_t host) xbt_assert(!sg_host_by_name(host->id), "Reading a host, processing unit \"%s\" already exists", host->id); - RoutingEdgePtr info = new RoutingEdgeImpl(xbt_strdup(host->id), + RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(host->id), -1, SURF_NETWORK_ELEMENT_HOST, current_routing); @@ -191,7 +191,7 @@ static void parse_S_router(sg_platf_router_cbarg_t router) "Reading a router, processing unit \"%s\" already exists", router->id); - RoutingEdgePtr info = new RoutingEdgeImpl(xbt_strdup(router->id), + RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(router->id), -1, SURF_NETWORK_ELEMENT_ROUTER, current_routing); @@ -361,13 +361,13 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) } /* make a new routing component */ - AsPtr new_as = model->create(); + As *new_as = model->create(); new_as->p_modelDesc = model; new_as->p_hierarchy = SURF_ROUTING_NULL; new_as->p_name = xbt_strdup(AS->id); - RoutingEdgePtr info = new RoutingEdgeImpl(xbt_strdup(new_as->p_name), + RoutingEdge *info = new RoutingEdgeImpl(xbt_strdup(new_as->p_name), -1, SURF_NETWORK_ELEMENT_AS, current_routing); @@ -447,15 +447,15 @@ static void elements_father(sg_routing_edge_t src, sg_routing_edge_t dst, { xbt_assert(src && dst, "bad parameters for \"elements_father\" method"); #define ELEMENTS_FATHER_MAXDEPTH 16 /* increase if it is not enough */ - AsPtr src_as, dst_as; - AsPtr path_src[ELEMENTS_FATHER_MAXDEPTH]; - AsPtr path_dst[ELEMENTS_FATHER_MAXDEPTH]; + As *src_as, *dst_as; + As *path_src[ELEMENTS_FATHER_MAXDEPTH]; + As *path_dst[ELEMENTS_FATHER_MAXDEPTH]; int index_src = 0; int index_dst = 0; - AsPtr current; - AsPtr current_src; - AsPtr current_dst; - AsPtr father; + As *current; + As *current_src; + As *current_dst; + As *father; /* (1) find the as where the src and dst are located */ sg_routing_edge_t src_data = src; @@ -515,7 +515,7 @@ static void elements_father(sg_routing_edge_t src, sg_routing_edge_t dst, * This function is called by "get_route" and "get_latency". It allows to walk * recursively through the ASes tree. */ -static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst, +static void _get_route_and_latency(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t * links, double *latency) { s_sg_platf_route_cbarg_t route; @@ -525,7 +525,7 @@ static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst, XBT_DEBUG("Solve route/latency \"%s\" to \"%s\"", src->getName(), dst->getName()); /* Find how src and dst are interconnected */ - AsPtr common_father, src_father, dst_father; + As *common_father, *src_father, *dst_father; elements_father(src, dst, &common_father, &src_father, &dst_father); XBT_DEBUG("elements_father: common father '%s' src_father '%s' dst_father '%s'", common_father->p_name, src_father->p_name, dst_father->p_name); @@ -555,8 +555,8 @@ static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst, route.link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); // Find the net_card corresponding to father - RoutingEdgePtr src_father_net_elm = src_father->p_netElem; - RoutingEdgePtr dst_father_net_elm = dst_father->p_netElem; + RoutingEdge *src_father_net_elm = src_father->p_netElem; + RoutingEdge *dst_father_net_elm = dst_father->p_netElem; common_father->getRouteAndLatency(src_father_net_elm, dst_father_net_elm, &route, latency); @@ -602,7 +602,7 @@ e_surf_network_element_type_t surf_routing_edge_get_rc_type(sg_routing_edge_t ed * walk through the routing components tree and find a route between hosts * by calling the differents "get_route" functions in each routing component. */ -void RoutingPlatf::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, +void RoutingPlatf::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t* route, double *latency) { XBT_DEBUG("routing_get_route_and_latency from %s to %s", src->getName(), dst->getName()); @@ -621,9 +621,9 @@ xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ return recursiveGetOneLinkRoutes(p_root); } -xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(AsPtr rc) +xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(As *rc) { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); + xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); //adding my one link routes xbt_dynar_t onelink_mine = rc->getOneLinkRoutes(); @@ -644,7 +644,7 @@ xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(AsPtr rc) e_surf_network_element_type_t routing_get_network_element_type(const char *name) { - RoutingEdgePtr rc = sg_routing_edge_by_name_or_null(name); + RoutingEdge *rc = sg_routing_edge_by_name_or_null(name); if (rc) return rc->getRcType(); @@ -827,7 +827,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) XBT_DEBUG("", cluster->id); AS.routing = A_surfxml_AS_routing_Cluster___torus; sg_platf_new_AS_begin(&AS); - ((AsClusterTorusPtr)current_routing)->parse_specific_arguments(cluster); + ((AsClusterTorus*)current_routing)->parse_specific_arguments(cluster); } else if (cluster->topology == SURF_CLUSTER_FAT_TREE) { XBT_DEBUG("", cluster->id); @@ -843,13 +843,13 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) } if(cluster->loopback_bw!=0 || cluster->loopback_lat!=0){ - ((AsClusterPtr)current_routing)->p_nb_links_per_node++; - ((AsClusterPtr)current_routing)->p_has_loopback=1; + ((AsCluster*)current_routing)->p_nb_links_per_node++; + ((AsCluster*)current_routing)->p_has_loopback=1; } if(cluster->limiter_link!=0){ - ((AsClusterPtr)current_routing)->p_nb_links_per_node++; - ((AsClusterPtr)current_routing)->p_has_limiter=1; + ((AsCluster*)current_routing)->p_nb_links_per_node++; + ((AsCluster*)current_routing)->p_has_limiter=1; } @@ -954,7 +954,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) info_loop.link_up = Link::byName(tmp_link); info_loop.link_down = info_loop.link_up; free(tmp_link); - xbt_dynar_set(current_routing->p_linkUpDownList, rankId*((AsClusterPtr)current_routing)->p_nb_links_per_node, &info_loop); + xbt_dynar_set(current_routing->p_linkUpDownList, rankId*(static_cast(current_routing))->p_nb_links_per_node, &info_loop); } //add a limiter link (shared link to account for maximal bandwidth of the node) @@ -975,7 +975,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) info_lim.link_down = info_lim.link_up; free(tmp_link); xbt_dynar_set(current_routing->p_linkUpDownList, - rankId*((AsClusterPtr)current_routing)->p_nb_links_per_node + ((AsClusterPtr)current_routing)->p_has_loopback , + rankId*(static_cast(current_routing))->p_nb_links_per_node + static_cast(current_routing)->p_has_loopback , &info_lim); } @@ -986,10 +986,10 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) ((AsClusterFatTree*) current_routing)->addProcessingNode(i); } else { - ((AsClusterPtr)current_routing)->create_links_for_node(cluster, i, rankId, rankId* - ((AsClusterPtr)current_routing)->p_nb_links_per_node - + ((AsClusterPtr)current_routing)->p_has_loopback - + ((AsClusterPtr)current_routing)->p_has_limiter ); + static_cast(current_routing)->create_links_for_node(cluster, i, rankId, rankId* + static_cast(current_routing)->p_nb_links_per_node + + static_cast(current_routing)->p_has_loopback + + static_cast(current_routing)->p_has_limiter ); } xbt_free(link_id); xbt_free(host_id); @@ -1002,7 +1002,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) // For fat trees, the links must be created once all nodes have been added if(cluster->topology == SURF_CLUSTER_FAT_TREE) { - ((AsClusterFatTree*)current_routing)->create_links(); + static_cast(current_routing)->create_links(); } // Add a router. It is magically used thanks to the way in which surf_routing_cluster is written, // and it's very useful to connect clusters together @@ -1018,7 +1018,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix); sg_platf_new_router(&router); - ((AsClusterPtr)current_routing)->p_router = (RoutingEdgePtr) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL); + ((AsCluster*)current_routing)->p_router = (RoutingEdge*) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL); free(newid); //Make the backbone @@ -1121,7 +1121,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) router.id = router_id; router.coord = peer->coord; sg_platf_new_router(&router); - static_cast(current_routing)->p_router = static_cast(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL)); + static_cast(current_routing)->p_router = static_cast(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL)); XBT_DEBUG(""); sg_platf_new_AS_end(); @@ -1260,10 +1260,10 @@ static void check_disk_attachment() xbt_lib_cursor_t cursor; char *key; void **data; - RoutingEdgePtr host_elm; + RoutingEdge *host_elm; xbt_lib_foreach(storage_lib, cursor, key, data) { if(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL) != NULL) { - StoragePtr storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); + Storage *storage = static_cast(xbt_lib_get_level(xbt_lib_get_elm_or_null(storage_lib, key), SURF_STORAGE_LEVEL)); host_elm = sg_routing_edge_by_name_or_null(storage->p_attach); if(!host_elm) surf_parse_error("Unable to attach storage %s: host %s doesn't exist.", storage->getName(), storage->p_attach); @@ -1306,7 +1306,7 @@ void routing_register_callbacks() * This fuction is call by "finalize". It allow to finalize the * AS or routing components. It delete all the structures. */ -static void finalize_rec(AsPtr as) { +static void finalize_rec(As *as) { xbt_dict_cursor_t cursor = NULL; char *key; AS_t elem; @@ -1333,15 +1333,15 @@ AS_t surf_AS_get_routing_root() { return routing_platf->p_root; } -const char *surf_AS_get_name(AsPtr as) { +const char *surf_AS_get_name(As *as) { return as->p_name; } -static AsPtr surf_AS_recursive_get_by_name(AsPtr current, const char * name) { +static As *surf_AS_recursive_get_by_name(As *current, const char * name) { xbt_dict_cursor_t cursor = NULL; char *key; AS_t elem; - AsPtr tmp = NULL; + As *tmp = NULL; if(!strcmp(current->p_name, name)) return current; @@ -1356,22 +1356,22 @@ static AsPtr surf_AS_recursive_get_by_name(AsPtr current, const char * name) { } -AsPtr surf_AS_get_by_name(const char * name) { - AsPtr as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); +As *surf_AS_get_by_name(const char * name) { + As *as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); if(as == NULL) XBT_WARN("Impossible to find an AS with name %s, please check your input", name); return as; } -xbt_dict_t surf_AS_get_routing_sons(AsPtr as) { +xbt_dict_t surf_AS_get_routing_sons(As *as) { return as->p_routingSons; } -const char *surf_AS_get_model(AsPtr as) { +const char *surf_AS_get_model(As *as) { return as->p_modelDesc->name; } -xbt_dynar_t surf_AS_get_hosts(AsPtr as) { +xbt_dynar_t surf_AS_get_hosts(As *as) { xbt_dynar_t elms = as->p_indexNetworkElm; sg_routing_edge_t relm; xbt_dictelm_t delm; @@ -1379,7 +1379,7 @@ xbt_dynar_t surf_AS_get_hosts(AsPtr as) { int count = xbt_dynar_length(elms); xbt_dynar_t res = xbt_dynar_new(sizeof(xbt_dictelm_t), NULL); for (index = 0; index < count; index++) { - relm = xbt_dynar_get_as(elms, index, RoutingEdgePtr); + relm = xbt_dynar_get_as(elms, index, RoutingEdge*); delm = xbt_lib_get_elm_or_null(host_lib, relm->getName()); if (delm!=NULL) { xbt_dynar_push(res, &delm); diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index 0980e57849..6877e4c958 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -21,34 +21,25 @@ xbt_edge_t new_xbt_graph_edge (xbt_graph_t graph, xbt_node_t s, xbt_node_t d, xb * Classes * ***********/ -/* Note: As and RoutingEdge are declared as struct instead of class, to keep - compatibility with C files where they are mentioned. */ -struct As; -typedef As *AsPtr; - +class As; class RoutingModelDescription; -typedef RoutingModelDescription *RoutingModelDescriptionPtr; - class Onelink; -typedef Onelink *OnelinkPtr; - class RoutingPlatf; -typedef RoutingPlatf *RoutingPlatfPtr; /** @ingroup SURF_routing_interface * @brief The Autonomous System (AS) routing interface * @details [TODO] */ -struct As { +class As { public: xbt_dynar_t p_indexNetworkElm; xbt_dict_t p_bypassRoutes; /* store bypass routes */ routing_model_description_t p_modelDesc; e_surf_routing_hierarchy_t p_hierarchy; char *p_name; - AsPtr p_routingFather; + As *p_routingFather; xbt_dict_t p_routingSons; - RoutingEdgePtr p_netElem; + RoutingEdge *p_netElem; xbt_dynar_t p_linkUpDownList; /** @@ -72,17 +63,17 @@ public: * @param into [description] * @param latency [description] */ - virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0; + virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency)=0; virtual xbt_dynar_t getOneLinkRoutes()=0; virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0; - virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat)=0; + virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat)=0; /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */ - virtual int parseAS( RoutingEdgePtr elm)=0; + virtual int parsePU(RoutingEdge *elm)=0; /* A host or a router, whatever */ + virtual int parseAS( RoutingEdge *elm)=0; virtual void parseRoute(sg_platf_route_cbarg_t route)=0; virtual void parseASroute(sg_platf_route_cbarg_t route)=0; virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0; @@ -99,13 +90,13 @@ public: virtual int *getIdPtr()=0; virtual void setId(int id)=0; virtual char *getName()=0; - virtual AsPtr getRcComponent()=0; + virtual As *getRcComponent()=0; virtual e_surf_network_element_type_t getRcType()=0; }; struct RoutingEdgeImpl : public RoutingEdge { public: - RoutingEdgeImpl(char *name, int id, e_surf_network_element_type_t rcType, AsPtr rcComponent) + RoutingEdgeImpl(char *name, int id, e_surf_network_element_type_t rcType, As *rcComponent) : p_rcComponent(rcComponent), p_rcType(rcType), m_id(id), p_name(name) {} ~RoutingEdgeImpl() { xbt_free(p_name);}; @@ -113,10 +104,10 @@ public: int *getIdPtr() {return &m_id;} void setId(int id) {m_id = id;} char *getName() {return p_name;} - AsPtr getRcComponent() {return p_rcComponent;} + As *getRcComponent() {return p_rcComponent;} e_surf_network_element_type_t getRcType() {return p_rcType;} private: - AsPtr p_rcComponent; + As *p_rcComponent; e_surf_network_element_type_t p_rcType; int m_id; char *p_name; @@ -130,7 +121,7 @@ public: int *getIdPtr() {return p_re->getIdPtr();} void setId(int id) {p_re->setId(id);} char *getName() {return p_re->getName();} - AsPtr getRcComponent() {return p_re->getRcComponent();} + As *getRcComponent() {return p_re->getRcComponent();} e_surf_network_element_type_t getRcType() {return p_re->getRcType();} private: RoutingEdge *p_re; @@ -141,10 +132,10 @@ private: */ class Onelink { public: - Onelink(void *link, RoutingEdgePtr src, RoutingEdgePtr dst) + Onelink(void *link, RoutingEdge *src, RoutingEdge *dst) : p_src(src), p_dst(dst), p_link(link) {}; - RoutingEdgePtr p_src; - RoutingEdgePtr p_dst; + RoutingEdge *p_src; + RoutingEdge *p_dst; void *p_link; }; @@ -154,12 +145,12 @@ public: XBT_PUBLIC_CLASS RoutingPlatf { public: ~RoutingPlatf(); - AsPtr p_root; + As *p_root; void *p_loopback; xbt_dynar_t p_lastRoute; xbt_dynar_t getOneLinkRoutes(void); - xbt_dynar_t recursiveGetOneLinkRoutes(AsPtr rc); - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t * links, double *latency); + xbt_dynar_t recursiveGetOneLinkRoutes(As *rc); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, xbt_dynar_t * links, double *latency); }; #endif /* NETWORK_ROUTING_HPP_ */ diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index c928779d07..5a0dab91e0 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -29,7 +29,7 @@ AsCluster::AsCluster() : AsNone() } /* Business methods */ -void AsCluster::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat) +void AsCluster::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat) { s_surf_parsing_link_up_down_t info; XBT_VERB("cluster_get_route_and_latency from '%s'[%d] to '%s'[%d]", @@ -61,7 +61,7 @@ void AsCluster::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_pl } if (p_backbone) { - xbt_dynar_push_as(route->link_list, void *, static_cast(p_backbone)); + xbt_dynar_push_as(route->link_list, void *, static_cast(p_backbone)); if (lat) *lat += p_backbone->getLatency(); } @@ -86,7 +86,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) int isrc; int table_size = xbt_dynar_length(p_indexNetworkElm); - RoutingEdgePtr src; + RoutingEdge *src; xbt_node_t current, previous, backboneNode = NULL, routerNode; s_surf_parsing_link_up_down_t info; @@ -104,7 +104,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } for (isrc = 0; isrc < table_size; isrc++) { - src = xbt_dynar_get_as(p_indexNetworkElm, isrc, RoutingEdgePtr); + src = xbt_dynar_get_as(p_indexNetworkElm, isrc, RoutingEdge*); if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { previous = new_xbt_graph_node(graph, src->getName(), nodes); @@ -113,7 +113,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) if (info.link_up) { // link up - const char *link_name = static_cast(info.link_up)->getName(); + const char *link_name = static_cast(info.link_up)->getName(); current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); @@ -126,7 +126,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } if (info.link_down) { // link down - const char *link_name = static_cast(info.link_down)->getName(); + const char *link_name = static_cast(info.link_down)->getName(); current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); @@ -169,15 +169,15 @@ void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, xbt_free(link_id); } -int AsCluster::parsePU(RoutingEdgePtr elm) { +int AsCluster::parsePU(RoutingEdge *elm) { XBT_DEBUG("Load process unit \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); return xbt_dynar_length(p_indexNetworkElm)-1; } -int AsCluster::parseAS(RoutingEdgePtr elm) { +int AsCluster::parseAS(RoutingEdge *elm) { XBT_DEBUG("Load Autonomous system \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); return xbt_dynar_length(p_indexNetworkElm)-1; } diff --git a/src/surf/surf_routing_cluster.hpp b/src/surf/surf_routing_cluster.hpp index da24d6a21a..f87953ed72 100644 --- a/src/surf/surf_routing_cluster.hpp +++ b/src/surf/surf_routing_cluster.hpp @@ -14,7 +14,6 @@ * Classes * ***********/ class AsCluster; -typedef AsCluster *AsClusterPtr; /* ************************************************** */ @@ -24,24 +23,24 @@ class AsCluster: public AsNone { public: AsCluster(); - virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); //xbt_dynar_t getOneLinkRoutes(); //void parseRoute(sg_platf_route_cbarg_t route); //void parseASroute(sg_platf_route_cbarg_t route); void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + //sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */ - int parseAS(RoutingEdgePtr elm); + int parsePU(RoutingEdge *elm); /* A host or a router, whatever */ + int parseAS(RoutingEdge *elm); virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position); Link* p_backbone; void *p_loopback; - RoutingEdgePtr p_router; + RoutingEdge *p_router; int p_has_limiter; int p_has_loopback; int p_nb_links_per_node; diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 7e558774b0..fc58a79e8b 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -47,8 +47,8 @@ bool AsClusterFatTree::isInSubTree(FatTreeNode *root, FatTreeNode *node) { return true; } -void AsClusterFatTree::getRouteAndLatency(RoutingEdgePtr src, - RoutingEdgePtr dst, +void AsClusterFatTree::getRouteAndLatency(RoutingEdge *src, + RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency) { FatTreeNode *source, *destination, *currentNode; diff --git a/src/surf/surf_routing_cluster_fat_tree.hpp b/src/surf/surf_routing_cluster_fat_tree.hpp index 1b3c460ab8..9435ca91c0 100644 --- a/src/surf/surf_routing_cluster_fat_tree.hpp +++ b/src/surf/surf_routing_cluster_fat_tree.hpp @@ -111,7 +111,7 @@ class AsClusterFatTree : public AsCluster { public: AsClusterFatTree(); ~AsClusterFatTree(); - virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, + virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 9377aa273a..d6a33a5167 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -118,7 +118,7 @@ void AsClusterTorus::parse_specific_arguments(sg_platf_cluster_cbarg_t cluster){ xbt_dynar_free(&dimensions); } -void AsClusterTorus::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat){ +void AsClusterTorus::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat){ XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]", src->getName(), src->getId(), diff --git a/src/surf/surf_routing_cluster_torus.hpp b/src/surf/surf_routing_cluster_torus.hpp index 86e9a20e92..a9ab7942c4 100644 --- a/src/surf/surf_routing_cluster_torus.hpp +++ b/src/surf/surf_routing_cluster_torus.hpp @@ -12,16 +12,12 @@ #ifndef SURF_ROUTING_CLUSTER_TORUS_HPP_ #define SURF_ROUTING_CLUSTER_TORUS_HPP_ -class AsClusterTorus; -typedef AsClusterTorus *AsClusterTorusPtr; - - class AsClusterTorus: public AsCluster { public: AsClusterTorus(); virtual ~AsClusterTorus(); virtual void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position); - virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster); diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index 57d39b9a46..f6d146d786 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -48,7 +48,7 @@ AS_t model_dijkstracache_create(void){ void model_dijkstra_both_end(AS_t as) { - AsDijkstraPtr THIS_AS = static_cast(as); + AsDijkstra *THIS_AS = static_cast(as); xbt_node_t node = NULL; unsigned int cursor2; xbt_dynar_t nodes = NULL; @@ -176,23 +176,23 @@ void AsDijkstra::addLoopback() { xbt_dynar_t AsDijkstra::getOnelinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); + xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); int src,dst; - RoutingEdgePtr src_elm, dst_elm; + RoutingEdge *src_elm, *dst_elm; int table_size = (int)xbt_dynar_length(p_indexNetworkElm); for(src=0; src < table_size; src++) { for(dst=0; dst< table_size; dst++) { xbt_dynar_reset(route->link_list); - src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr); - dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr); + src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdge*); + dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdge*); this->getRouteAndLatency(src_elm, dst_elm,route, NULL); if (xbt_dynar_length(route->link_list) == 1) { void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); - OnelinkPtr onelink; + Onelink *onelink; if (p_hierarchy == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); else if (p_hierarchy == SURF_ROUTING_RECURSIVE) @@ -206,7 +206,7 @@ xbt_dynar_t AsDijkstra::getOnelinkRoutes() return ret; } -void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat) +void AsDijkstra::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat) { /* set utils vars */ @@ -330,8 +330,8 @@ void AsDijkstra::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_p } /* compose route path with links */ - RoutingEdgePtr gw_src = NULL, gw_dst, prev_gw_src, first_gw = NULL; - RoutingEdgePtr gw_dst_net_elm = NULL, prev_gw_src_net_elm = NULL; + RoutingEdge *gw_src = NULL, *gw_dst, *prev_gw_src, *first_gw = NULL; + RoutingEdge *gw_dst_net_elm = NULL, *prev_gw_src_net_elm = NULL; for (v = dst_node_id; v != src_node_id; v = pred_arr[v]) { xbt_node_t node_pred_v = @@ -480,7 +480,7 @@ void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route) surf_parse_error("The gw_src '%s' does not exist!",route->gw_src->getName()); } - RoutingEdgePtr src_net_elm, dst_net_elm; + RoutingEdge *src_net_elm, *dst_net_elm; src_net_elm = sg_routing_edge_by_name_or_null(src); dst_net_elm = sg_routing_edge_by_name_or_null(dst); @@ -521,7 +521,7 @@ void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route) THROWF(arg_error,0,"(AS)Route from '%s' to '%s' already exists",src,dst); if (route->gw_dst && route->gw_src) { - RoutingEdgePtr gw_tmp; + RoutingEdge *gw_tmp; gw_tmp = route->gw_src; route->gw_src = route->gw_dst; route->gw_dst = gw_tmp; diff --git a/src/surf/surf_routing_dijkstra.hpp b/src/surf/surf_routing_dijkstra.hpp index 033e4f9aaa..28143839a6 100644 --- a/src/surf/surf_routing_dijkstra.hpp +++ b/src/surf/surf_routing_dijkstra.hpp @@ -27,7 +27,6 @@ typedef struct route_cache_element { * Classes * ***********/ class AsDijkstra; -typedef AsDijkstra *AsDijkstraPtr; class AsDijkstra : public AsGeneric { public: @@ -50,7 +49,7 @@ public: * will have a loopback attached to it. */ void addLoopback(); - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat); xbt_dynar_t getOnelinkRoutes(); void getRouteAndLatency(sg_platf_route_cbarg_t route, double *lat); void parseASroute(sg_platf_route_cbarg_t route); diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index adaecedfca..adc6a53836 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -20,7 +20,7 @@ AS_t model_floyd_create(void) void model_floyd_end(AS_t current_routing) { - static_cast(current_routing)->end(); + static_cast(current_routing)->end(); } AsFloyd::AsFloyd(): AsGeneric() { @@ -51,7 +51,7 @@ AsFloyd::~AsFloyd(){ /* Business methods */ xbt_dynar_t AsFloyd::getOneLinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); + xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); @@ -61,13 +61,13 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes() for(src=0; src < table_size; src++) { for(dst=0; dst< table_size; dst++) { xbt_dynar_reset(route->link_list); - src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr); - dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr); + src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdge*); + dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdge*); this->getRouteAndLatency(src_elm, dst_elm, route, NULL); if (xbt_dynar_length(route->link_list) == 1) { void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); - OnelinkPtr onelink; + Onelink *onelink; if (p_hierarchy == SURF_ROUTING_BASE) onelink = new Onelink(link, src_elm, dst_elm); else if (p_hierarchy == SURF_ROUTING_RECURSIVE) @@ -82,7 +82,7 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes() return ret; } -void AsFloyd::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat) +void AsFloyd::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t res, double *lat) { /* set utils vars */ @@ -149,7 +149,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) /* set the size of table routing */ int table_size = (int)xbt_dynar_length(p_indexNetworkElm); - RoutingEdgePtr src_net_elm, dst_net_elm; + RoutingEdge *src_net_elm, *dst_net_elm; src_net_elm = sg_routing_edge_by_name_or_null(src); dst_net_elm = sg_routing_edge_by_name_or_null(dst); diff --git a/src/surf/surf_routing_floyd.hpp b/src/surf/surf_routing_floyd.hpp index 57fca5eb95..e307d47d0e 100644 --- a/src/surf/surf_routing_floyd.hpp +++ b/src/surf/surf_routing_floyd.hpp @@ -14,14 +14,13 @@ * Classes * ***********/ class AsFloyd; -typedef AsFloyd *AsFloydPtr; class AsFloyd: public AsGeneric { public: AsFloyd(); ~AsFloyd(); - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); xbt_dynar_t getOneLinkRoutes(); void parseASroute(sg_platf_route_cbarg_t route); void parseRoute(sg_platf_route_cbarg_t route); @@ -29,14 +28,14 @@ public: //void parseASroute(sg_platf_route_cbarg_t route); //void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + //sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - //int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */ - //int parseAS(RoutingEdgePtr elm); + //int parsePU(RoutingEdge *elm); /* A host or a router, whatever */ + //int parseAS(RoutingEdge *elm); //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0; diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 806ece7ae8..c7ef49a41b 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -25,7 +25,7 @@ void model_full_end(AS_t _routing) sg_platf_route_cbarg_t e_route; /* set utils vars */ - AsFullPtr routing = ((AsFullPtr) _routing); + AsFull *routing = static_cast(_routing); int table_size = (int)xbt_dynar_length(routing->p_indexNetworkElm); /* Create table if necessary */ @@ -70,7 +70,7 @@ AsFull::~AsFull(){ xbt_dynar_t AsFull::getOneLinkRoutes() { - xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f); + xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); int src, dst; int table_size = xbt_dynar_length(p_indexNetworkElm); @@ -81,11 +81,11 @@ xbt_dynar_t AsFull::getOneLinkRoutes() if (route) { if (xbt_dynar_length(route->link_list) == 1) { void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0); - OnelinkPtr onelink; + Onelink *onelink; if (p_hierarchy == SURF_ROUTING_BASE) { - RoutingEdgePtr tmp_src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_routing_edge_t); + RoutingEdge *tmp_src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_routing_edge_t); tmp_src->setId(src); - RoutingEdgePtr tmp_dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_routing_edge_t); + RoutingEdge *tmp_dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_routing_edge_t); tmp_dst->setId(dst); onelink = new Onelink(link, tmp_src, tmp_dst); } else if (p_hierarchy == SURF_ROUTING_RECURSIVE) @@ -103,7 +103,7 @@ xbt_dynar_t AsFull::getOneLinkRoutes() return ret; } -void AsFull::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat) +void AsFull::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t res, double *lat) { XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]", src->getName(), @@ -145,7 +145,7 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route) int as_route = 0; char *src = (char*)(route->src); char *dst = (char*)(route->dst); - RoutingEdgePtr src_net_elm, dst_net_elm; + RoutingEdge *src_net_elm, *dst_net_elm; src_net_elm = sg_routing_edge_by_name_or_null(src); dst_net_elm = sg_routing_edge_by_name_or_null(dst); diff --git a/src/surf/surf_routing_full.hpp b/src/surf/surf_routing_full.hpp index de3d0de2e2..bd0c712128 100644 --- a/src/surf/surf_routing_full.hpp +++ b/src/surf/surf_routing_full.hpp @@ -13,7 +13,6 @@ * Classes * ***********/ class AsFull; -typedef AsFull *AsFullPtr; class AsFull: public AsGeneric { public: @@ -22,20 +21,20 @@ public: AsFull(); ~AsFull(); - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); xbt_dynar_t getOneLinkRoutes(); void parseRoute(sg_platf_route_cbarg_t route); void parseASroute(sg_platf_route_cbarg_t route); //void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + //sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - //virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */ - //virtual int parseAS( RoutingEdgePtr elm)=0; + //virtual int parsePU(RoutingEdge *elm)=0; /* A host or a router, whatever */ + //virtual int parseAS( RoutingEdge *elm)=0; //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0; }; diff --git a/src/surf/surf_routing_generic.cpp b/src/surf/surf_routing_generic.cpp index a92e8beef8..d80e89ce6a 100644 --- a/src/surf/surf_routing_generic.cpp +++ b/src/surf/surf_routing_generic.cpp @@ -30,7 +30,7 @@ void AsGeneric::parseASroute(sg_platf_route_cbarg_t /*route*/){ THROW_IMPOSSIBLE; } -void AsGeneric::getRouteAndLatency(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, sg_platf_route_cbarg_t /*into*/, double */*latency*/){ +void AsGeneric::getRouteAndLatency(RoutingEdge */*src*/, RoutingEdge */*dst*/, sg_platf_route_cbarg_t /*into*/, double */*latency*/){ THROW_IMPOSSIBLE; } @@ -42,17 +42,17 @@ AsGeneric::~AsGeneric() { xbt_dict_free(&p_bypassRoutes); } -int AsGeneric::parsePU(RoutingEdgePtr elm) +int AsGeneric::parsePU(RoutingEdge *elm) { XBT_DEBUG("Load process unit \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); return xbt_dynar_length(p_indexNetworkElm)-1; } -int AsGeneric::parseAS(RoutingEdgePtr elm) +int AsGeneric::parseAS(RoutingEdge *elm) { XBT_DEBUG("Load Autonomous system \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); return xbt_dynar_length(p_indexNetworkElm)-1; } @@ -149,13 +149,13 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) for (src = 0; src < table_size; src++) { - RoutingEdgePtr my_src = - xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr); + RoutingEdge *my_src = + xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdge*); for (dst = 0; dst < table_size; dst++) { if (src == dst) continue; - RoutingEdgePtr my_dst = - xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr); + RoutingEdge *my_dst = + xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdge*); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); @@ -179,7 +179,7 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } xbt_dynar_foreach(route->link_list, cpt, link) { - const char *link_name = ((ResourcePtr) link)->getName(); + const char *link_name = static_cast(link)->getName(); current = new_xbt_graph_node(graph, link_name, nodes); current_name = link_name; new_xbt_graph_edge(graph, previous, current, edges); @@ -204,8 +204,8 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } } -sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, - RoutingEdgePtr dst, +sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdge *src, + RoutingEdge *dst, double *lat) { // If never set a bypass route return NULL without any further computations @@ -224,13 +224,13 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, free(route_name); } else{ - AsPtr src_as, dst_as; + As *src_as, *dst_as; int index_src, index_dst; xbt_dynar_t path_src = NULL; xbt_dynar_t path_dst = NULL; - AsPtr current = NULL; - AsPtr *current_src = NULL; - AsPtr *current_dst = NULL; + As *current = NULL; + As **current_src = NULL; + As **current_dst = NULL; if (src == NULL || dst == NULL) xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"", @@ -241,13 +241,13 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, dst_as = dst->getRcComponent(); /* (2) find the path to the root routing component */ - path_src = xbt_dynar_new(sizeof(AsPtr), NULL); + path_src = xbt_dynar_new(sizeof(As*), NULL); current = src_as; while (current != NULL) { xbt_dynar_push(path_src, ¤t); current = current->p_routingFather; } - path_dst = xbt_dynar_new(sizeof(AsPtr), NULL); + path_dst = xbt_dynar_new(sizeof(As*), NULL); current = dst_as; while (current != NULL) { xbt_dynar_push(path_dst, ¤t); @@ -257,15 +257,15 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, /* (3) find the common father */ index_src = path_src->used - 1; index_dst = path_dst->used - 1; - current_src = (AsPtr *) xbt_dynar_get_ptr(path_src, index_src); - current_dst = (AsPtr *) xbt_dynar_get_ptr(path_dst, index_dst); + current_src = (As **) xbt_dynar_get_ptr(path_src, index_src); + current_dst = (As **) xbt_dynar_get_ptr(path_dst, index_dst); while (index_src >= 0 && index_dst >= 0 && *current_src == *current_dst) { xbt_dynar_pop_ptr(path_src); xbt_dynar_pop_ptr(path_dst); index_src--; index_dst--; - current_src = (AsPtr *) xbt_dynar_get_ptr(path_src, index_src); - current_dst = (AsPtr *) xbt_dynar_get_ptr(path_dst, index_dst); + current_src = (As **) xbt_dynar_get_ptr(path_src, index_src); + current_dst = (As **) xbt_dynar_get_ptr(path_dst, index_dst); } int max_index_src = path_src->used - 1; @@ -278,9 +278,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, for (i = 0; i < max; i++) { if (i <= max_index_src && max <= max_index_dst) { char *route_name = bprintf("%s#%s", - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_src, i)))->p_name, - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_dst, max)))->p_name); e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name); xbt_free(route_name); @@ -289,9 +289,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, break; if (max <= max_index_src && i <= max_index_dst) { char *route_name = bprintf("%s#%s", - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_src, max)))->p_name, - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_dst, i)))->p_name); e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name); xbt_free(route_name); @@ -305,9 +305,9 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(RoutingEdgePtr src, if (max <= max_index_src && max <= max_index_dst) { char *route_name = bprintf("%s#%s", - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_src, max)))->p_name, - (*(AsPtr *) + (*(As **) (xbt_dynar_get_ptr(path_dst, max)))->p_name); e_route_bypass = (sg_platf_route_cbarg_t) xbt_dict_get_or_null(dict_bypassRoutes, route_name); xbt_free(route_name); @@ -383,13 +383,13 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi -AsPtr AsGeneric::asExist(AsPtr to_find) +As *AsGeneric::asExist(As *to_find) { //return to_find; // FIXME: BYPASSERROR OF FOREACH WITH BREAK xbt_dict_cursor_t cursor = NULL; char *key; int found = 0; - AsGenericPtr elem; + AsGeneric *elem; xbt_dict_foreach(p_routingSons, cursor, key, elem) { if (to_find == elem || elem->asExist(to_find)) { found = 1; @@ -401,16 +401,16 @@ AsPtr AsGeneric::asExist(AsPtr to_find) return NULL; } -AsPtr AsGeneric::autonomousSystemExist(char *element) +As *AsGeneric::autonomousSystemExist(char *element) { //return rc; // FIXME: BYPASSERROR OF FOREACH WITH BREAK - AsPtr element_as, result, elem; + As *element_as, *result, *elem; xbt_dict_cursor_t cursor = NULL; char *key; - element_as = ((RoutingEdgePtr) + element_as = ((RoutingEdge*) xbt_lib_get_or_null(as_router_lib, element, ROUTING_ASR_LEVEL))->getRcComponent(); - result = ((AsPtr) - 1); + result = ((As*) - 1); if (element_as != this) result = asExist(element_as); @@ -427,15 +427,15 @@ AsPtr AsGeneric::autonomousSystemExist(char *element) return NULL; } -AsPtr AsGeneric::processingUnitsExist(char *element) +As *AsGeneric::processingUnitsExist(char *element) { - AsPtr element_as = sg_host_edge(sg_host_by_name(element)) ->getRcComponent(); + As *element_as = sg_host_edge(sg_host_by_name(element)) ->getRcComponent(); if (element_as == this) return element_as; return asExist(element_as); } -void AsGeneric::srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst) +void AsGeneric::srcDstCheck(RoutingEdge *src, RoutingEdge *dst) { if (src == NULL || dst == NULL) xbt_die("Ask for route \"from\"(%s) or \"to\"(%s) no found at AS \"%s\"", @@ -443,8 +443,8 @@ void AsGeneric::srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst) dst ? dst->getName() : "(null)", p_name); - AsPtr src_as = src->getRcComponent(); - AsPtr dst_as = dst->getRcComponent(); + As *src_as = src->getRcComponent(); + As *dst_as = dst->getRcComponent(); if (src_as != dst_as) xbt_die("The src(%s in %s) and dst(%s in %s) are in differents AS", diff --git a/src/surf/surf_routing_generic.hpp b/src/surf/surf_routing_generic.hpp index 53928b152b..fd386a6cc7 100644 --- a/src/surf/surf_routing_generic.hpp +++ b/src/surf/surf_routing_generic.hpp @@ -10,7 +10,6 @@ #define SURF_ROUTING_GENERIC_HPP_ class AsGeneric; -typedef AsGeneric *AsGenericPtr; void generic_free_route(sg_platf_route_cbarg_t route); @@ -19,26 +18,26 @@ public: AsGeneric(); ~AsGeneric(); - virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + virtual void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); virtual xbt_dynar_t getOneLinkRoutes(); virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */ - virtual int parseAS( RoutingEdgePtr elm); + virtual int parsePU(RoutingEdge *elm); /* A host or a router, whatever */ + virtual int parseAS(RoutingEdge *elm); virtual void parseRoute(sg_platf_route_cbarg_t route); virtual void parseASroute(sg_platf_route_cbarg_t route); virtual void parseBypassroute(sg_platf_route_cbarg_t e_route); virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order); - virtual AsPtr asExist(AsPtr to_find); - virtual AsPtr autonomousSystemExist(char *element); - virtual AsPtr processingUnitsExist(char *element); - virtual void srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst); + virtual As *asExist(As *to_find); + virtual As *autonomousSystemExist(char *element); + virtual As *processingUnitsExist(char *element); + virtual void srcDstCheck(RoutingEdge *src, RoutingEdge *dst); }; #endif /* SURF_ROUTING_GENERIC_HPP_ */ diff --git a/src/surf/surf_routing_none.cpp b/src/surf/surf_routing_none.cpp index 1ea0e4ab5e..a1a97e878d 100644 --- a/src/surf/surf_routing_none.cpp +++ b/src/surf/surf_routing_none.cpp @@ -17,7 +17,7 @@ xbt_dynar_t AsNone::getOneLinkRoutes() { return NULL; } -void AsNone::getRouteAndLatency(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, +void AsNone::getRouteAndLatency(RoutingEdge */*src*/, RoutingEdge */*dst*/, sg_platf_route_cbarg_t /*res*/, double *lat) { *lat = 0.0; @@ -28,20 +28,20 @@ void AsNone::getGraph(xbt_graph_t /*graph*/, xbt_dict_t /*nodes*/, xbt_dict_t /* XBT_INFO("No routing no graph"); } -sg_platf_route_cbarg_t AsNone::getBypassRoute(RoutingEdgePtr /*src*/, RoutingEdgePtr /*dst*/, double */*lat*/) { +sg_platf_route_cbarg_t AsNone::getBypassRoute(RoutingEdge */*src*/, RoutingEdge */*dst*/, double */*lat*/) { return NULL; } -int AsNone::parsePU(RoutingEdgePtr elm) { +int AsNone::parsePU(RoutingEdge *elm) { XBT_DEBUG("Load process unit \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); /* don't care about PUs */ return -1; } -int AsNone::parseAS(RoutingEdgePtr elm) { +int AsNone::parseAS(RoutingEdge *elm) { XBT_DEBUG("Load Autonomous system \"%s\"", elm->getName()); - xbt_dynar_push_as(p_indexNetworkElm, RoutingEdgePtr, elm); + xbt_dynar_push_as(p_indexNetworkElm, RoutingEdge*, elm); /* even don't care about sub-ASes -- I'm as nihilist as an old punk*/ return -1; } diff --git a/src/surf/surf_routing_none.hpp b/src/surf/surf_routing_none.hpp index 042161ef72..8fab504ddf 100644 --- a/src/surf/surf_routing_none.hpp +++ b/src/surf/surf_routing_none.hpp @@ -14,17 +14,17 @@ public: AsNone(); ~AsNone(); - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); xbt_dynar_t getOneLinkRoutes(); void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */ - int parseAS( RoutingEdgePtr elm); + int parsePU(RoutingEdge *elm); /* A host or a router, whatever */ + int parseAS( RoutingEdge *elm); void parseRoute(sg_platf_route_cbarg_t route); void parseASroute(sg_platf_route_cbarg_t route); void parseBypassroute(sg_platf_route_cbarg_t e_route); diff --git a/src/surf/surf_routing_private.hpp b/src/surf/surf_routing_private.hpp index 4dbfad44c2..99479c682c 100644 --- a/src/surf/surf_routing_private.hpp +++ b/src/surf/surf_routing_private.hpp @@ -66,9 +66,9 @@ void model_floyd_parse_route(AS_t rc, sg_platf_route_cbarg_t route); /* ************************************************** */ /* ************** Cluster ROUTING **************** */ -AsPtr model_cluster_create(void); /* create structures for cluster routing model */ -AsPtr model_torus_cluster_create(void); -AsPtr model_fat_tree_cluster_create(void); +As *model_cluster_create(void); /* create structures for cluster routing model */ +As *model_torus_cluster_create(void); +As *model_fat_tree_cluster_create(void); /* ************************************************** */ /* ************** Vivaldi ROUTING **************** */ diff --git a/src/surf/surf_routing_vivaldi.cpp b/src/surf/surf_routing_vivaldi.cpp index 783b99d7bd..2865fa056f 100644 --- a/src/surf/surf_routing_vivaldi.cpp +++ b/src/surf/surf_routing_vivaldi.cpp @@ -23,7 +23,7 @@ AS_t model_vivaldi_create(void) return new AsVivaldi(); } -void AsVivaldi::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat) +void AsVivaldi::getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t route, double *lat) { s_surf_parsing_link_up_down_t info; @@ -101,7 +101,7 @@ void AsVivaldi::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_pl } } -int AsVivaldi::parsePU(RoutingEdgePtr elm) { +int AsVivaldi::parsePU(RoutingEdge *elm) { XBT_DEBUG("Load process unit \"%s\"", elm->getName()); xbt_dynar_push_as(p_indexNetworkElm, sg_routing_edge_t, elm); return xbt_dynar_length(p_indexNetworkElm)-1; diff --git a/src/surf/surf_routing_vivaldi.hpp b/src/surf/surf_routing_vivaldi.hpp index ee0ab652b0..a85bb9370f 100644 --- a/src/surf/surf_routing_vivaldi.hpp +++ b/src/surf/surf_routing_vivaldi.hpp @@ -20,7 +20,6 @@ AS_t model_vivaldi_create(void); /* create structures for vivaldi routing m * Classes * ***********/ class AsVivaldi; -typedef AsVivaldi *AsVivaldiPtr; class AsVivaldi: public AsGeneric { public: @@ -29,16 +28,16 @@ public: AsVivaldi() : AsGeneric() {}; ~AsVivaldi() {}; - void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency); + void getRouteAndLatency(RoutingEdge *src, RoutingEdge *dst, sg_platf_route_cbarg_t into, double *latency); //void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges); - //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat); + //sg_platf_route_cbarg_t getBypassRoute(RoutingEdge *src, RoutingEdge *dst, double *lat); /* The parser calls the following functions to inform the routing models * that a new element is added to the AS currently built. * * Of course, only the routing model of this AS is informed, not every ones */ - int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */ - //virtual int parseAS( RoutingEdgePtr elm)=0; + int parsePU(RoutingEdge *elm); /* A host or a router, whatever */ + //virtual int parseAS( RoutingEdge *elm)=0; //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0; }; diff --git a/src/surf/vm_hl13.cpp b/src/surf/vm_hl13.cpp index e72a6283ba..ff60c24e27 100644 --- a/src/surf/vm_hl13.cpp +++ b/src/surf/vm_hl13.cpp @@ -12,7 +12,7 @@ XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_vm); void surf_vm_model_init_HL13(void){ if (surf_cpu_model_vm) { surf_vm_model = new VMHL13Model(); - ModelPtr model = surf_vm_model; + Model *model = surf_vm_model; xbt_dynar_push(model_list, &model); xbt_dynar_push(model_list_invoke, &model); @@ -31,16 +31,16 @@ void VMHL13Model::updateActionsState(double /*now*/, double /*delta*/){ return; } -ActionPtr VMHL13Model::communicate(HostPtr src, HostPtr dst, double size, double rate){ +Action *VMHL13Model::communicate(Host *src, Host *dst, double size, double 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 * structure (i.e not on the surf_resource_private infos) */ -VMPtr VMHL13Model::createVM(const char *name, surf_resource_t host_PM) +VM *VMHL13Model::createVM(const char *name, surf_resource_t host_PM) { - VMHL13Ptr ws = new VMHL13(this, name, NULL, host_PM); + VMHL13 *ws = new VMHL13(this, name, NULL, host_PM); xbt_lib_set(host_lib, name, SURF_HOST_LEVEL, ws); @@ -50,7 +50,7 @@ VMPtr VMHL13Model::createVM(const char *name, surf_resource_t host_PM) return ws; } -static inline double get_solved_value(CpuActionPtr cpu_action) +static inline double get_solved_value(CpuAction *cpu_action) { return cpu_action->getVariable()->value; } @@ -70,8 +70,8 @@ double VMHL13Model::shareResources(double now) /* 0. Make sure that we already calculated the resource share at the physical * machine layer. */ { - _XBT_GNUC_UNUSED ModelPtr ws_model = surf_host_model; - _XBT_GNUC_UNUSED ModelPtr vm_ws_model = surf_vm_model; + _XBT_GNUC_UNUSED Model *ws_model = surf_host_model; + _XBT_GNUC_UNUSED Model *vm_ws_model = surf_vm_model; _XBT_GNUC_UNUSED unsigned int index_of_pm_ws_model = xbt_dynar_search(model_list_invoke, &ws_model); _XBT_GNUC_UNUSED unsigned int index_of_vm_ws_model = xbt_dynar_search(model_list_invoke, &vm_ws_model); xbt_assert((index_of_pm_ws_model < index_of_vm_ws_model), "Cannot assume surf_host_model comes before"); @@ -111,8 +111,8 @@ double VMHL13Model::shareResources(double now) VMModel::ws_vms.begin(); iter != VMModel::ws_vms.end(); ++iter) { - VMPtr ws_vm = &*iter; - CpuPtr cpu = ws_vm->p_cpu; + VM *ws_vm = &*iter; + Cpu *cpu = ws_vm->p_cpu; xbt_assert(cpu, "cpu-less host"); double solved_value = get_solved_value(ws_vm->p_action); @@ -158,7 +158,7 @@ double VMHL13Model::shareResources(double now) { #if 0 - VM2013Ptr ws_vm2013 = static_cast(&*iter); + VM2013 *ws_vm2013 = static_cast(&*iter); XBT_INFO("cost %f remains %f start %f finish %f", ws_vm2013->cpu_action->cost, ws_vm2013->cpu_action->remains, ws_vm2013->cpu_action->start, @@ -181,7 +181,7 @@ double VMHL13Model::shareResources(double now) return ret; } -ActionPtr VMHL13Model::executeParallelTask(int host_nb, +Action *VMHL13Model::executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, @@ -189,10 +189,10 @@ ActionPtr VMHL13Model::executeParallelTask(int host_nb, #define cost_or_zero(array,pos) ((array)?(array)[pos]:0.0) if ((host_nb == 1) && (cost_or_zero(bytes_amount, 0) == 0.0)) - return ((HostCLM03Ptr)host_list[0])->execute(flops_amount[0]); + return static_cast(host_list[0])->execute(flops_amount[0]); else if ((host_nb == 1) && (cost_or_zero(flops_amount, 0) == 0.0)) - return communicate((HostCLM03Ptr)host_list[0], (HostCLM03Ptr)host_list[0],bytes_amount[0], rate); + return communicate(static_cast(host_list[0]), static_cast(host_list[0]),bytes_amount[0], rate); else if ((host_nb == 2) && (cost_or_zero(flops_amount, 0) == 0.0) && (cost_or_zero(flops_amount, 1) == 0.0)) { @@ -206,7 +206,7 @@ ActionPtr VMHL13Model::executeParallelTask(int host_nb, } } if (nb == 1) - return communicate((HostCLM03Ptr)host_list[0], (HostCLM03Ptr)host_list[1],value, rate); + return communicate(static_cast(host_list[0]), static_cast(host_list[1]),value, rate); } #undef cost_or_zero @@ -218,11 +218,11 @@ ActionPtr VMHL13Model::executeParallelTask(int host_nb, * Resource * ************/ -VMHL13::VMHL13(VMModelPtr model, const char* name, xbt_dict_t props, +VMHL13::VMHL13(VMModel *model, const char* name, xbt_dict_t props, surf_resource_t host_PM) : VM(model, name, props, NULL, NULL) { - HostPtr sub_ws = static_cast(surf_host_resource_priv(host_PM)); + Host *sub_ws = static_cast(surf_host_resource_priv(host_PM)); /* Currently, we assume a VM has no storage. */ p_storage = NULL; @@ -242,7 +242,7 @@ VMHL13::VMHL13(VMModelPtr model, const char* name, xbt_dict_t props, // //// CPU RELATED STUFF //// // Roughly, create a vcpu resource by using the values of the sub_cpu one. - CpuCas01Ptr sub_cpu = static_cast(sg_host_surfcpu(host_PM)); + CpuCas01 *sub_cpu = static_cast(sg_host_surfcpu(host_PM)); p_cpu = surf_cpu_model_vm->createCpu(name, // name sub_cpu->getPowerPeakList(), // host->power_peak, @@ -328,7 +328,7 @@ void VMHL13::restore() void VMHL13::migrate(surf_resource_t ind_dst_pm) { /* ind_dst_pm equals to smx_host_t */ - HostPtr ws_dst = static_cast(surf_host_resource_priv(ind_dst_pm)); + Host *ws_dst = static_cast(surf_host_resource_priv(ind_dst_pm)); const char *vm_name = getName(); const char *pm_name_src = p_subWs->getName(); const char *pm_name_dst = ws_dst->getName(); @@ -336,8 +336,8 @@ void VMHL13::migrate(surf_resource_t ind_dst_pm) xbt_assert(ws_dst); /* update net_elm with that of the destination physical host */ - RoutingEdgePtr old_net_elm = p_netElm; - RoutingEdgePtr new_net_elm = new RoutingEdgeWrapper(sg_host_edge(sg_host_by_name(pm_name_dst))); + RoutingEdge *old_net_elm = p_netElm; + RoutingEdge *new_net_elm = new RoutingEdgeWrapper(sg_host_edge(sg_host_by_name(pm_name_dst))); xbt_assert(new_net_elm); /* Unregister the current net_elm from host_lib. Do not call the free callback. */ @@ -362,8 +362,8 @@ void VMHL13::migrate(surf_resource_t ind_dst_pm) #endif /* create a cpu action bound to the pm model at the destination. */ - CpuActionPtr new_cpu_action = static_cast( - static_cast(sg_host_surfcpu(ind_dst_pm))->execute(0)); + CpuAction *new_cpu_action = static_cast( + static_cast(sg_host_surfcpu(ind_dst_pm))->execute(0)); e_surf_action_state_t state = p_action->getState(); if (state != SURF_ACTION_DONE) @@ -393,7 +393,7 @@ void VMHL13::setBound(double bound){ p_action->setBound(bound); } -void VMHL13::setAffinity(CpuPtr cpu, unsigned long mask){ +void VMHL13::setAffinity(Cpu *cpu, unsigned long mask){ p_action->setAffinity(cpu, mask); } @@ -407,7 +407,7 @@ surf_resource_t VMHL13::getPm() } /* Adding a task to a VM updates the VCPU task on its physical machine. */ -ActionPtr VMHL13::execute(double size) +Action *VMHL13::execute(double size) { double old_cost = p_action->getCost(); double new_cost = old_cost + size; @@ -421,7 +421,7 @@ ActionPtr VMHL13::execute(double size) return p_cpu->execute(size); } -ActionPtr VMHL13::sleep(double duration) { +Action *VMHL13::sleep(double duration) { return p_cpu->sleep(duration); } diff --git a/src/surf/vm_hl13.hpp b/src/surf/vm_hl13.hpp index 397bac591d..41b06ef800 100644 --- a/src/surf/vm_hl13.hpp +++ b/src/surf/vm_hl13.hpp @@ -18,10 +18,7 @@ ***********/ class VMHL13Model; -typedef VMHL13Model *VMHL13ModelPtr; - class VMHL13; -typedef VMHL13 *VMHL13Ptr; /********* * Model * @@ -31,11 +28,11 @@ public: VMHL13Model(); ~VMHL13Model(){}; - VMPtr createVM(const char *name, surf_resource_t host_PM); + VM *createVM(const char *name, surf_resource_t host_PM); double shareResources(double now); void adjustWeightOfDummyCpuActions() {}; - ActionPtr communicate(HostPtr src, HostPtr dst, double size, double rate); - ActionPtr executeParallelTask(int host_nb, + Action *communicate(Host *src, Host *dst, double size, double rate); + Action *executeParallelTask(int host_nb, void **host_list, double *flops_amount, double *bytes_amount, @@ -49,7 +46,7 @@ public: class VMHL13 : public VM { public: - VMHL13(VMModelPtr model, const char* name, xbt_dict_t props, surf_resource_t host_PM); + VMHL13(VMModel *model, const char* name, xbt_dict_t props, surf_resource_t host_PM); ~VMHL13(); void suspend(); @@ -66,14 +63,14 @@ public: surf_resource_t getPm(); // will be vm_ws_get_pm() void setBound(double bound); - void setAffinity(CpuPtr cpu, unsigned long mask); + void setAffinity(Cpu *cpu, unsigned long mask); //FIXME: remove void updateState(tmgr_trace_event_t event_type, double value, double date); bool isUsed(); - ActionPtr execute(double size); - ActionPtr sleep(double duration); + Action *execute(double size); + Action *sleep(double duration); }; /********** diff --git a/src/surf/vm_interface.cpp b/src/surf/vm_interface.cpp index c72689df40..d7b0e5c923 100644 --- a/src/surf/vm_interface.cpp +++ b/src/surf/vm_interface.cpp @@ -10,15 +10,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm, surf, "Logging specific to the SURF VM module"); -VMModelPtr surf_vm_model = NULL; +VMModel *surf_vm_model = NULL; /************* * Callbacks * *************/ -surf_callback(void, VMPtr) VMCreatedCallbacks; -surf_callback(void, VMPtr) VMDestructedCallbacks; -surf_callback(void, VMPtr) VMStateChangedCallbacks; +surf_callback(void, VM*) VMCreatedCallbacks; +surf_callback(void, VM*) VMDestructedCallbacks; +surf_callback(void, VM*) VMStateChangedCallbacks; /********* * Model * @@ -34,8 +34,8 @@ VMModel::vm_list_t VMModel::ws_vms; * Resource * ************/ -VM::VM(ModelPtr model, const char *name, xbt_dict_t props, - RoutingEdgePtr netElm, CpuPtr cpu) +VM::VM(Model *model, const char *name, xbt_dict_t props, + RoutingEdge *netElm, Cpu *cpu) : Host(model, name, props, NULL, netElm, cpu) { VMModel::ws_vms.push_back(*this); diff --git a/src/surf/vm_interface.hpp b/src/surf/vm_interface.hpp index a8ddce849d..0dede2e71f 100644 --- a/src/surf/vm_interface.hpp +++ b/src/surf/vm_interface.hpp @@ -17,13 +17,7 @@ ***********/ class VMModel; -typedef VMModel *VMModelPtr; - class VM; -typedef VM *VMPtr; - -class VMLmm; -typedef VMLmm *VMLmmPtr; /************* * Callbacks * @@ -33,19 +27,19 @@ typedef VMLmm *VMLmmPtr; * @brief Callbacks handler which emit the callbacks after VM creation * * @details Callback functions have the following signature: `void(VMPtr)` */ -extern surf_callback(void, VMPtr) VMCreatedCallbacks; +extern surf_callback(void, VM*) VMCreatedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after VM destruction * * @details Callback functions have the following signature: `void(VMPtr)` */ -extern surf_callback(void, VMPtr) VMDestructedCallbacks; +extern surf_callback(void, VM*) VMDestructedCallbacks; /** @ingroup SURF_callbacks * @brief Callbacks handler which emit the callbacks after VM State changed * * @details Callback functions have the following signature: `void(VMActionPtr)` */ -extern surf_callback(void, VMPtr) VMStateChangedCallbacks; +extern surf_callback(void, VM*) VMStateChangedCallbacks; /********* * Model * @@ -59,7 +53,7 @@ public: VMModel(); ~VMModel(){}; - HostPtr createHost(const char *name){DIE_IMPOSSIBLE;} + Host *createHost(const char *name){DIE_IMPOSSIBLE;} /** * @brief Create a new VM @@ -68,7 +62,7 @@ public: * @param host_PM The real machine hosting the VM * */ - virtual VMPtr createVM(const char *name, surf_resource_t host_PM)=0; + virtual VM *createVM(const char *name, surf_resource_t host_PM)=0; void adjustWeightOfDummyCpuActions() {}; typedef boost::intrusive::list