+/* Copyright (c) 2014. 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. */
+
#include "surf_routing_cluster_torus.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster_torus, surf_route_cluster, "Torus Routing part of surf");
#include "surf_routing_cluster_torus.hpp"
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster_torus, surf_route_cluster, "Torus Routing part of surf");
void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position){
void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position){
/**
* We are in a torus cluster
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN"
* and safe it in a dynarray.
* Additionally, we need to know how many ranks we have in total
*/
/**
* We are in a torus cluster
* Parse attribute dimensions="dim1,dim2,dim3,...,dimN"
* and safe it in a dynarray.
* Additionally, we need to know how many ranks we have in total
*/
- xbt_dynar_foreach(p_dimensions, iter, groups) {
- int tmp = surf_parse_get_int(xbt_dynar_get_as(p_dimensions, iter, char *));
+ xbt_dynar_foreach(dimensions, iter, groups) {
+ int tmp = surf_parse_get_int(xbt_dynar_get_as(dimensions, iter, char *));
xbt_dynar_set_as(p_dimensions, iter, int, tmp);
}
p_nb_links_per_node = xbt_dynar_length(p_dimensions);
}
xbt_dynar_set_as(p_dimensions, iter, int, tmp);
}
p_nb_links_per_node = xbt_dynar_length(p_dimensions);
}
}
void AsClusterTorus::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat){
}
void AsClusterTorus::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t route, double *lat){
- XBT_INFO("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]",
- src->p_name,src->m_id,
- dst->p_name,dst->m_id);
+ XBT_VERB("torus_get_route_and_latency from '%s'[%d] to '%s'[%d]",
+ src->getName(), src->getId(),
+ dst->getName(), dst->getId());
- if((src->m_id == dst->m_id) && p_has_loopback ){
- s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(p_linkUpDownList, src->m_id * p_nb_links_per_node, s_surf_parsing_link_up_down_t);
+ if((src->getId() == dst->getId()) && p_has_loopback ){
+ s_surf_parsing_link_up_down_t info = xbt_dynar_get_as(p_linkUpDownList, src->getId() * p_nb_links_per_node, s_surf_parsing_link_up_down_t);
* TODO Change to dynamic assignment
*/
unsigned int j, cur_dim, dim_product = 1;
* TODO Change to dynamic assignment
*/
unsigned int j, cur_dim, dim_product = 1;
/**
* Arrays that hold the coordinates of the current node and
* the 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
* into this dimension or not.
*/
unsigned int* myCoords, *targetCoords;
* into this dimension or not.
*/
unsigned int* myCoords, *targetCoords;
- myCoords = rankId_to_coords(src->m_id, p_dimensions);
- targetCoords = rankId_to_coords(dst->m_id, p_dimensions);
+ myCoords = rankId_to_coords(src->getId(), p_dimensions);
+ targetCoords = rankId_to_coords(dst->getId(), p_dimensions);
bool use_lnk_up = false; // Is this link of the form "cur -> next" or "next -> cur"?
// false means: next -> cur
bool use_lnk_up = false; // Is this link of the form "cur -> next" or "next -> cur"?
// false means: next -> cur
dim_product = 1; // First, we will route in x-dimension
for (j = 0; j < xbt_dynar_length(p_dimensions); j++) {
cur_dim = xbt_dynar_get_as(p_dimensions, j, int);
// current_node/dim_product = position in current dimension
dim_product = 1; // First, we will route in x-dimension
for (j = 0; j < xbt_dynar_length(p_dimensions); j++) {
cur_dim = xbt_dynar_get_as(p_dimensions, j, int);
// current_node/dim_product = position in current dimension
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 && (myCoords[j]+cur_dim/2)%cur_dim >= targetCoords[j] )) { // Or do we need to use the wrap around to reach it?
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 && (myCoords[j]+cur_dim/2)%cur_dim >= targetCoords[j] )) { // Or do we need to use the wrap around to reach it?
- XBT_DEBUG("torus_get_route_and_latency - current_node: %lu, next_node: %lu, linkOffset is %lu",
+ XBT_DEBUG("torus_get_route_and_latency - current_node: %i, next_node: %u, linkOffset is %i",