Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make HostL07 behave more like the regular Host
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 25 Nov 2015 23:57:41 +0000 (00:57 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 25 Nov 2015 23:57:41 +0000 (00:57 +0100)
The methods execute() and sleep() were implemented directly in the
host, and the virtual functions in the cpu were implemented with a
DIE_IMPOSSIBLE.

Instead, HostL07 is dispatching the execute() and sleep() calls that
it gets from the higher layers to its CpuL07, just as any Host.

The goal is to kill HostL07 and just use a regular Host dispatching
*every* call to its CPU and RoutingEdge. Then, Host will be made part
of the public interface (simgrid::Host will offer the interface of
S4U::Host with the content of surf::Host).

src/surf/cpu_interface.hpp
src/surf/host_ptask_L07.cpp
src/surf/host_ptask_L07.hpp

index be93fb8..7de27b3 100644 (file)
@@ -142,7 +142,7 @@ public:
    * @param size The value of the processing amount (in flop) needed to process
    * @return The CpuAction corresponding to the processing
    */
-  virtual CpuAction *execute(double size)=0;
+  virtual Action *execute(double size)=0;
 
   /**
    * @brief Make a process sleep for duration (in seconds)
@@ -150,7 +150,7 @@ public:
    * @param duration The number of seconds to sleep
    * @return The CpuAction corresponding to the sleeping
    */
-  virtual CpuAction *sleep(double duration)=0;
+  virtual Action *sleep(double duration)=0;
 
   /** @brief Get the number of cores of the current Cpu */
   virtual int getCore();
index f7af590..c092c28 100644 (file)
@@ -486,6 +486,35 @@ LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props,
        lmm_constraint_shared(getConstraint());
 }
 
+Action *CpuL07::execute(double size)
+{
+  sg_host_t*host_list = xbt_new0(sg_host_t, 1);
+  double *flops_amount = xbt_new0(double, 1);
+  double *bytes_amount = xbt_new0(double, 1);
+
+  host_list[0] = sg_host_by_name(getName());
+  flops_amount[0] = size;
+
+  return static_cast<HostL07Model*>(getModel())->executeParallelTask(1, host_list,
+                                             flops_amount,
+                                     bytes_amount, -1);
+}
+
+Action *CpuL07::sleep(double duration)
+{
+  L07Action *action = NULL;
+
+  XBT_IN("(%s,%g)", getName(), duration);
+
+  action = static_cast<L07Action*>(execute(1.0));
+  action->m_maxDuration = duration;
+  action->m_suspended = 2;
+  lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
+
+  XBT_OUT();
+  return action;
+}
+
 bool CpuL07::isUsed(){
   return lmm_constraint_used(ptask_maxmin_system, getConstraint());
 }
@@ -543,34 +572,6 @@ e_surf_resource_state_t HostL07::getState() {
   return p_cpu->getState();
 }
 
-Action *HostL07::execute(double size)
-{
-  sg_host_t*host_list = xbt_new0(sg_host_t, 1);
-  double *flops_amount = xbt_new0(double, 1);
-  double *bytes_amount = xbt_new0(double, 1);
-
-  host_list[0] = sg_host_by_name(getName());
-  flops_amount[0] = size;
-
-  return static_cast<HostL07Model*>(getModel())->executeParallelTask(1, host_list,
-                                             flops_amount,
-                                     bytes_amount, -1);
-}
-
-Action *HostL07::sleep(double duration)
-{
-  L07Action *action = NULL;
-
-  XBT_IN("(%s,%g)", getName(), duration);
-
-  action = static_cast<L07Action*>(execute(1.0));
-  action->m_maxDuration = duration;
-  action->m_suspended = 2;
-  lmm_update_variable_weight(ptask_maxmin_system, action->getVariable(), 0.0);
-
-  XBT_OUT();
-  return action;
-}
 
 double LinkL07::getBandwidth()
 {
index 34d7a2c..5264a84 100644 (file)
@@ -93,11 +93,10 @@ public:
 class HostL07 : public Host {
 public:
   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;};
-  Action *execute(double size);
-  Action *sleep(double duration);
+  Action *execute(double size) {return p_cpu->execute(size);};
+  Action *sleep(double duration) {return p_cpu->sleep(duration);};
   e_surf_resource_state_t getState();
   double getPowerPeakAt(int pstate_index);
   int getNbPstates();
@@ -115,10 +114,9 @@ public:
                 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);
-  CpuAction *execute(double /*size*/) {DIE_IMPOSSIBLE;};
-  CpuAction *sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
+  Action *execute(double size);
+  Action *sleep(double duration);
 
   double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
   double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
@@ -159,8 +157,8 @@ public:
  * Action *
  **********/
 class L07Action : public HostAction {
-  friend Action *HostL07::execute(double size);
-  friend Action *HostL07::sleep(double duration);
+  friend Action *CpuL07::execute(double size);
+  friend Action *CpuL07::sleep(double duration);
   friend Action *HostL07Model::executeParallelTask(int host_nb,
                                                    sg_host_t*host_list,
                                                    double *flops_amount,