* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/kernel/routing/AsClusterTorus.hpp"
+#include "src/kernel/routing/NetCard.hpp"
+
#include "src/surf/network_interface.hpp"
#include "src/surf/xml/platf.hpp" // FIXME: move that back to the parsing area
namespace simgrid {
namespace kernel {
namespace routing {
- AsClusterTorus::AsClusterTorus(const char*name)
- : AsCluster(name) {
+ AsClusterTorus::AsClusterTorus(As* father, const char* name) : AsCluster(father, name)
+ {
}
AsClusterTorus::~AsClusterTorus() {
xbt_dynar_free(&dimensions_);
* Create all links that exist in the torus.
* Each rank creates @a dimensions-1 links
*/
- int neighbour_rank_id = 0; // The other node the link connects
- int current_dimension = 0, // which dimension are we currently in?
+ int neighbor_rank_id = 0; // The other node the link connects
+ int current_dimension = 0, // which dimension are we currently in?
// we need to iterate over all dimensions
// and create all links there
- dim_product = 1; // Needed to calculate the next neighbour_id
+ dim_product = 1; // Needed to calculate the next neighbor_id
for (j = 0; j < xbt_dynar_length(dimensions_); j++) {
s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
current_dimension = xbt_dynar_get_as(dimensions_, j, int);
- neighbour_rank_id =
- (((int) rank / dim_product) % current_dimension ==
- current_dimension - 1) ? rank - (current_dimension - 1) * dim_product : rank + dim_product;
+ neighbor_rank_id = (((int)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)
- link_id = bprintf("%s_link_from_%i_to_%i", cluster->id, id, neighbour_rank_id);
+ link_id = bprintf("%s_link_from_%i_to_%i", cluster->id, id, neighbor_rank_id);
link.id = link_id;
link.bandwidth = cluster->bw;
link.latency = cluster->lat;
}
/*
* Add the link to its appropriate position;
- * note that position rankId*(xbt_dynar_length(dimensions)+has_loopack?+has_limiter?)
+ * note that position rankId*(xbt_dynar_length(dimensions)+has_loopback?+has_limiter?)
* holds the link "rankId->rankId"
*/
- privateLinks_.insert(privateLinks_.begin() + position + j, info);
+ privateLinks_.insert({position + j, info});
dim_product *= current_dimension;
xbt_free(link_id);
}
xbt_dynar_free(&dimensions);
}
- void AsClusterTorus::getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t route, double *lat) {
+ void AsClusterTorus::getLocalRoute(NetCard* src, NetCard* dst, sg_platf_route_cbarg_t route, double* lat)
+ {
- XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]",
- src->name(), src->id(), dst->name(), dst->id());
+ XBT_VERB("torus getLocalRoute from '%s'[%d] to '%s'[%d]", src->name().c_str(), src->id(), dst->name().c_str(),
+ dst->id());
if (dst->isRouter() || src->isRouter())
return;
- if ((src->id() == dst->id()) && hasLoopback_) {
+ 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);
if (lat)
- *lat += info.linkUp->getLatency();
+ *lat += info.linkUp->latency();
return;
}
* TODO Change to dynamic assignment
*/
unsigned int j, cur_dim, dim_product = 1;
- int current_node = src->id();
- int unsigned next_node = 0;
+ unsigned int current_node = src->id();
+ unsigned int next_node = 0;
/*
* 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.
*/
- unsigned int *myCoords, *targetCoords;
- myCoords = rankId_to_coords(src->id(), dimensions_);
- targetCoords = rankId_to_coords(dst->id(), dimensions_);
+ unsigned int* myCoords = rankId_to_coords(src->id(), dimensions_);
+ unsigned int* targetCoords = rankId_to_coords(dst->id(), dimensions_);
/*
* linkOffset describes the offset where the link
* we want to use is stored
if (use_lnk_up == false) {
route->link_list->push_back(info.linkDown);
if (lat)
- *lat += info.linkDown->getLatency();
+ *lat += info.linkDown->latency();
} else {
route->link_list->push_back(info.linkUp);
if (lat)
- *lat += info.linkUp->getLatency();
+ *lat += info.linkUp->latency();
}
current_node = next_node;
next_node = 0;