Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
NetZoneImpl: rework seal
authorBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 25 Feb 2021 17:33:36 +0000 (18:33 +0100)
committerBruno Donassolo <bruno.donassolo@inria.fr>
Thu, 11 Mar 2021 17:27:15 +0000 (18:27 +0100)
Create a do_seal that can be rewritten by derived classes

Assure that flag sealed_ is sealed properly when derived classes
override the seal() method.

14 files changed:
include/simgrid/kernel/routing/DijkstraZone.hpp
include/simgrid/kernel/routing/DragonflyZone.hpp
include/simgrid/kernel/routing/FatTreeZone.hpp
include/simgrid/kernel/routing/FloydZone.hpp
include/simgrid/kernel/routing/FullZone.hpp
include/simgrid/kernel/routing/NetZoneImpl.hpp
include/simgrid/kernel/routing/WifiZone.hpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/DragonflyZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/FloydZone.cpp
src/kernel/routing/FullZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/WifiZone.cpp

index 0154499..8e64fe0 100644 (file)
@@ -35,6 +35,7 @@ private:
   xbt_node_t route_graph_new_node(int id);
   xbt_node_t node_map_search(int id);
   void new_edge(int src_id, int dst_id, RouteCreationArgs* e_route);
+  void do_seal() override;
 
 public:
   DijkstraZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel, bool cached);
@@ -50,7 +51,6 @@ public:
    * After this function returns, any node in the graph
    * will have a loopback attached to it.
    */
-  void seal() override;
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
index dc15b66..ddb62f1 100644 (file)
@@ -70,13 +70,13 @@ public:
   explicit DragonflyZone(NetZoneImpl* father, const std::string& name, resource::NetworkModel* netmodel);
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
   void parse_specific_arguments(ClusterCreationArgs* cluster) override;
-  void seal() override;
 
   Coords rankId_to_coords(int rank_id) const;
   XBT_ATTRIB_DEPRECATED_v330("Please use rankId_to_coords(int)") void rankId_to_coords(int rank_id,
                                                                                        unsigned int coords[4]) const;
 
 private:
+  void do_seal() override;
   void generate_routers();
   void generate_links();
   void generate_link(const std::string& id, int numlinks, resource::LinkImpl** linkup,
index 484de14..f580267 100644 (file)
@@ -104,13 +104,6 @@ public:
   ~FatTreeZone() override;
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
 
-  /** @brief Generate the fat tree
-   *
-   * Once all processing nodes have been added, this will make sure the fat
-   * tree is generated by calling generateLabels(), generateSwitches() and
-   * then connection all nodes between them, using their label.
-   */
-  void seal() override;
   /** @brief Read the parameters in topo_parameters field.
    *
    * It will also store the cluster for future use.
@@ -120,6 +113,13 @@ public:
   void generate_dot_file(const std::string& filename = "fat_tree.dot") const;
 
 private:
+  /** @brief Generate the fat tree
+   *
+   * Once all processing nodes have been added, this will make sure the fat
+   * tree is generated by calling generateLabels(), generateSwitches() and
+   * then connection all nodes between them, using their label.
+   */
+  void do_seal() override;
   // description of a PGFT (TODO : better doc)
   unsigned long levels_ = 0;
   std::vector<unsigned int> num_children_per_node_; // number of children by node
index 9a5b924..4fc1cea 100644 (file)
@@ -31,7 +31,6 @@ public:
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
-  void seal() override;
 
 private:
   /* vars to compute the Floyd algorithm. */
@@ -40,6 +39,7 @@ private:
   std::vector<RouteCreationArgs*> link_table_;
 
   void init_tables(unsigned int table_size);
+  void do_seal() override;
 };
 } // namespace routing
 } // namespace kernel
index 3eed494..dd37e64 100644 (file)
@@ -25,13 +25,13 @@ public:
   FullZone& operator=(const FullZone) = delete;
   ~FullZone() override;
 
-  void seal() override;
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
   void add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoint* gw_dst,
                  std::vector<resource::LinkImpl*>& link_list, bool symmetrical) override;
 
 private:
   std::vector<RouteCreationArgs*> routing_table_;
+  void do_seal() override;
 };
 } // namespace routing
 } // namespace kernel
index b550fc4..b641b4b 100644 (file)
@@ -75,6 +75,8 @@ class XBT_PUBLIC NetZoneImpl : public xbt::PropertyHolder {
   resource::CpuModel* cpu_model_pm_;
   resource::DiskModel* disk_model_;
   simgrid::surf::HostModel* host_model_;
+  /** @brief Perform sealing procedure for derived classes, if necessary */
+  virtual void do_seal(){};
 
 protected:
   explicit NetZoneImpl(NetZoneImpl* father, const std::string& name, resource::NetworkModel* network_model);
@@ -145,7 +147,7 @@ public:
                                 std::vector<resource::LinkImpl*>& link_list, bool symmetrical);
 
   /** @brief Seal your netzone once you're done adding content, and before routing stuff through it */
-  virtual void seal() { sealed_ = true; };
+  void seal();
   virtual int add_component(kernel::routing::NetPoint* elm); /* A host, a router or a netzone, whatever */
   virtual void add_route(kernel::routing::NetPoint* src, kernel::routing::NetPoint* dst,
                          kernel::routing::NetPoint* gw_src, kernel::routing::NetPoint* gw_dst,
index 15cc9b0..a56d3fb 100644 (file)
@@ -24,13 +24,13 @@ public:
   WifiZone(const WifiZone&) = delete;
   WifiZone& operator=(const WifiZone) = delete;
 
-  void seal() override;
   void get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* into, double* latency) override;
   s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
                          s4u::Link::SharingPolicy policy) override;
   NetPoint* get_access_point() {return access_point_;}
 
 private:
+  void do_seal() override;
   resource::LinkImpl* wifi_link_ = nullptr; // Representing the air media (there is no such thing in NS-3)
   NetPoint* access_point_        = nullptr; // Zone's gateway to the external world
 };
index 7855c4f..e6408a7 100644 (file)
@@ -38,7 +38,7 @@ void DijkstraZone::route_graph_delete(xbt_graph_t g)
                        [](void* e) { delete static_cast<simgrid::kernel::routing::RouteCreationArgs*>(e); }, nullptr);
 }
 
-void DijkstraZone::seal()
+void DijkstraZone::do_seal()
 {
   unsigned int cursor;
   xbt_node_t node = nullptr;
index a2fde68..e42b30a 100644 (file)
@@ -124,7 +124,7 @@ void DragonflyZone::parse_specific_arguments(ClusterCreationArgs* cluster)
 }
 
 /* Generate the cluster once every node is created */
-void DragonflyZone::seal()
+void DragonflyZone::do_seal()
 {
   if (this->num_nodes_per_blade_ == 0) {
     return;
index 228527a..140d453 100644 (file)
@@ -130,7 +130,7 @@ void FatTreeZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArg
 /* This function makes the assumption that parse_specific_arguments() and
  * addNodes() have already been called
  */
-void FatTreeZone::seal()
+void FatTreeZone::do_seal()
 {
   if (this->levels_ == 0) {
     return;
index e374648..bb7d86b 100644 (file)
@@ -139,7 +139,7 @@ void FloydZone::add_route(NetPoint* src, NetPoint* dst, NetPoint* gw_src, NetPoi
   }
 }
 
-void FloydZone::seal()
+void FloydZone::do_seal()
 {
   /* set the size of table routing */
   unsigned int table_size = get_table_size();
index b7c0f33..41d52c1 100644 (file)
@@ -21,7 +21,7 @@ FullZone::FullZone(NetZoneImpl* father, const std::string& name, resource::Netwo
 {
 }
 
-void FullZone::seal()
+void FullZone::do_seal()
 {
   unsigned int table_size = get_table_size();
 
index 6ae49f1..ed41a9f 100644 (file)
@@ -401,6 +401,13 @@ void NetZoneImpl::get_global_route(NetPoint* src, NetPoint* dst,
   if (route.gw_dst != dst)
     get_global_route(route.gw_dst, dst, links, latency);
 }
+
+void NetZoneImpl::seal()
+{
+  do_seal(); // derived class' specific sealing procedure
+  sealed_ = true;
+}
+
 } // namespace routing
 } // namespace kernel
 } // namespace simgrid
index 1985a95..a063fea 100644 (file)
@@ -21,7 +21,7 @@ WifiZone::WifiZone(NetZoneImpl* father, const std::string& name, resource::Netwo
 {
 }
 
-void WifiZone::seal()
+void WifiZone::do_seal()
 {
   const char* AP_name = get_property("access_point");
   if (AP_name != nullptr) {