Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
These methods are overriden to the same content too
[simgrid.git] / src / surf / host_ptask_L07.hpp
index 51dd683..3754b67 100644 (file)
@@ -4,6 +4,10 @@
 /* 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 <cstdlib>
+
+#include <vector>
+
 #include <xbt/base.h>
 
 #include "host_interface.hpp"
@@ -11,6 +15,9 @@
 #ifndef HOST_L07_HPP_
 #define HOST_L07_HPP_
 
+namespace simgrid {
+namespace surf {
+
 /***********
  * Classes *
  ***********/
@@ -24,7 +31,6 @@ class XBT_PRIVATE CpuL07;
 class XBT_PRIVATE LinkL07;
 
 class XBT_PRIVATE L07Action;
-
 /*********
  * Tools *
  *********/
@@ -37,52 +43,47 @@ public:
   HostL07Model();
   ~HostL07Model();
 
-  double shareResources(double now);
-  void updateActionsState(double now, double delta);
-  Host *createHost(const char *name);
-  Action *executeParallelTask(int host_nb,
-                              sg_host_t *host_list,
-                                                         double *flops_amount,
-                                                         double *bytes_amount,
-                                                         double rate);
-  xbt_dynar_t getRoute(Host *src, Host *dst);
-  void addTraces();
-  NetworkModel *p_networkModel;
+  double shareResources(double now) override;
+  void updateActionsState(double now, double delta) override;
+  Action *executeParallelTask(int host_nb, sg_host_t *host_list,
+                                                         double *flops_amount, double *bytes_amount,
+                                                         double rate) override;
+
+  void addTraces() override;
 };
 
 class CpuL07Model : public CpuModel {
 public:
-  CpuL07Model() : CpuModel() {};
-  ~CpuL07Model() {surf_cpu_model_pm = NULL;};
-  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,
-                          tmgr_trace_t state_trace,
-                          xbt_dict_t cpu_properties);
-  void addTraces() {DIE_IMPOSSIBLE;};
+  CpuL07Model(HostL07Model *hmodel,lmm_system_t sys);
+  ~CpuL07Model();
+
+  Cpu *createCpu(simgrid::s4u::Host *host,  xbt_dynar_t speedPeakList,
+                          int pstate, double speedScale,
+                          tmgr_trace_t speedTrace, int core,
+                          int initiallyOn,
+                          tmgr_trace_t state_trace) override;
+  void addTraces() override {DIE_IMPOSSIBLE;};
 
   HostL07Model *p_hostModel;
 };
 
 class NetworkL07Model : public NetworkModel {
 public:
-  NetworkL07Model() : NetworkModel() {};
-  ~NetworkL07Model() {surf_network_model = NULL;};
+  NetworkL07Model(HostL07Model *hmodel, lmm_system_t sys);
+  ~NetworkL07Model();
   Link* createLink(const char *name,
-                                                  double bw_initial,
-                                                  tmgr_trace_t bw_trace,
-                                                  double lat_initial,
-                                                  tmgr_trace_t lat_trace,
-                                                  e_surf_resource_state_t
-                                                  state_initial,
-                                                  tmgr_trace_t state_trace,
-                                                  e_surf_link_sharing_policy_t
-                                                  policy, xbt_dict_t properties);
-
-  Action *communicate(RoutingEdge *src, RoutingEdge *dst, double size, double rate);
-  void addTraces() {DIE_IMPOSSIBLE;};
-  bool shareResourcesIsIdempotent() {return true;}
+                 double bw_initial,
+                 tmgr_trace_t bw_trace,
+                 double lat_initial,
+                 tmgr_trace_t lat_trace,
+                 int initiallyOn,
+                 tmgr_trace_t state_trace,
+                 e_surf_link_sharing_policy_t policy,
+                 xbt_dict_t properties) override;
+
+  Action *communicate(NetCard *src, NetCard *dst, double size, double rate) override;
+  void addTraces() override {DIE_IMPOSSIBLE;};
+  bool shareResourcesIsIdempotent() override {return true;}
 
   HostL07Model *p_hostModel;
 };
@@ -91,42 +92,21 @@ public:
  * Resource *
  ************/
 
-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);
-  e_surf_resource_state_t getState();
-  double getPowerPeakAt(int pstate_index);
-  int getNbPstates();
-  void setPstate(int pstate_index);
-  int  getPstate();
-  double getConsumedEnergy();
-};
-
 class CpuL07 : public Cpu {
   friend void HostL07Model::addTraces();
-  tmgr_trace_event_t p_stateEvent;
-  tmgr_trace_event_t p_powerEvent;
+  tmgr_trace_iterator_t p_stateEvent = nullptr;
+  tmgr_trace_iterator_t p_speedEvent = nullptr;
 public:
-  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);
-  CpuAction *execute(double /*size*/) {DIE_IMPOSSIBLE;};
-  CpuAction *sleep(double /*duration*/) {DIE_IMPOSSIBLE;};
-
-  double getCurrentPowerPeak() {THROW_UNIMPLEMENTED;};
-  double getPowerPeakAt(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
-  int getNbPstates() {THROW_UNIMPLEMENTED;};
-  void setPstate(int /*pstate_index*/) {THROW_UNIMPLEMENTED;};
-  int  getPstate() {THROW_UNIMPLEMENTED;};
-  double getConsumedEnergy() {THROW_UNIMPLEMENTED;};
+  CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, xbt_dynar_t speedPeakList, int pstate,
+                double power_scale, tmgr_trace_t power_trace,
+     int core, int initiallyOn, tmgr_trace_t state_trace);
+  ~CpuL07();
+  bool isUsed() override;
+  void updateState(tmgr_trace_iterator_t event_type, double value, double date) override;
+  Action *execution_start(double size) override;
+  Action *sleep(double duration) override;
+protected:
+  void onSpeedChange() override;
 };
 
 class LinkL07 : public Link {
@@ -136,58 +116,51 @@ public:
           tmgr_trace_t bw_trace,
           double lat_initial,
           tmgr_trace_t lat_trace,
-          e_surf_resource_state_t
-          state_initial,
+          int initiallyOn,
           tmgr_trace_t state_trace,
           e_surf_link_sharing_policy_t policy);
-  ~LinkL07(){
-  };
-  bool isUsed();
-  void updateState(tmgr_trace_event_t event_type, double value, double date);
-  double getBandwidth();
-  double getLatency();
-  bool isShared();
-  void updateBandwidth(double value, double date=surf_get_clock());
-  void updateLatency(double value, double date=surf_get_clock());
-
-  double m_latCurrent;
-  tmgr_trace_event_t p_latEvent;
+  ~LinkL07(){ };
+  bool isUsed() override;
+  void updateState(tmgr_trace_iterator_t event_type, double value, double date) override;
+  double getBandwidth() override;
+  void updateBandwidth(double value, double date=surf_get_clock()) override;
+  void updateLatency(double value, double date=surf_get_clock()) override;
+
   double m_bwCurrent;
-  tmgr_trace_event_t p_bwEvent;
+  tmgr_trace_iterator_t p_bwEvent;
 };
 
 /**********
  * Action *
  **********/
-class L07Action : public HostAction {
-  friend Action *HostL07::execute(double size);
-  friend Action *HostL07::sleep(double duration);
+class L07Action : public CpuAction {
+  friend Action *CpuL07::execution_start(double size);
+  friend Action *CpuL07::sleep(double duration);
   friend Action *HostL07Model::executeParallelTask(int host_nb,
                                                    sg_host_t*host_list,
                                                    double *flops_amount,
-                                                                                                  double *bytes_amount,
+                                                   double *bytes_amount,
                                                    double rate);
 public:
-  L07Action(Model *model, double cost, bool failed)
-  : HostAction(model, cost, failed) {};
+  L07Action(Model *model, int host_nb,
+          sg_host_t*host_list,
+          double *flops_amount,
+                  double *bytes_amount,
+          double rate);
  ~L07Action();
 
   void updateBound();
 
-  int unref();
-  void cancel();
-  void suspend();
-  void resume();
-  bool isSuspended();
-  void setMaxDuration(double duration);
-  void setPriority(double priority);
-  double getRemains();
+  int unref() override;
 
-  vector<RoutingEdge*> * p_edgeList = new vector<RoutingEdge*>();
+  std::vector<NetCard*> * p_netcardList = new std::vector<NetCard*>();
   double *p_computationAmount;
   double *p_communicationAmount;
   double m_latency;
   double m_rate;
 };
 
+}
+}
+
 #endif /* HOST_L07_HPP_ */