Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix network constant issues
authorPaul Bédaride <paul.bedaride@gmail.com>
Wed, 27 Nov 2013 17:29:41 +0000 (18:29 +0100)
committerPaul Bédaride <paul.bedaride@gmail.com>
Wed, 27 Nov 2013 17:29:41 +0000 (18:29 +0100)
13 files changed:
src/simix/smx_host.c
src/surf/cpu.cpp
src/surf/cpu.hpp
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/cpu_ti.cpp
src/surf/cpu_ti.hpp
src/surf/network_constant.cpp
src/surf/network_constant.hpp
src/surf/surf.cpp
src/surf/surf.hpp
src/surf/vm_workstation.cpp
src/surf/workstation_ptask_L07.cpp

index 5b42062..8205c77 100644 (file)
@@ -35,7 +35,7 @@ smx_host_t SIMIX_host_create(const char *name,
   /* Update global variables */
   xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
 
   /* Update global variables */
   xbt_lib_set(host_lib,name,SIMIX_HOST_LEVEL,smx_host);
 
-  return xbt_lib_get_or_null(host_lib, name, SIMIX_HOST_LEVEL);
+  return xbt_lib_get_elm_or_null(host_lib, name);//, SIMIX_HOST_LEVEL);
 }
 
 void SIMIX_pre_host_on(smx_simcall_t simcall, smx_host_t h)
 }
 
 void SIMIX_pre_host_on(smx_simcall_t simcall, smx_host_t h)
index 4632489..77f06e3 100644 (file)
@@ -130,6 +130,33 @@ int Cpu::getCore()
   return m_core;
 }
 
   return m_core;
 }
 
+CpuLmm::CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
+: ResourceLmm(), Cpu(model, name, properties, core, powerPeak, powerScale) {
+  /* At now, we assume that a VM does not have a multicore CPU. */
+  if (core > 1)
+    xbt_assert(model == surf_cpu_model_pm);
+
+  p_constraintCore = xbt_new(lmm_constraint_t, core);
+
+  int i;
+  for (i = 0; i < core; i++) {
+    /* just for a unique id, never used as a string. */
+    void *cnst_id = bprintf("%s:%i", name, i);
+    p_constraintCore[i] = lmm_constraint_new(p_model->p_maxminSystem, cnst_id, m_powerScale * m_powerPeak);
+  }
+}
+
+CpuLmm::~CpuLmm(){
+  if (p_constraintCore){
+    for (int i = 0; i < m_core; i++) {
+         void *cnst_id = p_constraintCore[i]->id;
+         //FIXME:lmm_constraint_free(p_model->p_maxminSystem, p_constraintCore[i]);
+         xbt_free(cnst_id);
+    }
+    xbt_free(p_constraintCore);
+  }
+}
+
 /**********
  * Action *
  **********/
 /**********
  * Action *
  **********/
index c8b5316..e4a5646 100644 (file)
@@ -1,4 +1,5 @@
 #include "surf.hpp"
 #include "surf.hpp"
+#include "maxmin_private.h"
 
 #ifndef SURF_MODEL_CPU_H_
 #define SURF_MODEL_CPU_H_
 
 #ifndef SURF_MODEL_CPU_H_
 #define SURF_MODEL_CPU_H_
@@ -40,7 +41,9 @@ public:
 class Cpu : virtual public Resource {
 public:
   Cpu(){};
 class Cpu : virtual public Resource {
 public:
   Cpu(){};
-  Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties) : Resource(model, name, properties) {};
+  Cpu(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale)
+   : Resource(model, name, properties), m_core(core), m_powerPeak(powerPeak), m_powerScale(powerScale)
+   {};
   virtual ActionPtr execute(double size)=0;
   virtual ActionPtr sleep(double duration)=0;
   virtual int getCore();
   virtual ActionPtr execute(double size)=0;
   virtual ActionPtr sleep(double duration)=0;
   virtual int getCore();
@@ -54,9 +57,9 @@ public:
   virtual double getConsumedEnergy()=0;
 
   void addTraces(void);
   virtual double getConsumedEnergy()=0;
 
   void addTraces(void);
+  int m_core;
   double m_powerPeak;            /*< CPU power peak */
   double m_powerScale;           /*< Percentage of CPU disponible */
   double m_powerPeak;            /*< CPU power peak */
   double m_powerScale;           /*< Percentage of CPU disponible */
-  int m_core;
 protected:
 
   //virtual boost::shared_ptr<Action> execute(double size) = 0;
 protected:
 
   //virtual boost::shared_ptr<Action> execute(double size) = 0;
@@ -65,8 +68,9 @@ protected:
 
 class CpuLmm : public ResourceLmm, public Cpu {
 public:
 
 class CpuLmm : public ResourceLmm, public Cpu {
 public:
-  CpuLmm(){};
-  CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties) : ResourceLmm(), Cpu(model, name, properties) {};
+  CpuLmm() : p_constraintCore(NULL) {};
+  CpuLmm(CpuModelPtr model, const char* name, xbt_dict_t properties, int core, double powerPeak, double powerScale);
+  ~CpuLmm();
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore;
 };
   /* Note (hypervisor): */
   lmm_constraint_t *p_constraintCore;
 };
index 8bc8545..540117f 100644 (file)
@@ -133,7 +133,7 @@ void CpuCas01Model::parseInit(sg_platf_host_cbarg_t host)
         host->properties);
 }
 
         host->properties);
 }
 
-CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, xbt_dynar_t power_peak,
+CpuPtr CpuCas01Model::createResource(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,
                                  int pstate, double power_scale,
                           tmgr_trace_t power_trace, int core,
                           e_surf_resource_state_t state_initial,
@@ -150,7 +150,7 @@ CpuCas01LmmPtr CpuCas01Model::createResource(const char *name, xbt_dynar_t power
   cpu = new CpuCas01Lmm(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
   cpu = new CpuCas01Lmm(this, name, power_peak, pstate, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
 
-  return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);
+  return cpu;
 }
 
 double CpuCas01Model::shareResourcesFull(double /*now*/)
 }
 
 double CpuCas01Model::shareResourcesFull(double /*now*/)
@@ -198,10 +198,10 @@ void CpuCas01Model::addTraces()
 CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak,
                          int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
                          e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
 CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t powerPeak,
                          int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
                          e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
-                         xbt_dict_t properties) :
-       Resource(model, name, properties), CpuLmm(model, name, properties) {
+                         xbt_dict_t properties)
+: Resource(model, name, properties)
+, CpuLmm(model, name, properties, core, xbt_dynar_get_as(powerPeak, pstate, double), powerScale) {
   p_powerEvent = NULL;
   p_powerEvent = NULL;
-  m_powerPeak = xbt_dynar_get_as(powerPeak, pstate, double);
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
 
   p_powerPeakList = powerPeak;
   m_pstate = pstate;
 
@@ -212,7 +212,6 @@ CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t p
 
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
 
 
   XBT_DEBUG("CPU create: peak=%f, pstate=%d", m_powerPeak, m_pstate);
 
-  m_powerScale = powerScale;
   m_core = core;
   p_stateCurrent = stateInitial;
   if (powerTrace)
   m_core = core;
   p_stateCurrent = stateInitial;
   if (powerTrace)
@@ -245,6 +244,9 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
   lmm_element_t elem = NULL;
 
   if (event_type == p_powerEvent) {
   lmm_element_t elem = NULL;
 
   if (event_type == p_powerEvent) {
+       /* TODO (Hypervisor): do the same thing for constraint_core[i] */
+       xbt_assert(m_core == 1, "FIXME: add power scaling code also for constraint_core[i]");
+
     m_powerScale = value;
     lmm_update_constraint_bound(surf_cpu_model_pm->p_maxminSystem, p_constraint,
                                 m_core * m_powerScale *
     m_powerScale = value;
     lmm_update_constraint_bound(surf_cpu_model_pm->p_maxminSystem, p_constraint,
                                 m_core * m_powerScale *
@@ -265,6 +267,9 @@ void CpuCas01Lmm::updateState(tmgr_trace_event_t event_type, double value, doubl
     if (tmgr_trace_event_free(event_type))
       p_powerEvent = NULL;
   } else if (event_type == p_stateEvent) {
     if (tmgr_trace_event_free(event_type))
       p_powerEvent = NULL;
   } else if (event_type == p_stateEvent) {
+       /* TODO (Hypervisor): do the same thing for constraint_core[i] */
+    xbt_assert(m_core == 1, "FIXME: add state change code also for constraint_core[i]");
+
     if (value > 0) {
       if(p_stateCurrent == SURF_RESOURCE_OFF)
         xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
     if (value > 0) {
       if(p_stateCurrent == SURF_RESOURCE_OFF)
         xbt_dynar_push_as(host_that_restart, char*, (char *)m_name);
index a75fa9e..8ed959f 100644 (file)
@@ -24,7 +24,7 @@ public:
   void (CpuCas01Model::*updateActionsState)(double now, double delta);
 
   void parseInit(sg_platf_host_cbarg_t host);  
   void (CpuCas01Model::*updateActionsState)(double now, double delta);
 
   void parseInit(sg_platf_host_cbarg_t host);  
-  CpuCas01LmmPtr createResource(const char *name, xbt_dynar_t power_peak, int pstate,
+  CpuPtr createResource(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,
                                  double power_scale,
                           tmgr_trace_t power_trace, int core,
                           e_surf_resource_state_t state_initial,
@@ -84,6 +84,6 @@ class CpuCas01ActionLmm: public CpuActionLmm {
 public:
   CpuCas01ActionLmm() {};
   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
 public:
   CpuCas01ActionLmm() {};
   CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
+  ~CpuCas01ActionLmm() {};
   void updateEnergy();
   void updateEnergy();
-
 };
 };
index 2be282c..8cf2280 100644 (file)
@@ -10,10 +10,6 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_ti, surf_cpu,
                                 "Logging specific to the SURF CPU TRACE INTEGRATION module");
 }
 
                                 "Logging specific to the SURF CPU TRACE INTEGRATION module");
 }
 
-static xbt_swag_t cpu_ti_running_action_set_that_does_not_need_being_checked;
-static xbt_swag_t cpu_ti_modified_cpu;
-static xbt_heap_t cpu_ti_action_heap;
-
 static void cpu_ti_action_update_index_heap(void *action, int i);
 
 /*********
 static void cpu_ti_action_update_index_heap(void *action, int i);
 
 /*********
@@ -400,26 +396,31 @@ static void cpu_ti_define_callbacks()
 void surf_cpu_model_init_ti()
 {
   xbt_assert(!surf_cpu_model_pm,"CPU model already initialized. This should not happen.");
 void surf_cpu_model_init_ti()
 {
   xbt_assert(!surf_cpu_model_pm,"CPU model already initialized. This should not happen.");
+  xbt_assert(!surf_cpu_model_vm,"CPU model already initialized. This should not happen.");
+
   surf_cpu_model_pm = new CpuTiModel();
   surf_cpu_model_pm = new CpuTiModel();
+  surf_cpu_model_vm  = new CpuTiModel();
+
   cpu_ti_define_callbacks();
   cpu_ti_define_callbacks();
-  ModelPtr model = static_cast<ModelPtr>(surf_cpu_model_pm);
-  xbt_dynar_push(model_list, &model);
+  ModelPtr model_pm = static_cast<ModelPtr>(surf_cpu_model_pm);
+  ModelPtr model_vm = static_cast<ModelPtr>(surf_cpu_model_vm);
+  xbt_dynar_push(model_list, &model_pm);
+  xbt_dynar_push(model_list, &model_vm);
 }
 
 CpuTiModel::CpuTiModel() : CpuModel("cpu_ti")
 {
 }
 
 CpuTiModel::CpuTiModel() : CpuModel("cpu_ti")
 {
-  xbt_assert(!surf_cpu_model_pm,"CPU model already initialized. This should not happen.");
   ActionPtr action = NULL;
   ActionPtr action = NULL;
-  CpuTi cpu;
+  CpuTiPtr cpu;
 
 
-  cpu_ti_running_action_set_that_does_not_need_being_checked =
+  p_runningActionSetThatDoesNotNeedBeingChecked =
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
       xbt_swag_new(xbt_swag_offset(*action, p_stateHookup));
 
-  cpu_ti_modified_cpu =
-      xbt_swag_new(xbt_swag_offset(cpu, p_modifiedCpuHookup));
+  p_modifiedCpu =
+      xbt_swag_new(xbt_swag_offset(*cpu, p_modifiedCpuHookup));
 
 
-  cpu_ti_action_heap = xbt_heap_new(8, NULL);
-  xbt_heap_set_update_callback(cpu_ti_action_heap,
+  p_tiActionHeap = xbt_heap_new(8, NULL);
+  xbt_heap_set_update_callback(p_tiActionHeap,
                                cpu_ti_action_update_index_heap);
 }
 
                                cpu_ti_action_update_index_heap);
 }
 
@@ -431,11 +432,9 @@ CpuTiModel::~CpuTiModel()
 
   surf_cpu_model_pm = NULL;
 
 
   surf_cpu_model_pm = NULL;
 
-  xbt_swag_free
-      (cpu_ti_running_action_set_that_does_not_need_being_checked);
-  xbt_swag_free(cpu_ti_modified_cpu);
-  cpu_ti_running_action_set_that_does_not_need_being_checked = NULL;
-  xbt_heap_free(cpu_ti_action_heap);
+  xbt_swag_free(p_runningActionSetThatDoesNotNeedBeingChecked);
+  xbt_swag_free(p_modifiedCpu);
+  xbt_heap_free(p_tiActionHeap);
 }
 
 void CpuTiModel::parseInit(sg_platf_host_cbarg_t host)
 }
 
 void CpuTiModel::parseInit(sg_platf_host_cbarg_t host)
@@ -468,7 +467,7 @@ CpuTiPtr CpuTiModel::createResource(const char *name,
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
   CpuTiPtr cpu = new CpuTi(this, name, powerPeak, pstate, powerScale, powerTrace,
                           core, stateInitial, stateTrace, cpuProperties);
   xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, static_cast<ResourcePtr>(cpu));
-  return (CpuTiPtr) xbt_lib_get_elm_or_null(host_lib, name);
+  return cpu;
 }
 
 CpuTiActionPtr CpuTiModel::createAction(double /*cost*/, bool /*failed*/)
 }
 
 CpuTiActionPtr CpuTiModel::createAction(double /*cost*/, bool /*failed*/)
@@ -482,12 +481,12 @@ double CpuTiModel::shareResources(double now)
   double min_action_duration = -1;
 
 /* iterates over modified cpus to update share resources */
   double min_action_duration = -1;
 
 /* iterates over modified cpus to update share resources */
-  xbt_swag_foreach_safe(_cpu, _cpu_next, cpu_ti_modified_cpu) {
+  xbt_swag_foreach_safe(_cpu, _cpu_next, p_modifiedCpu) {
     static_cast<CpuTiPtr>(_cpu)->updateActionFinishDate(now);
   }
 /* get the min next event if heap not empty */
     static_cast<CpuTiPtr>(_cpu)->updateActionFinishDate(now);
   }
 /* get the min next event if heap not empty */
-  if (xbt_heap_size(cpu_ti_action_heap) > 0)
-    min_action_duration = xbt_heap_maxkey(cpu_ti_action_heap) - now;
+  if (xbt_heap_size(p_tiActionHeap) > 0)
+    min_action_duration = xbt_heap_maxkey(p_tiActionHeap) - now;
 
   XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
 
 
   XBT_DEBUG("Share resources, min next event date: %f", min_action_duration);
 
@@ -496,9 +495,9 @@ double CpuTiModel::shareResources(double now)
 
 void CpuTiModel::updateActionsState(double now, double /*delta*/)
 {
 
 void CpuTiModel::updateActionsState(double now, double /*delta*/)
 {
-  while ((xbt_heap_size(cpu_ti_action_heap) > 0)
-         && (xbt_heap_maxkey(cpu_ti_action_heap) <= now)) {
-    CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(cpu_ti_action_heap);
+  while ((xbt_heap_size(p_tiActionHeap) > 0)
+         && (xbt_heap_maxkey(p_tiActionHeap) <= now)) {
+    CpuTiActionPtr action = (CpuTiActionPtr) xbt_heap_pop(p_tiActionHeap);
     XBT_DEBUG("Action %p: finish", action);
     action->m_finish = surf_get_clock();
     /* set the remains to 0 due to precision problems when updating the remaining amount */
     XBT_DEBUG("Action %p: finish", action);
     action->m_finish = surf_get_clock();
     /* set the remains to 0 due to precision problems when updating the remaining amount */
@@ -572,8 +571,9 @@ void CpuTiModel::addTraces()
 CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
 CpuTi::CpuTi(CpuTiModelPtr model, const char *name, xbt_dynar_t powerPeak,
         int pstate, double powerScale, tmgr_trace_t powerTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
-       xbt_dict_t properties) :
-       Resource(model, name, properties), Cpu(model, name, properties) {
+       xbt_dict_t properties)
+: Resource(model, name, properties)
+, Cpu(model, name, properties, core, 0, powerScale) {
   p_powerEvent = NULL;
   p_stateCurrent = stateInitial;
   m_powerScale = powerScale;
   p_powerEvent = NULL;
   p_stateCurrent = stateInitial;
   m_powerScale = powerScale;
@@ -632,7 +632,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
            value, date);
     /* update remaining of actions and put in modified cpu swag */
     updateRemainingAmount(date);
            value, date);
     /* update remaining of actions and put in modified cpu swag */
     updateRemainingAmount(date);
-    xbt_swag_insert(this, cpu_ti_modified_cpu);
+    xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
 
     power_trace = p_availTrace->p_powerTrace;
     xbt_dynar_get_cpy(power_trace->s_list.event_list,
 
     power_trace = p_availTrace->p_powerTrace;
     xbt_dynar_get_cpy(power_trace->s_list.event_list,
@@ -667,7 +667,7 @@ void CpuTi::updateState(tmgr_trace_event_t event_type,
           action->setState(SURF_ACTION_FAILED);
           if (action->m_indexHeap >= 0) {
             CpuTiActionPtr heap_act = (CpuTiActionPtr)
           action->setState(SURF_ACTION_FAILED);
           if (action->m_indexHeap >= 0) {
             CpuTiActionPtr heap_act = (CpuTiActionPtr)
-                xbt_heap_remove(cpu_ti_action_heap, action->m_indexHeap);
+                xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
             if (heap_act != action)
               DIE_IMPOSSIBLE;
           }
@@ -745,12 +745,12 @@ updateRemainingAmount(now);
     XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap);
     if (action->m_indexHeap >= 0) {
       CpuTiActionPtr heap_act = (CpuTiActionPtr)
     XBT_DEBUG("action(%p) index %d", action, action->m_indexHeap);
     if (action->m_indexHeap >= 0) {
       CpuTiActionPtr heap_act = (CpuTiActionPtr)
-          xbt_heap_remove(cpu_ti_action_heap, action->m_indexHeap);
+          xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action->m_indexHeap);
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
     if (min_finish != NO_MAX_DURATION)
       if (heap_act != action)
         DIE_IMPOSSIBLE;
     }
     if (min_finish != NO_MAX_DURATION)
-      xbt_heap_push(cpu_ti_action_heap, action, min_finish);
+      xbt_heap_push(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, action, min_finish);
 
     XBT_DEBUG
         ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
 
     XBT_DEBUG
         ("Update finish time: Cpu(%s) Action: %p, Start Time: %f Finish Time: %f Max duration %f",
@@ -759,7 +759,7 @@ updateRemainingAmount(now);
          action->m_maxDuration);
   }
 /* remove from modified cpu */
          action->m_maxDuration);
   }
 /* remove from modified cpu */
-  xbt_swag_remove(this, cpu_ti_modified_cpu);
+  xbt_swag_remove(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
 }
 
 bool CpuTi::isUsed()
 }
 
 bool CpuTi::isUsed()
@@ -842,7 +842,7 @@ CpuTiActionPtr CpuTi::_execute(double size)
   action->p_cpu = this;
   action->m_indexHeap = -1;
 
   action->p_cpu = this;
   action->m_indexHeap = -1;
 
-  xbt_swag_insert(this, cpu_ti_modified_cpu);
+  xbt_swag_insert(this, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
 
   xbt_swag_insert(action, p_actionSet);
 
 
   xbt_swag_insert(action, p_actionSet);
 
@@ -867,7 +867,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  */
     xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
     /* Move to the *end* of the corresponding action set. This convention
        is used to speed up update_resource_state  */
     xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
-    action->p_stateSet = cpu_ti_running_action_set_that_does_not_need_being_checked;
+    action->p_stateSet = reinterpret_cast<CpuTiModelPtr>(p_model)->p_runningActionSetThatDoesNotNeedBeingChecked;
     xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
   XBT_OUT();
     xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
   }
   XBT_OUT();
@@ -894,7 +894,7 @@ void CpuTiAction::updateIndexHeap(int i)
 void CpuTiAction::setState(e_surf_action_state_t state)
 {
   Action::setState(state);
 void CpuTiAction::setState(e_surf_action_state_t state)
 {
   Action::setState(state);
-  xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
 }
 
 int CpuTiAction::unref()
 }
 
 int CpuTiAction::unref()
@@ -905,8 +905,8 @@ int CpuTiAction::unref()
     /* remove from action_set */
     xbt_swag_remove(this, p_cpu->p_actionSet);
     /* remove from heap */
     /* remove from action_set */
     xbt_swag_remove(this, p_cpu->p_actionSet);
     /* remove from heap */
-    xbt_heap_remove(cpu_ti_action_heap, this->m_indexHeap);
-    xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+    xbt_heap_remove(reinterpret_cast<CpuTiModelPtr>(p_model)->p_tiActionHeap, this->m_indexHeap);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
     delete this;
     return 1;
   }
     delete this;
     return 1;
   }
@@ -916,8 +916,8 @@ int CpuTiAction::unref()
 void CpuTiAction::cancel()
 {
   this->setState(SURF_ACTION_FAILED);
 void CpuTiAction::cancel()
 {
   this->setState(SURF_ACTION_FAILED);
-  xbt_heap_remove(cpu_ti_action_heap, this->m_indexHeap);
-  xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+  xbt_heap_remove(p_model->p_actionHeap, this->m_indexHeap);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
   return;
 }
 
   return;
 }
 
@@ -931,8 +931,8 @@ void CpuTiAction::suspend()
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 1;
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 1;
-    xbt_heap_remove(cpu_ti_action_heap, m_indexHeap);
-    xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+    xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -942,7 +942,7 @@ void CpuTiAction::resume()
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 0;
   XBT_IN("(%p)", this);
   if (m_suspended != 2) {
     m_suspended = 0;
-    xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+    xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
   }
   XBT_OUT();
 }
   }
   XBT_OUT();
 }
@@ -969,11 +969,11 @@ void CpuTiAction::setMaxDuration(double duration)
 /* add in action heap */
   if (m_indexHeap >= 0) {
     CpuTiActionPtr heap_act = (CpuTiActionPtr)
 /* add in action heap */
   if (m_indexHeap >= 0) {
     CpuTiActionPtr heap_act = (CpuTiActionPtr)
-        xbt_heap_remove(cpu_ti_action_heap, m_indexHeap);
+        xbt_heap_remove(p_model->p_actionHeap, m_indexHeap);
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
     if (heap_act != this)
       DIE_IMPOSSIBLE;
   }
-  xbt_heap_push(cpu_ti_action_heap, this, min_finish);
+  xbt_heap_push(p_model->p_actionHeap, this, min_finish);
 
   XBT_OUT();
 }
 
   XBT_OUT();
 }
@@ -982,7 +982,7 @@ void CpuTiAction::setPriority(double priority)
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
 {
   XBT_IN("(%p,%g)", this, priority);
   m_priority = priority;
-  xbt_swag_insert(p_cpu, cpu_ti_modified_cpu);
+  xbt_swag_insert(p_cpu, reinterpret_cast<CpuTiModelPtr>(p_model)->p_modifiedCpu);
   XBT_OUT();
 }
 
   XBT_OUT();
 }
 
index eb31b86..edf240e 100644 (file)
@@ -92,6 +92,10 @@ public:
   void updateActionsState(double now, double delta);
   void addTraces();
 
   void updateActionsState(double now, double delta);
   void addTraces();
 
+  xbt_swag_t p_runningActionSetThatDoesNotNeedBeingChecked;
+  xbt_swag_t p_modifiedCpu;
+  xbt_heap_t p_tiActionHeap;
+
 protected:
   void NotifyResourceTurnedOn(ResourcePtr){};
   void NotifyResourceTurnedOff(ResourcePtr){};
 protected:
   void NotifyResourceTurnedOn(ResourcePtr){};
   void NotifyResourceTurnedOff(ResourcePtr){};
index 97deb3d..55e6e3c 100644 (file)
@@ -80,7 +80,7 @@ ActionPtr NetworkConstantModel::communicate(RoutingEdgePtr src, RoutingEdgePtr d
   char *dst_name = dst->p_name;
 
   XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
   char *dst_name = dst->p_name;
 
   XBT_IN("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
-  NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, sg_latency_factor);
+  NetworkConstantActionLmmPtr action = new NetworkConstantActionLmm(this, size, sg_latency_factor);
   XBT_OUT();
 
   return action;
   XBT_OUT();
 
   return action;
index c9c140d..dc1c416 100644 (file)
@@ -48,8 +48,8 @@ public:
  **********/
 class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
 public:
  **********/
 class NetworkConstantActionLmm : public NetworkCm02ActionLmm {
 public:
-  NetworkConstantActionLmm(NetworkConstantModelPtr model, double latency):
-         Action(model, 0, false), NetworkCm02ActionLmm(model, 0, false), m_latInit(latency) {
+  NetworkConstantActionLmm(NetworkConstantModelPtr model, double size, double latency):
+         Action(model, size, false), NetworkCm02ActionLmm(model, 0, false), m_latInit(latency) {
        m_latency = latency;
        if (m_latency <= 0.0) {
          p_stateSet = p_model->p_doneActionSet;
        m_latency = latency;
        if (m_latency <= 0.0) {
          p_stateSet = p_model->p_doneActionSet;
index ee63af4..b8f653e 100644 (file)
@@ -757,7 +757,8 @@ Action::Action(ModelPtr model, double cost, bool failed):
          m_maxDuration(NO_MAX_DURATION),
          m_cost(cost),
          p_model(model),
          m_maxDuration(NO_MAX_DURATION),
          m_cost(cost),
          p_model(model),
-         m_refcount(1)
+         m_refcount(1),
+         p_data(NULL)
 {
   #ifdef HAVE_TRACING
     p_category = NULL;
 {
   #ifdef HAVE_TRACING
     p_category = NULL;
index 770c293..7a6b91b 100644 (file)
@@ -205,7 +205,9 @@ private:
 
 class ResourceLmm: virtual public Resource {
 public:
 
 class ResourceLmm: virtual public Resource {
 public:
-  ResourceLmm() { p_power.event = NULL; };
+  ResourceLmm() : p_constraint(NULL) {
+       p_power.event = NULL;
+  };
   ResourceLmm(surf_model_t model, const char *name, xbt_dict_t props,
                            lmm_system_t system,
                            double constraint_value,
   ResourceLmm(surf_model_t model, const char *name, xbt_dict_t props,
                            lmm_system_t system,
                            double constraint_value,
@@ -214,7 +216,8 @@ public:
                            tmgr_trace_t state_trace,
                            double metric_peak,
                            tmgr_trace_t metric_trace);
                            tmgr_trace_t state_trace,
                            double metric_peak,
                            tmgr_trace_t metric_trace);
-  ~ResourceLmm() {};
+  ~ResourceLmm() {
+  };
   lmm_constraint_t p_constraint;
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
   lmm_constraint_t p_constraint;
   tmgr_trace_event_t p_stateEvent;
   s_surf_metric_t p_power;
@@ -276,7 +279,7 @@ protected:
   int    m_refcount;
 #ifdef HAVE_TRACING
 #endif
   int    m_refcount;
 #ifdef HAVE_TRACING
 #endif
-  e_UM_t p_updateMechanism;
+  //FIXME:removee_UM_t p_updateMechanism;
 
 private:
   int resourceUsed(void *resource_id);
 
 private:
   int resourceUsed(void *resource_id);
index 4f2dbc6..6f868cc 100644 (file)
@@ -6,7 +6,6 @@
  */
 #include "vm_workstation.hpp"
 #include "cpu_cas01.hpp"
  */
 #include "vm_workstation.hpp"
 #include "cpu_cas01.hpp"
-#include "maxmin_private.h"
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
 
 extern "C" {
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_vm_workstation, surf,
@@ -40,7 +39,7 @@ void WorkstationVMModel::createResource(const char *name, void *ind_phys_worksta
 {
   WorkstationVM2013LmmPtr ws = new WorkstationVM2013Lmm(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
 
 {
   WorkstationVM2013LmmPtr ws = new WorkstationVM2013Lmm(this, name, NULL, static_cast<surf_resource_t>(ind_phys_workstation));
 
-  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, ws);
+  xbt_lib_set(host_lib, name, SURF_WKS_LEVEL, static_cast<ResourcePtr>(ws));
 
   /* TODO:
    * - check how network requests are scheduled between distinct processes competing for the same card.
 
   /* TODO:
    * - check how network requests are scheduled between distinct processes competing for the same card.
@@ -180,7 +179,6 @@ double WorkstationVMModel::shareResources(double now)
 /************
  * Resource *
  ************/
 /************
  * Resource *
  ************/
-
 WorkstationVM2013Lmm::WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
                                                   surf_resource_t ind_phys_workstation)
   :  Resource(model, name, props),
 WorkstationVM2013Lmm::WorkstationVM2013Lmm(WorkstationVMModelPtr model, const char* name, xbt_dict_t props,
                                                   surf_resource_t ind_phys_workstation)
   :  Resource(model, name, props),
@@ -215,7 +213,7 @@ WorkstationVM2013Lmm::WorkstationVM2013Lmm(WorkstationVMModelPtr model, const ch
   /* We can assume one core and cas01 cpu for the first step.
    * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */
 
   /* We can assume one core and cas01 cpu for the first step.
    * Do xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu) if you get the resource. */
 
-  static_cast<CpuCas01ModelPtr>(surf_cpu_model_vm)->createResource(name, // name
+  p_cpu = static_cast<CpuCas01ModelPtr>(surf_cpu_model_vm)->createResource(name, // name
       sub_cpu->p_powerPeakList,        // host->power_peak,
       sub_cpu->m_pstate,
       1,                          // host->power_scale,
       sub_cpu->p_powerPeakList,        // host->power_peak,
       sub_cpu->m_pstate,
       1,                          // host->power_scale,
@@ -272,17 +270,7 @@ WorkstationVM2013Lmm::~WorkstationVM2013Lmm()
   int ret = p_action->unref();
   xbt_assert(ret == 1, "Bug: some resource still remains");
 
   int ret = p_action->unref();
   xbt_assert(ret == 1, "Bug: some resource still remains");
 
-  /* Free the cpu resource of the VM. If using power_trace, we will have to
-   * free other objects than lmm_constraint. */
-  lmm_constraint_free(cpu->p_model->p_maxminSystem, cpu->p_constraint);
-  for (int i = 0; i < cpu->m_core; i++) {
-    void *cnst_id = cpu->p_constraintCore[i]->id;
-    lmm_constraint_free(cpu->p_model->p_maxminSystem, cpu->p_constraintCore[i]);
-    xbt_free(cnst_id);
-  }
-
-  xbt_free(cpu->p_constraintCore);
-
+  /* Free the cpu resource of the VM. If using power_trace, we will have to */
   delete cpu;
 
   /* Free the network resource of the VM. */
   delete cpu;
 
   /* Free the network resource of the VM. */
index d4d810a..383ff77 100644 (file)
@@ -470,7 +470,7 @@ double WorkstationL07::getConsumedEnergy()
 }
 
 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
 }
 
 CpuL07::CpuL07(CpuL07ModelPtr model, const char* name, xbt_dict_t props)
- : Resource(model, name, props), CpuLmm(model, name, props) {
+ : Resource(model, name, props), CpuLmm() {
 
 }
 
 
 }