Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update copyright lines.
[simgrid.git] / src / kernel / routing / TorusZone.cpp
index a1001e6..248c5ad 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2014-2019. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2014-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -33,7 +33,7 @@ void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int
     int current_dimension = dimensions_[j]; // which dimension are we currently in?
                                             // we need to iterate over all dimensions and create all links there
     // The other node the link connects
-    int neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
+    int neighbor_rank_id = ((rank / dim_product) % current_dimension == current_dimension - 1)
                                ? rank - (current_dimension - 1) * dim_product
                                : rank + dim_product;
     // name of neighbor is not right for non contiguous cluster radicals (as id != rank in this case)
@@ -83,7 +83,6 @@ void TorusZone::parse_specific_arguments(ClusterCreationArgs* cluster)
 
 void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* route, double* lat)
 {
-
   XBT_VERB("torus getLocalRoute from '%s'[%u] to '%s'[%u]", src->get_cname(), src->id(), dst->get_cname(), dst->id());
 
   if (dst->is_router() || src->is_router())
@@ -104,12 +103,12 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
    */
 
   /*
-   * Arrays that hold the coordinates of the current node andthe target; comparing the values at the i-th position of
+   * Arrays that hold the coordinates of the current node and the target; comparing the values at the i-th position of
    * both arrays, we can easily assess whether we need to route into this dimension or not.
    */
   const unsigned int dsize = dimensions_.size();
-  unsigned int myCoords[dsize];
-  unsigned int targetCoords[dsize];
+  std::vector<unsigned int> myCoords(dsize);
+  std::vector<unsigned int> targetCoords(dsize);
   unsigned int dim_size_product = 1;
   for (unsigned i = 0; i < dsize; i++) {
     unsigned cur_dim_size = dimensions_[i];
@@ -134,7 +133,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
       const unsigned cur_dim = dimensions_[j];
       // current_node/dim_product = position in current dimension
       if ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) {
-
         if ((targetCoords[j] > myCoords[j] &&
              targetCoords[j] <= myCoords[j] + cur_dim / 2) // Is the target node on the right, without the wrap-around?
             || (myCoords[j] > cur_dim / 2 &&
@@ -188,6 +186,6 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs*
     current_node = next_node;
   }
 }
-}
-}
-} // namespace
+} // namespace routing
+} // namespace kernel
+} // namespace simgrid