Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
unXBTize a bit
authorMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 00:19:55 +0000 (01:19 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Wed, 16 Nov 2016 00:19:55 +0000 (01:19 +0100)
src/kernel/routing/AsImpl.cpp
src/kernel/routing/AsImpl.hpp
src/kernel/routing/AsRoutedGraph.cpp
src/kernel/routing/AsRoutedGraph.hpp
src/surf/network_ns3.cpp
src/surf/surf_routing.cpp
src/surf/surf_routing.hpp

index 33688ac..9fe0cef 100644 (file)
@@ -41,7 +41,7 @@ namespace simgrid {
     return res;
   }
 
-  void AsImpl::getOneLinkRoutes(xbt_dynar_t accumulator)
+  void AsImpl::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
   {
   }
 
index dd3b26d..4747852 100644 (file)
@@ -17,65 +17,69 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
   class RoutingPlatf; // FIXME: KILLME
+  class Onelink;
 
-/** @brief Autonomous Systems
- *
- * An AS is a network container, in charge of routing information between elements (hosts) and to the nearby ASes.
- * In SimGrid, there is a hierarchy of ASes, with a unique root AS (that you can retrieve from the s4u::Engine).
- */
-XBT_PUBLIC_CLASS AsImpl : public s4u::As {
-  friend simgrid::kernel::routing::RoutingPlatf;
-protected:
-  explicit AsImpl(As * father, const char* name);
-  ~AsImpl() override;
-  
-public:
-  /** @brief Make an host within that AS */
-  simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount);
-
-  /**
-   * @brief Probe the routing path between two points
-   *
-   * The networking model uses this function when creating a communication
-   * to retrieve both the list of links that the create communication will use,
-   * and the summed latency that these links represent.
-   *
-   * The network could recompute the latency by itself from the list, but it would
-   * require an additional link set traversal. This operation being on the critical
-   * path of SimGrid, the routing computes the latency in behalf of the network.
-   *
-   * Things are rather complex here because we have to find the path from ASes to ASes, and within each.
-   * In addition, the different ASes may use differing routing models.
-   * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top of that, and so on.
-   * Some ASes may even not have any predefined links and use only coordinate information to compute the latency.
+  /** @brief Autonomous Systems
    *
-   * So, the path is constructed recursively, with each traversed AS adding its information to the set.
-   * The algorithm for that is explained in http://hal.inria.fr/hal-00650233/
-   *
-   * @param src Initial point of the routing path
-   * @param dst Final point of the routing path
-   * @param into Container into which the traversed links should be pushed
-   * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
+   * An AS is a network container, in charge of routing information between elements (hosts) and to the nearby ASes.
+   * In SimGrid, there is a hierarchy of ASes, with a unique root AS (that you can retrieve from the s4u::Engine).
    */
-  virtual void getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbarg_t into, double *latency)=0;
-  /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
-  virtual void getOneLinkRoutes(xbt_dynar_t accumulator);
-  /* returns whether we found a bypass path */
-  bool getBypassRoute(routing::NetCard * src, routing::NetCard * dst,
-                      /* OUT */ std::vector<surf::Link*> * links, double* latency);
+  XBT_PUBLIC_CLASS AsImpl : public s4u::As
+  {
+    friend simgrid::kernel::routing::RoutingPlatf;
+
+  protected:
+    explicit AsImpl(As * father, const char* name);
+    ~AsImpl() override;
+
+  public:
+    /** @brief Make an host within that AS */
+    simgrid::s4u::Host* createHost(const char* name, std::vector<double>* speedPerPstate, int coreAmount);
+
+    /**
+     * @brief Probe the routing path between two points
+     *
+     * The networking model uses this function when creating a communication
+     * to retrieve both the list of links that the create communication will use,
+     * and the summed latency that these links represent.
+     *
+     * The network could recompute the latency by itself from the list, but it would
+     * require an additional link set traversal. This operation being on the critical
+     * path of SimGrid, the routing computes the latency in behalf of the network.
+     *
+     * Things are rather complex here because we have to find the path from ASes to ASes, and within each.
+     * In addition, the different ASes may use differing routing models.
+     * Some ASes may be routed in full, others may have only some connection information and use a shortest path on top
+     * of that, and so on.
+     * Some ASes may even not have any predefined links and use only coordinate information to compute the latency.
+     *
+     * So, the path is constructed recursively, with each traversed AS adding its information to the set.
+     * The algorithm for that is explained in http://hal.inria.fr/hal-00650233/
+     *
+     * @param src Initial point of the routing path
+     * @param dst Final point of the routing path
+     * @param into Container into which the traversed links should be pushed
+     * @param latency Accumulator in which the latencies should be added (caller must set it to 0)
+     */
+    virtual void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double* latency) = 0;
+    /** @brief retrieves the list of all routes of size 1 (of type src x dst x Link) */
+    virtual void getOneLinkRoutes(std::vector<Onelink*> * accumulator);
+    /* returns whether we found a bypass path */
+    bool getBypassRoute(routing::NetCard * src, routing::NetCard * dst,
+                        /* OUT */ std::vector<surf::Link*> * links, double* latency);
 
-  virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
-  static void getRouteRecursive(routing::NetCard * src, routing::NetCard * dst,
-                                /* OUT */ std::vector<surf::Link*> * links, double* latency);
+    virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) = 0;
+    static void getRouteRecursive(routing::NetCard * src, routing::NetCard * dst,
+                                  /* OUT */ std::vector<surf::Link*> * links, double* latency);
 
-  enum class RoutingMode {
-    unset = 0,  /**< Undefined type                                   */
-    base,       /**< Base case: use simple link lists for routing     */
-    recursive   /**< Recursive case: also return gateway information  */
-  };
-  /* FIXME: protect the following fields once the construction madness is sorted out */
-  RoutingMode hierarchy_ = RoutingMode::unset;
-  routing::NetCard *netcard_ = nullptr; // Our representative in the father AS
+    enum class RoutingMode {
+      unset = 0, /**< Undefined type                                   */
+      base,      /**< Base case: use simple link lists for routing     */
+      recursive  /**< Recursive case: also return gateway information  */
+    };
+    /* FIXME: protect the following fields once the construction madness is sorted out */
+    RoutingMode hierarchy_     = RoutingMode::unset;
+    routing::NetCard* netcard_ = nullptr; // Our representative in the father AS
 };
 
 }}}; // Namespace simgrid::kernel::routing
index b45087f..592ad3c 100644 (file)
@@ -81,7 +81,7 @@ namespace simgrid {
 namespace kernel {
 namespace routing {
 
-void AsRoutedGraph::getOneLinkRoutes(xbt_dynar_t accumulator)
+void AsRoutedGraph::getOneLinkRoutes(std::vector<Onelink*>* accumulator)
 {
   sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
   route->link_list             = new std::vector<Link*>();
@@ -103,7 +103,7 @@ void AsRoutedGraph::getOneLinkRoutes(xbt_dynar_t accumulator)
           onelink = new Onelink(link, route->gw_src, route->gw_dst);
         else
           onelink = new Onelink(link, nullptr, nullptr);
-        xbt_dynar_push(accumulator, &onelink);
+        accumulator->push_back(onelink);
       }
     }
   }
index 7dd239c..b4f5d1f 100644 (file)
@@ -17,7 +17,7 @@ public:
   explicit AsRoutedGraph(As* father, const char* name);
   ~AsRoutedGraph() override;
 
-  void getOneLinkRoutes(xbt_dynar_t accumulator) override;
+  void getOneLinkRoutes(std::vector<Onelink*>* accumulator) override;
 
   void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) override;
   virtual sg_platf_route_cbarg_t newExtendedRoute(RoutingMode hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
index 21325c2..1acad86 100644 (file)
@@ -107,14 +107,12 @@ static void create_ns3_topology(void)
   xbt_dynar_shrink(IPV4addr,0);
 
   //get the onelinks from the parsed platform
-  xbt_dynar_t onelink_routes = routing_platf->getOneLinkRoutes();
+  std::vector<simgrid::kernel::routing::Onelink*>* onelink_routes = routing_platf->getOneLinkRoutes();
 
   std::unordered_set<simgrid::surf::LinkNS3*> already_seen = std::unordered_set<simgrid::surf::LinkNS3*>();
 
-  XBT_DEBUG("There is %ld one-link routes",onelink_routes->used);
-  simgrid::kernel::routing::Onelink *onelink;
-  unsigned int iter;
-  xbt_dynar_foreach(onelink_routes, iter, onelink) {
+  XBT_DEBUG("There is %ld one-link routes", onelink_routes->size());
+  for (simgrid::kernel::routing::Onelink* onelink : *onelink_routes) {
     const char* src              = onelink->src_->name().c_str();
     const char* dst              = onelink->dst_->name().c_str();
     simgrid::surf::LinkNS3 *link = static_cast<simgrid::surf::LinkNS3 *>(onelink->link_);
index 596ccee..b1b6a12 100644 (file)
@@ -100,7 +100,7 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Li
   AsImpl::getRouteRecursive(src, dst, route, latency);
 }
 
-static void _recursiveGetOneLinkRoutes(AsImpl* as, xbt_dynar_t accumulator)
+static void _recursiveGetOneLinkRoutes(AsImpl* as, std::vector<Onelink*>* accumulator)
 {
   //adding my one link routes
   as->getOneLinkRoutes(accumulator);
@@ -114,8 +114,9 @@ static void _recursiveGetOneLinkRoutes(AsImpl* as, xbt_dynar_t accumulator)
   }
 }
 
-xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){
-  xbt_dynar_t res = xbt_dynar_new(sizeof(Onelink*), xbt_free_f);
+std::vector<Onelink*>* RoutingPlatf::getOneLinkRoutes()
+{
+  std::vector<Onelink*>* res = new std::vector<Onelink*>();
   _recursiveGetOneLinkRoutes(root_, res);
   return res;
 }
index 926f1a6..cd1db49 100644 (file)
@@ -108,7 +108,7 @@ public:
   explicit RoutingPlatf();
   ~RoutingPlatf();
   AsImpl *root_ = nullptr;
-  xbt_dynar_t getOneLinkRoutes();
+  std::vector<Onelink*>* getOneLinkRoutes();
   void getRouteAndLatency(NetCard *src, NetCard *dst, std::vector<Link*> * links, double *latency);
 };