Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup the declaration and handling of the cpu/optim option
[simgrid.git] / src / surf / cpu_cas01.hpp
index 7b2a76e..7683a08 100644 (file)
@@ -1,64 +1,74 @@
-#include "cpu.hpp"
+/* Copyright (c) 2013-2018. 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. */
+
+#include <xbt/base.h>
+
+#include "cpu_interface.hpp"
 
 /***********
  * Classes *
  ***********/
-class CpuCas01Model;
-typedef CpuCas01Model *CpuCas01ModelPtr;
 
-class CpuCas01Lmm;
-typedef CpuCas01Lmm *CpuCas01LmmPtr;
+namespace simgrid {
+namespace surf {
 
-class CpuCas01ActionLmm;
-typedef CpuCas01ActionLmm *CpuCas01ActionLmmPtr;
+class XBT_PRIVATE CpuCas01Model;
+class XBT_PRIVATE CpuCas01;
+class XBT_PRIVATE CpuCas01Action;
 
 /*********
  * Model *
  *********/
-class CpuCas01Model : public CpuModel {
+
+class CpuCas01Model : public simgrid::surf::CpuModel {
 public:
-  CpuCas01Model();
-  ~CpuCas01Model();
-
-  double (CpuCas01Model::*shareResources)(double now);
-  void (CpuCas01Model::*updateActionsState)(double now, double delta);
-
-  void parseInit(sg_platf_host_cbarg_t host);  
-  CpuCas01LmmPtr createResource(const char *name, double power_peak, 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);
-  double shareResourcesFull(double now);  
-  void addTraces();
+  CpuCas01Model(bool optim_lazy);
+  ~CpuCas01Model() override;
+
+  Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
+  kernel::resource::Action::StateSet cpuRunningActionSetThatDoesNotNeedBeingChecked_;
 };
 
 /************
  * Resource *
  ************/
-class CpuCas01Lmm : public CpuLmm {
+
+class CpuCas01 : public Cpu {
 public:
-  CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, double powerPeak,
-        double powerScale, tmgr_trace_t powerTrace, int core,
-        e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
-       xbt_dict_t properties) ;
-  void updateState(tmgr_trace_event_t event_type, double value, double date);
-  CpuActionPtr execute(double size);
-  CpuActionPtr sleep(double duration);
+  CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core);
+  ~CpuCas01() override;
+  void apply_event(tmgr_trace_event_t event, double value) override;
+  CpuAction* execution_start(double size) override;
+  CpuAction* execution_start(double size, int requestedCore) override;
+  CpuAction* sleep(double duration) override;
+
+  bool isUsed() override;
 
-  bool isUsed();
+  std::vector<double> * getSpeedPeakList(); // FIXME: killme to hide our internals
 
-  tmgr_trace_event_t p_powerEvent;
+protected:
+  void onSpeedChange() override;
 };
 
 /**********
  * Action *
  **********/
-class CpuCas01ActionLmm: public CpuActionLmm {
+class CpuCas01Action: public CpuAction {
+  friend CpuAction *CpuCas01::execution_start(double size);
+  friend CpuAction *CpuCas01::sleep(double duration);
 public:
-  CpuCas01ActionLmm() {};
-  CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): CpuActionLmm(model, cost, failed) {};
-  int unref() {return 0;};//TODO
-  void cancel() {};//TODO
-  void recycle() {};//TODO
+  CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed,
+                 kernel::lmm::Constraint* constraint, int coreAmount);
+  CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed,
+                 kernel::lmm::Constraint* constraint);
+  ~CpuCas01Action() override;
+  int requestedCore();
+
+private:
+  int requestedCore_ = 1;
 };
+
+}
+}