Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use std::pair instead of s_surf_parsing_link_up_down_t for Cluster private links
authorMartin Quinson <martin.quinson@loria.fr>
Sun, 11 Dec 2016 19:56:41 +0000 (20:56 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Sun, 11 Dec 2016 19:56:41 +0000 (20:56 +0100)
src/kernel/routing/AsCluster.cpp
src/kernel/routing/AsCluster.hpp
src/kernel/routing/AsClusterDragonfly.cpp
src/kernel/routing/AsClusterTorus.cpp
src/kernel/routing/AsVivaldi.cpp
src/surf/sg_platf.cpp

index 095b80c..95805fc 100644 (file)
@@ -28,24 +28,24 @@ void AsCluster::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t
   if (! src->isRouter()) {    // No specific link for router
 
     if((src->id() == dst->id()) && hasLoopback_ ){
   if (! src->isRouter()) {    // No specific link for router
 
     if((src->id() == dst->id()) && hasLoopback_ ){
-      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
-      route->link_list->push_back(info.linkUp);
+      std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_);
+      route->link_list->push_back(info.first);
       if (lat)
       if (lat)
-        *lat += info.linkUp->latency();
+        *lat += info.first->latency();
       return;
     }
 
     if (hasLimiter_){          // limiter for sender
       return;
     }
 
     if (hasLimiter_){          // limiter for sender
-      s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
-      route->link_list->push_back(info.linkUp);
+      std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0));
+      route->link_list->push_back(info.first);
     }
 
     }
 
-    s_surf_parsing_link_up_down_t info =
+    std::pair<Link*, Link*> info =
         privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0));
         privateLinks_.at(src->id() * linkCountPerNode_ + (hasLoopback_ ? 1 : 0) + (hasLimiter_ ? 1 : 0));
-    if (info.linkUp) {         // link up
-      route->link_list->push_back(info.linkUp);
+    if (info.first) { // link up
+      route->link_list->push_back(info.first);
       if (lat)
       if (lat)
-        *lat += info.linkUp->latency();
+        *lat += info.first->latency();
     }
 
   }
     }
 
   }
@@ -57,16 +57,16 @@ void AsCluster::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t
   }
 
   if (! dst->isRouter()) {    // No specific link for router
   }
 
   if (! dst->isRouter()) {    // No specific link for router
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_ + hasLimiter_);
+    std::pair<Link*, Link*> info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_ + hasLimiter_);
 
 
-    if (info.linkDown) {       // link down
-      route->link_list->push_back(info.linkDown);
+    if (info.second) { // link down
+      route->link_list->push_back(info.second);
       if (lat)
       if (lat)
-        *lat += info.linkDown->latency();
+        *lat += info.second->latency();
     }
     if (hasLimiter_){          // limiter for receiver
         info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_);
     }
     if (hasLimiter_){          // limiter for receiver
         info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_);
-        route->link_list->push_back(info.linkUp);
+        route->link_list->push_back(info.first);
     }
   }
 }
     }
   }
 }
@@ -74,7 +74,7 @@ void AsCluster::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t
 void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   xbt_node_t current, previous, backboneNode = nullptr;
 void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 {
   xbt_node_t current, previous, backboneNode = nullptr;
-  s_surf_parsing_link_up_down_t info;
+  std::pair<Link*, Link*> info;
 
   xbt_assert(router_,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph.");
 
 
   xbt_assert(router_,"Malformed cluster. This may be because your platform file is a hypergraph while it must be a graph.");
 
@@ -94,8 +94,8 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
 
       info = privateLinks_.at(src->id());
 
 
       info = privateLinks_.at(src->id());
 
-      if (info.linkUp) {     // link up
-        const char *link_name = static_cast<simgrid::surf::Resource*>(info.linkUp)->getName();
+      if (info.first) { // link up
+        const char* link_name = static_cast<simgrid::surf::Resource*>(info.first)->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
@@ -106,9 +106,8 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)
         }
       }
 
         }
       }
 
-      if (info.linkDown) {    // link down
-        const char *link_name = static_cast<simgrid::surf::Resource*>(
-          info.linkDown)->getName();
+      if (info.second) { // link down
+        const char* link_name = static_cast<simgrid::surf::Resource*>(info.second)->getName();
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
         current = new_xbt_graph_node(graph, link_name, nodes);
         new_xbt_graph_edge(graph, previous, current, edges);
 
@@ -145,7 +144,7 @@ void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id,
     info.linkUp = Link::byName(link_id);
     info.linkDown = info.linkUp;
   }
     info.linkUp = Link::byName(link_id);
     info.linkDown = info.linkUp;
   }
-  privateLinks_.insert({position, info});
+  privateLinks_.insert({position, {info.linkUp, info.linkDown}});
   xbt_free(link_id);
 }
 
   xbt_free(link_id);
 }
 
index 9dd3d09..14d07c8 100644 (file)
@@ -25,7 +25,8 @@ public:
   virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
 
   /* We use a map instead of a std::vector here because that's a sparse vector. Some values may not exist */
   virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {}
 
   /* We use a map instead of a std::vector here because that's a sparse vector. Some values may not exist */
-  std::unordered_map<unsigned int, s_surf_parsing_link_up_down_t> privateLinks_;
+  /* The pair is {linkUp, linkDown} */
+  std::unordered_map<unsigned int, std::pair<Link*, Link*>> privateLinks_;
 
   Link* backbone_ = nullptr;
   void *loopback_ = nullptr;
 
   Link* backbone_ = nullptr;
   void *loopback_ = nullptr;
index abe03ac..355c17d 100644 (file)
@@ -249,12 +249,12 @@ void AsClusterDragonfly::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_rout
            dst->id());
 
   if ((src->id() == dst->id()) && hasLoopback_) {
            dst->id());
 
   if ((src->id() == dst->id()) && hasLoopback_) {
-     s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
+    std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_);
 
 
-     route->link_list->push_back(info.linkUp);
-     if (latency)
-       *latency += info.linkUp->latency();
-     return;
+    route->link_list->push_back(info.first);
+    if (latency)
+      *latency += info.first->latency();
+    return;
   }
 
   unsigned int *myCoords = rankId_to_coords(src->id());
   }
 
   unsigned int *myCoords = rankId_to_coords(src->id());
@@ -272,8 +272,8 @@ void AsClusterDragonfly::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_rout
     *latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
 
   if (hasLimiter_) {    // limiter for sender
     *latency += myRouter->myNodes_[myCoords[3] * numLinksperLink_]->latency();
 
   if (hasLimiter_) {    // limiter for sender
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_ + hasLoopback_);
-    route->link_list->push_back(info.linkUp);
+    std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_ + hasLoopback_);
+    route->link_list->push_back(info.first);
   }
 
   if(targetRouter!=myRouter){
   }
 
   if(targetRouter!=myRouter){
@@ -323,8 +323,8 @@ void AsClusterDragonfly::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_rout
   }
 
   if (hasLimiter_) {    // limiter for receiver
   }
 
   if (hasLimiter_) {    // limiter for receiver
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_);
-    route->link_list->push_back(info.linkUp);
+    std::pair<Link*, Link*> info = privateLinks_.at(dst->id() * linkCountPerNode_ + hasLoopback_);
+    route->link_list->push_back(info.first);
   }
 
   //router->node local link
   }
 
   //router->node local link
index 8690cdc..d3477eb 100644 (file)
@@ -80,7 +80,7 @@ namespace simgrid {
          * note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
          * holds the link "rankId->rankId"
          */
          * note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
          * holds the link "rankId->rankId"
          */
-        privateLinks_.insert({position + j, info});
+        privateLinks_.insert({position + j, {info.linkUp, info.linkDown}});
         dim_product *= current_dimension;
         xbt_free(link_id);
       }
         dim_product *= current_dimension;
         xbt_free(link_id);
       }
@@ -121,11 +121,11 @@ namespace simgrid {
         return;
 
       if (src->id() == dst->id() && hasLoopback_) {
         return;
 
       if (src->id() == dst->id() && hasLoopback_) {
-        s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id() * linkCountPerNode_);
+        std::pair<Link*, Link*> info = privateLinks_.at(src->id() * linkCountPerNode_);
 
 
-        route->link_list->push_back(info.linkUp);
+        route->link_list->push_back(info.first);
         if (lat)
         if (lat)
-          *lat += info.linkUp->latency();
+          *lat += info.first->latency();
         return;
       }
 
         return;
       }
 
@@ -199,23 +199,23 @@ namespace simgrid {
           dim_product *= cur_dim;
         }
 
           dim_product *= cur_dim;
         }
 
-        s_surf_parsing_link_up_down_t info;
+        std::pair<Link*, Link*> info;
 
         if (hasLimiter_) {    // limiter for sender
           info = privateLinks_.at(nodeOffset + hasLoopback_);
 
         if (hasLimiter_) {    // limiter for sender
           info = privateLinks_.at(nodeOffset + hasLoopback_);
-          route->link_list->push_back(info.linkUp);
+          route->link_list->push_back(info.first);
         }
 
         info = privateLinks_.at(linkOffset);
 
         if (use_lnk_up == false) {
         }
 
         info = privateLinks_.at(linkOffset);
 
         if (use_lnk_up == false) {
-          route->link_list->push_back(info.linkDown);
+          route->link_list->push_back(info.second);
           if (lat)
           if (lat)
-            *lat += info.linkDown->latency();
+            *lat += info.second->latency();
         } else {
         } else {
-          route->link_list->push_back(info.linkUp);
+          route->link_list->push_back(info.first);
           if (lat)
           if (lat)
-            *lat += info.linkUp->latency();
+            *lat += info.first->latency();
         }
         current_node = next_node;
         next_node = 0;
         }
         current_node = next_node;
         next_node = 0;
index a7ff1f6..8988735 100644 (file)
@@ -68,7 +68,7 @@ void AsVivaldi::setPeerLink(NetCard* netcard, double bw_in, double bw_out, doubl
   char* link_down = bprintf("link_%s_DOWN", netcard->cname());
   info.linkUp     = surf_network_model->createLink(link_up, bw_out, latency, SURF_LINK_SHARED);
   info.linkDown   = surf_network_model->createLink(link_down, bw_in, latency, SURF_LINK_SHARED);
   char* link_down = bprintf("link_%s_DOWN", netcard->cname());
   info.linkUp     = surf_network_model->createLink(link_up, bw_out, latency, SURF_LINK_SHARED);
   info.linkDown   = surf_network_model->createLink(link_down, bw_in, latency, SURF_LINK_SHARED);
-  privateLinks_.insert({netcard->id(), info});
+  privateLinks_.insert({netcard->id(), {info.linkUp, info.linkDown}});
 
   free(link_up);
   free(link_down);
 
   free(link_up);
   free(link_down);
@@ -89,19 +89,19 @@ void AsVivaldi::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t
 
   /* Retrieve the private links */
   if (privateLinks_.find(src->id()) != privateLinks_.end()) {
 
   /* Retrieve the private links */
   if (privateLinks_.find(src->id()) != privateLinks_.end()) {
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(src->id());
-    if (info.linkUp) {
-      route->link_list->push_back(info.linkUp);
+    std::pair<Link*, Link*> info = privateLinks_.at(src->id());
+    if (info.first) {
+      route->link_list->push_back(info.first);
       if (lat)
       if (lat)
-        *lat += info.linkUp->latency();
+        *lat += info.first->latency();
     }
   }
   if (privateLinks_.find(dst->id()) != privateLinks_.end()) {
     }
   }
   if (privateLinks_.find(dst->id()) != privateLinks_.end()) {
-    s_surf_parsing_link_up_down_t info = privateLinks_.at(dst->id());
-    if (info.linkDown) {
-      route->link_list->push_back(info.linkDown);
+    std::pair<Link*, Link*> info = privateLinks_.at(dst->id());
+    if (info.second) {
+      route->link_list->push_back(info.second);
       if (lat)
       if (lat)
-        *lat += info.linkDown->latency();
+        *lat += info.second->latency();
     }
   }
 
     }
   }
 
index a6627a2..35b2deb 100644 (file)
@@ -261,7 +261,8 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
       free(tmp_link);
 
       auto as_cluster = static_cast<AsCluster*>(current_as);
       free(tmp_link);
 
       auto as_cluster = static_cast<AsCluster*>(current_as);
-      as_cluster->privateLinks_.insert({rankId*as_cluster->linkCountPerNode_, info_loop});
+      as_cluster->privateLinks_.insert(
+          {rankId * as_cluster->linkCountPerNode_, {info_loop.linkUp, info_loop.linkDown}});
     }
 
     //add a limiter link (shared link to account for maximal bandwidth of the node)
     }
 
     //add a limiter link (shared link to account for maximal bandwidth of the node)
@@ -278,7 +279,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster)
       info_lim.linkUp = info_lim.linkDown = Link::byName(tmp_link);
       free(tmp_link);
       current_as->privateLinks_.insert(
       info_lim.linkUp = info_lim.linkDown = Link::byName(tmp_link);
       free(tmp_link);
       current_as->privateLinks_.insert(
-          {rankId * current_as->linkCountPerNode_ + current_as->hasLoopback_ , info_lim});
+          {rankId * current_as->linkCountPerNode_ + current_as->hasLoopback_, {info_lim.linkUp, info_lim.linkDown}});
     }
 
     //call the cluster function that adds the others links
     }
 
     //call the cluster function that adds the others links
@@ -570,14 +571,13 @@ void sg_platf_new_process(sg_platf_process_cbarg_t process)
 
 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
 {
 
 void sg_platf_new_peer(sg_platf_peer_cbarg_t peer)
 {
-  using simgrid::kernel::routing::AsVivaldi;
-
-  AsVivaldi* as = dynamic_cast<simgrid::kernel::routing::AsVivaldi*>(current_routing);
+  simgrid::kernel::routing::AsVivaldi* as = dynamic_cast<simgrid::kernel::routing::AsVivaldi*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi ASes");
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
   simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi ASes");
 
   std::vector<double> speedPerPstate;
   speedPerPstate.push_back(peer->speed);
   simgrid::s4u::Host* host = as->createHost(peer->id, &speedPerPstate, 1);
+
   as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->lat, peer->coord);
   simgrid::s4u::Host::onCreation(*host);
 
   as->setPeerLink(host->pimpl_netcard, peer->bw_in, peer->bw_out, peer->lat, peer->coord);
   simgrid::s4u::Host::onCreation(*host);
 
@@ -760,5 +760,5 @@ void sg_platf_new_hostlink(sg_platf_host_link_cbarg_t hostlink)
     surf_parse_error("Host_link for '%s' is already defined!",hostlink->id);
 
   XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name().c_str(), netcard->id());
     surf_parse_error("Host_link for '%s' is already defined!",hostlink->id);
 
   XBT_DEBUG("Push Host_link for host '%s' to position %d", netcard->name().c_str(), netcard->id());
-  as_cluster->privateLinks_.insert({netcard->id(), link_up_down});
+  as_cluster->privateLinks_.insert({netcard->id(), {link_up_down.linkUp, link_up_down.linkDown}});
 }
 }