Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
One method to set netzone's relationship
authorBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 6 Apr 2021 08:27:02 +0000 (10:27 +0200)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Tue, 6 Apr 2021 08:27:02 +0000 (10:27 +0200)
A netzone is child of its parent, set_parent() is enough to determine
the relationship parent/child of netzones.

include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/s4u/NetZone.hpp
src/kernel/routing/NetZoneImpl.cpp
src/s4u/s4u_Netzone.cpp
src/surf/sg_platf.cpp

index c1bf111..d2eab40 100644 (file)
@@ -77,6 +77,7 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
   std::shared_ptr<simgrid::surf::HostModel> host_model_;
   /** @brief Perform sealing procedure for derived classes, if necessary */
   virtual void do_seal(){};
+  void add_child(NetZoneImpl* new_zone);
 
 protected:
   explicit NetZoneImpl(const std::string& name);
@@ -128,7 +129,6 @@ public:
   /** @brief Returns the list of direct children (no grand-children). This returns the internal data, no copy.
    * Don't mess with it.*/
   std::vector<NetZoneImpl*>* get_children() { return &children_; }
-  void add_child(NetZoneImpl* new_zone);
 
   /** @brief Retrieves the name of that netzone as a C++ string */
   const std::string& get_name() const { return name_; }
index 6ff7496..dd4db0d 100644 (file)
@@ -56,7 +56,8 @@ public:
   void set_property(const std::string& key, const std::string& value);
 
   std::vector<NetZone*> get_children() const;
-  NetZone* add_child(const NetZone* new_zone);
+  XBT_ATTRIB_DEPRECATED_v332("Please use set_parent() to manage NetZone's relationship") NetZone* add_child(
+      NetZone* new_zone);
 
   void extract_xbt_graph(const s_xbt_graph_t* graph, std::map<std::string, xbt_node_t, std::less<>>* nodes,
                          std::map<std::string, xbt_edge_t, std::less<>>* edges);
index 9ce2ab4..775009a 100644 (file)
@@ -487,8 +487,10 @@ void NetZoneImpl::set_parent(NetZoneImpl* parent)
   xbt_assert(not sealed_, "Impossible to set parent to an already sealed NetZone(%s)", this->get_cname());
   parent_ = parent;
   netpoint_->set_englobing_zone(parent_);
-  /* copying models from parent host, to be reviewed when we allow multi-models */
   if (parent) {
+    /* adding this class as child */
+    parent->add_child(this);
+    /* copying models from parent host, to be reviewed when we allow multi-models */
     set_network_model(parent->get_network_model());
     set_cpu_pm_model(parent->get_cpu_pm_model());
     set_cpu_vm_model(parent->get_cpu_vm_model());
index 7645d5d..dc6f3d4 100644 (file)
@@ -47,9 +47,9 @@ std::vector<NetZone*> NetZone::get_children() const
   return res;
 }
 
-NetZone* NetZone::add_child(const NetZone* new_zone)
+NetZone* NetZone::add_child(NetZone* new_zone)
 {
-  pimpl_->add_child(new_zone->get_impl());
+  new_zone->set_parent(this);
   return this;
 }
 
index 12cc56a..e256c36 100644 (file)
@@ -477,8 +477,6 @@ sg_platf_create_zone(const simgrid::kernel::routing::ZoneCreationArgs* zone)
     /* set the father behavior */
     if (current_routing->hierarchy_ == simgrid::kernel::routing::NetZoneImpl::RoutingMode::unset)
       current_routing->hierarchy_ = simgrid::kernel::routing::NetZoneImpl::RoutingMode::recursive;
-    /* add to the sons dictionary */
-    current_routing->add_child(new_zone);
   }
   return new_zone;
 }