Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanups in CpuCas01: overrides, initialize fields, kill non-obviously dead code
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 3 Jan 2016 21:45:46 +0000 (22:45 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 3 Jan 2016 21:53:35 +0000 (22:53 +0100)
src/surf/cpu_cas01.cpp
src/surf/cpu_cas01.hpp
src/surf/surf_interface.hpp

index 26df06f..d38b452 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2011, 2013-2015. The SimGrid Team.
+/* Copyright (c) 2009-2011, 2013-2016. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -17,25 +17,22 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu,
  *********/
 void surf_cpu_model_init_Cas01()
 {
  *********/
 void surf_cpu_model_init_Cas01()
 {
-  char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
-
   xbt_assert(!surf_cpu_model_pm);
   xbt_assert(!surf_cpu_model_vm);
 
   xbt_assert(!surf_cpu_model_pm);
   xbt_assert(!surf_cpu_model_vm);
 
+  char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
   if (!strcmp(optim, "TI")) {
     surf_cpu_model_init_ti();
     return;
   }
 
   surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
   if (!strcmp(optim, "TI")) {
     surf_cpu_model_init_ti();
     return;
   }
 
   surf_cpu_model_pm = new simgrid::surf::CpuCas01Model();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_pm);
+
   surf_cpu_model_vm  = new simgrid::surf::CpuCas01Model();
   surf_cpu_model_vm  = new simgrid::surf::CpuCas01Model();
+  xbt_dynar_push(all_existing_models, &surf_cpu_model_vm);
 
   sg_platf_postparse_add_cb(simgrid::surf::cpu_add_traces);
 
   sg_platf_postparse_add_cb(simgrid::surf::cpu_add_traces);
-
-  simgrid::surf::Model *model_pm = surf_cpu_model_pm;
-  simgrid::surf::Model *model_vm = surf_cpu_model_vm;
-  xbt_dynar_push(all_existing_models, &model_pm);
-  xbt_dynar_push(all_existing_models, &model_vm);
 }
 
 namespace simgrid {
 }
 
 namespace simgrid {
@@ -63,19 +60,7 @@ CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
 
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
 
 
   p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
 
-  if (getUpdateMechanism() == UM_LAZY) {
-       shareResources = &CpuCas01Model::shareResourcesLazy;
-       updateActionsState = &CpuCas01Model::updateActionsStateLazy;
-
-  } else if (getUpdateMechanism() == UM_FULL) {
-       shareResources = &CpuCas01Model::shareResourcesFull;
-       updateActionsState = &CpuCas01Model::updateActionsStateFull;
-  } else
-    xbt_die("Invalid cpu update mechanism!");
-
-  if (!p_maxminSystem) {
-    p_maxminSystem = lmm_system_new(m_selectiveUpdate);
-  }
+  p_maxminSystem = lmm_system_new(m_selectiveUpdate);
 
   if (getUpdateMechanism() == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
 
   if (getUpdateMechanism() == UM_LAZY) {
     p_actionHeap = xbt_heap_new(8, NULL);
@@ -303,11 +288,6 @@ CpuAction *CpuCas01::sleep(double duration)
   return action;
 }
 
   return action;
 }
 
-double CpuCas01::getCurrentPowerPeak()
-{
-  return m_speedPeak;
-}
-
 /**********
  * Action *
  **********/
 /**********
  * Action *
  **********/
index 294b8d7..d3e1275 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2013-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2013-2016. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -28,16 +27,13 @@ public:
   CpuCas01Model();
   ~CpuCas01Model();
 
   CpuCas01Model();
   ~CpuCas01Model();
 
-  double (CpuCas01Model::*shareResources)(double now);
-  void (CpuCas01Model::*updateActionsState)(double now, double delta);
-
   Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, int pstate,
                    double speedScale,
                           tmgr_trace_t speedTrace, int core,
                           e_surf_resource_state_t state_initial,
   Cpu *createCpu(simgrid::Host *host, xbt_dynar_t speedPeak, int pstate,
                    double speedScale,
                           tmgr_trace_t speedTrace, int core,
                           e_surf_resource_state_t state_initial,
-                          tmgr_trace_t state_trace);
-  double shareResourcesFull(double now);
-  void addTraces();
+                          tmgr_trace_t state_trace) override;
+  double shareResourcesFull(double now) override;
+  void addTraces() override;
   ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
 };
 
   ActionList *p_cpuRunningActionSetThatDoesNotNeedBeingChecked;
 };
 
@@ -51,17 +47,17 @@ public:
         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ;
   ~CpuCas01();
         int pstate, double speedScale, tmgr_trace_t speedTrace, int core,
         e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace) ;
   ~CpuCas01();
-  void updateState(tmgr_trace_event_t event_type, double value, double date);
-  CpuAction *execute(double size);
-  CpuAction *sleep(double duration);
+  void updateState(tmgr_trace_event_t event_type, double value, double date) override;
+  CpuAction *execute(double size) override;
+  CpuAction *sleep(double duration) override;
 
 
-  double getCurrentPowerPeak();
   bool isUsed() override;
   void setStateEvent(tmgr_trace_event_t stateEvent);
   void setPowerEvent(tmgr_trace_event_t stateEvent);
   bool isUsed() override;
   void setStateEvent(tmgr_trace_event_t stateEvent);
   void setPowerEvent(tmgr_trace_event_t stateEvent);
-  xbt_dynar_t getSpeedPeakList();
 
 
+  xbt_dynar_t getSpeedPeakList();
 private:
 private:
+
   tmgr_trace_event_t p_stateEvent;
   tmgr_trace_event_t p_speedEvent;
 };
   tmgr_trace_event_t p_stateEvent;
   tmgr_trace_event_t p_speedEvent;
 };
index f175f4c..516a2c9 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2004-2015. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2004-2016. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -378,7 +377,7 @@ public:
 
 protected:
   ActionLmmListPtr p_modifiedSet;
 
 protected:
   ActionLmmListPtr p_modifiedSet;
-  lmm_system_t p_maxminSystem;
+  lmm_system_t p_maxminSystem = nullptr;
   e_UM_t p_updateMechanism = UM_UNDEFINED;
   int m_selectiveUpdate;
   xbt_heap_t p_actionHeap;
   e_UM_t p_updateMechanism = UM_UNDEFINED;
   int m_selectiveUpdate;
   xbt_heap_t p_actionHeap;