Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
code simplification: we don't use non-LMM resources
authorMartin Quinson <martin.quinson@loria.fr>
Sat, 12 Nov 2016 00:50:17 +0000 (01:50 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sat, 12 Nov 2016 00:50:20 +0000 (01:50 +0100)
there was a specific constructor for non-LMM resources that was not
given the lmm constraint, which leaded to many dupplicated code.

But actually, this is not needed: NetworkConstant does not create a
link resource anyway, and NS3 can easily pass nullptr to the
constructor of its ancestor.

src/surf/network_cm02.cpp
src/surf/network_interface.cpp
src/surf/network_interface.hpp
src/surf/network_ns3.cpp
src/surf/ptask_L07.cpp
src/surf/storage_interface.cpp
src/surf/storage_interface.hpp
src/surf/surf_interface.cpp
src/surf/surf_interface.hpp
teshsuite/surf/trace_usage/trace_usage.cpp

index 64dad5a..0824bdb 100644 (file)
@@ -395,10 +395,9 @@ void NetworkCm02Model::gapAppend(double size, const Link* link, NetworkAction* a
 /************
  * Resource *
  ************/
-NetworkCm02Link::NetworkCm02Link(NetworkCm02Model *model, const char *name, xbt_dict_t props,
-    double bandwidth,  double latency, e_surf_link_sharing_policy_t policy,
-    lmm_system_t system)
-: Link(model, name, props, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth))
+NetworkCm02Link::NetworkCm02Link(NetworkCm02Model* model, const char* name, xbt_dict_t props, double bandwidth,
+                                 double latency, e_surf_link_sharing_policy_t policy, lmm_system_t system)
+    : Link(model, name, lmm_constraint_new(system, this, sg_bandwidth_factor * bandwidth), props)
 {
   bandwidth_.scale = 1.0;
   bandwidth_.peak  = bandwidth;
index a961155..493b71b 100644 (file)
@@ -147,20 +147,8 @@ namespace simgrid {
      * Resource *
      ************/
 
-    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props)
-    : Resource(model, name),
-      PropertyHolder(props)
-    {
-      links->insert({name, this});
-
-      latency_.scale   = 1;
-      bandwidth_.scale = 1;
-      XBT_DEBUG("Create link '%s'",name);
-    }
-
-    Link::Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint)
-    : Resource(model, name, constraint),
-      PropertyHolder(props)
+    Link::Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props)
+        : Resource(model, name, constraint), PropertyHolder(props)
     {
       if (strcmp(name,"__loopback__"))
         xbt_assert(!Link::byName(name), "Link '%s' declared several times in the platform.", name);
index 8db0f58..1354e73 100644 (file)
@@ -134,13 +134,11 @@ namespace simgrid {
         public simgrid::surf::PropertyHolder {
         public:
 
-      /** @brief Constructor of non-LMM links */
-      Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props);
       /** @brief Constructor of LMM links */
-      Link(simgrid::surf::NetworkModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint);
+          Link(simgrid::surf::NetworkModel* model, const char* name, lmm_constraint_t constraint, xbt_dict_t props);
 
-      /* Link destruction logic */
-      /**************************/
+          /* Link destruction logic */
+          /**************************/
         protected:
       ~Link() override;
         public:
index 48d8d1e..d4b933b 100644 (file)
@@ -283,8 +283,8 @@ void NetworkNS3Model::updateActionsState(double now, double delta)
  * Resource *
  ************/
 
-LinkNS3::LinkNS3(NetworkNS3Model *model, const char *name, xbt_dict_t props, double bandwidth, double latency)
: Link(model, name, props)
+LinkNS3::LinkNS3(NetworkNS3Model* model, const char* name, xbt_dict_t props, double bandwidth, double latency)
   : Link(model, name, nullptr, props)
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
index 733681e..33f500d 100644 (file)
@@ -259,17 +259,17 @@ Link* NetworkL07Model::createLink(const char *name, double bandwidth, double lat
  * Resource *
  ************/
 
-CpuL07::CpuL07(CpuL07Model *model, simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core)
- : Cpu(model, host, speedPerPstate, core)
+CpuL07::CpuL07(CpuL07Model* model, simgrid::s4u::Host* host, std::vector<double>* speedPerPstate, int core)
+    : Cpu(model, host, lmm_constraint_new(model->getMaxminSystem(), this, speedPerPstate->front()), speedPerPstate,
+          core)
 {
-  constraint_ = lmm_constraint_new(model->getMaxminSystem(), this, speedPerPstate->front());
 }
 
 CpuL07::~CpuL07()=default;
 
-LinkL07::LinkL07(NetworkL07Model *model, const char* name, xbt_dict_t props, double bandwidth, double latency,
-             e_surf_link_sharing_policy_t policy)
: Link(model, name, props, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth))
+LinkL07::LinkL07(NetworkL07Modelmodel, const char* name, xbt_dict_t props, double bandwidth, double latency,
+                 e_surf_link_sharing_policy_t policy)
   : Link(model, name, lmm_constraint_new(model->getMaxminSystem(), this, bandwidth), props)
 {
   bandwidth_.peak = bandwidth;
   latency_.peak   = latency;
index 9362187..c2ae47c 100644 (file)
@@ -49,20 +49,6 @@ StorageModel::~StorageModel(){
  * Resource *
  ************/
 
-Storage::Storage(Model *model, const char *name, xbt_dict_t props,
-                 const char* type_id, const char *content_name, const char *content_type,
-                 sg_size_t size)
- : Resource(model, name)
- , PropertyHolder(props)
- , contentType_(xbt_strdup(content_type))
- , size_(size), usedSize_(0)
- , typeId_(xbt_strdup(type_id))
- , writeActions_(std::vector<StorageAction*>())
-{
-  content_ = parseContent(content_name);
-  turnOn();
-}
-
 Storage::Storage(Model *model, const char *name, xbt_dict_t props,
                  lmm_system_t maxminSystem, double bread, double bwrite,
                  double bconnection, const char* type_id, const char *content_name,
index ce61419..e271c9b 100644 (file)
@@ -81,20 +81,6 @@ public:
 class Storage : public simgrid::surf::Resource,
         public simgrid::surf::PropertyHolder {
 public:
-  /**
-   * @brief Storage constructor
-   *
-   * @param model StorageModel associated to this Storage
-   * @param name The name of the Storage
-   * @param props Dictionary of properties associated to this Storage
-   * @param type_id [description]
-   * @param content_name [description]
-   * @param content_type [description]
-   * @param size [description]
-   */
-  Storage(Model *model, const char *name, xbt_dict_t props,
-          const char* type_id, const char *content_name, const char *content_type,
-          sg_size_t size);
 
   /**
    * @brief Storage constructor
index 76d1f3e..50107a3 100644 (file)
@@ -528,11 +528,6 @@ void Model::updateActionsStateFull(double /*now*/, double /*delta*/)
 namespace simgrid {
 namespace surf {
 
-Resource::Resource(Model *model, const char *name)
-  : name_(xbt_strdup(name))
-  , model_(model)
-{}
-
 Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
   : name_(xbt_strdup(name))
   , model_(model)
@@ -540,7 +535,7 @@ Resource::Resource(Model *model, const char *name, lmm_constraint_t constraint)
 {}
 
 Resource::~Resource() {
-  xbt_free((void*)name_);
+  free(name_);
 }
 
 bool Resource::isOn() const {
index daf878b..42f4c85 100644 (file)
@@ -383,14 +383,6 @@ namespace surf {
  */
 XBT_PUBLIC_CLASS Resource {
 public:
-  /**
-   * @brief Constructor of non-LMM Resources
-   *
-   * @param model Model associated to this Resource
-   * @param name The name of the Resource
-   */
-  Resource(Model *model, const char *name);
-
   /**
    * @brief Constructor of LMM Resources
    *
@@ -431,7 +423,7 @@ public:
   virtual void turnOff();
 
 private:
-  const char *name_;
+  char* name_;
   Model *model_;
   bool isOn_ = true;
 
@@ -439,7 +431,7 @@ public: /* LMM */
   /** @brief Get the lmm constraint associated to this Resource if it is part of a LMM component (or null if none) */
   lmm_constraint_t getConstraint() const;
 protected:
-  lmm_constraint_t constraint_ = nullptr;
+  const lmm_constraint_t constraint_ = nullptr;
 };
 
 }
index 07efaf9..07441cf 100644 (file)
@@ -16,7 +16,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
 class DummyTestResource
     : public simgrid::surf::Resource {
 public:
-  explicit DummyTestResource(const char *name) : Resource(nullptr,name) {}
+  explicit DummyTestResource(const char* name) : Resource(nullptr, name, nullptr) {}
   bool isUsed() override {return false;}
   void apply_event(tmgr_trace_iterator_t it, double value) override {}
 };