From c7344f5c93d14d03114fe84a0213d7f3950c73a3 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 14 Feb 2016 15:05:01 +0100 Subject: [PATCH] routing: rename all fields, and less void* --- include/simgrid/forward.h | 2 - src/surf/network_ns3.cpp | 6 +- src/surf/sg_platf.cpp | 20 +-- src/surf/surf_routing.cpp | 32 ++-- src/surf/surf_routing.hpp | 14 +- src/surf/surf_routing_cluster.cpp | 34 ++-- src/surf/surf_routing_cluster.hpp | 12 +- src/surf/surf_routing_cluster_fat_tree.cpp | 186 ++++++++++----------- src/surf/surf_routing_cluster_fat_tree.hpp | 18 +- src/surf/surf_routing_cluster_torus.cpp | 38 ++--- src/surf/surf_routing_cluster_torus.hpp | 2 +- src/surf/surf_routing_dijkstra.cpp | 70 ++++---- src/surf/surf_routing_dijkstra.hpp | 6 +- src/surf/surf_routing_floyd.cpp | 50 +++--- src/surf/surf_routing_floyd.hpp | 6 +- src/surf/surf_routing_full.cpp | 24 +-- src/surf/surf_routing_full.hpp | 2 +- src/surf/surf_routing_generic.cpp | 6 +- 18 files changed, 263 insertions(+), 265 deletions(-) diff --git a/include/simgrid/forward.h b/include/simgrid/forward.h index 8fc490d98b..316a59a6c5 100644 --- a/include/simgrid/forward.h +++ b/include/simgrid/forward.h @@ -55,8 +55,6 @@ typedef xbt_dictelm_t sg_storage_t; typedef struct tmgr_trace *tmgr_trace_t; /**< Opaque structure defining an availability trace */ -typedef void *sg_routing_link_t; /* FIXME:The actual type is model-dependent so use void* instead*/ - typedef enum { SURF_LINK_FULLDUPLEX = 2, SURF_LINK_SHARED = 1, diff --git a/src/surf/network_ns3.cpp b/src/surf/network_ns3.cpp index e179d55249..9a9a5e4ebd 100644 --- a/src/surf/network_ns3.cpp +++ b/src/surf/network_ns3.cpp @@ -165,10 +165,10 @@ static void create_ns3_topology(void) simgrid::surf::Onelink *onelink; unsigned int iter; xbt_dynar_foreach(onelink_routes, iter, onelink) { - char *src = onelink->p_src->name(); - char *dst = onelink->p_dst->name(); + char *src = onelink->src_->name(); + char *dst = onelink->dst_->name(); simgrid::surf::NetworkNS3Link *link = - static_cast(onelink->p_link); + static_cast(onelink->link_); if (strcmp(src,dst) && link->m_created){ XBT_DEBUG("Route from '%s' to '%s' with link '%s'", src, dst, link->getName()); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 26a982e936..4a31798ea1 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -208,13 +208,13 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) static_cast(current_routing)->parse_specific_arguments(cluster); if(cluster->loopback_bw!=0 || cluster->loopback_lat!=0){ - ((AsCluster*)current_routing)->p_nb_links_per_node++; - ((AsCluster*)current_routing)->p_has_loopback=1; + ((AsCluster*)current_routing)->nb_links_per_node_++; + ((AsCluster*)current_routing)->has_loopback_=1; } if(cluster->limiter_link!=0){ - ((AsCluster*)current_routing)->p_nb_links_per_node++; - ((AsCluster*)current_routing)->p_has_limiter=1; + ((AsCluster*)current_routing)->nb_links_per_node_++; + ((AsCluster*)current_routing)->has_limiter_=1; } @@ -316,7 +316,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) info_loop.link_down = info_loop.link_up; free(tmp_link); xbt_dynar_set(current_routing->upDownLinks, - rankId*(static_cast(current_routing))->p_nb_links_per_node, &info_loop); + rankId*(static_cast(current_routing))->nb_links_per_node_, &info_loop); } //add a limiter link (shared link to account for maximal bandwidth of the node) @@ -338,7 +338,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) free(tmp_link); auto as_cluster = static_cast(current_routing); xbt_dynar_set(current_routing->upDownLinks, - rankId*(as_cluster)->p_nb_links_per_node + as_cluster->p_has_loopback , + rankId*(as_cluster)->nb_links_per_node_ + as_cluster->has_loopback_ , &info_lim); } @@ -350,9 +350,9 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) } else { static_cast(current_routing)->create_links_for_node(cluster, i, rankId, rankId* - static_cast(current_routing)->p_nb_links_per_node - + static_cast(current_routing)->p_has_loopback - + static_cast(current_routing)->p_has_limiter ); + static_cast(current_routing)->nb_links_per_node_ + + static_cast(current_routing)->has_loopback_ + + static_cast(current_routing)->has_limiter_ ); } xbt_free(link_id); xbt_free(host_id); @@ -381,7 +381,7 @@ void sg_platf_new_cluster(sg_platf_cluster_cbarg_t cluster) bprintf("%s%s_router%s", cluster->prefix, cluster->id, cluster->suffix); sg_platf_new_router(&router); - ((AsCluster*)current_routing)->p_router = (simgrid::surf::NetCard*) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL); + ((AsCluster*)current_routing)->router_ = (simgrid::surf::NetCard*) xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL); free(newid); //Make the backbone diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 7871a416ea..5253c9723d 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -186,12 +186,12 @@ void routing_AS_begin(sg_platf_AS_cbarg_t AS) /* make a new routing component */ simgrid::surf::NetCard *netcard = new simgrid::surf::NetCardImpl(new_as->name_, SURF_NETWORK_ELEMENT_AS, current_routing); - if (current_routing == NULL && routing_platf->p_root == NULL) { + if (current_routing == NULL && routing_platf->root_ == NULL) { /* it is the first one */ new_as->father_ = NULL; - routing_platf->p_root = new_as; + routing_platf->root_ = new_as; netcard->setId(-1); - } else if (current_routing != NULL && routing_platf->p_root != NULL) { + } else if (current_routing != NULL && routing_platf->root_ != NULL) { xbt_assert(!xbt_dict_get_or_null(current_routing->sons_, AS->id), "The AS \"%s\" already exists", AS->id); @@ -364,7 +364,7 @@ static void _get_route_and_latency( /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/ - route.link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + route.link_list = xbt_dynar_new(sizeof(Link*), NULL); // Find the net_card corresponding to father simgrid::surf::NetCard *src_father_netcard = src_father->netcard_; simgrid::surf::NetCard *dst_father_netcard = dst_father->netcard_; @@ -390,7 +390,7 @@ static void _get_route_and_latency( } AS_t surf_platf_get_root(routing_platf_t platf){ - return platf->p_root; + return platf->root_; } e_surf_network_element_type_t surf_routing_edge_get_rc_type(sg_netcard_t netcard){ @@ -418,8 +418,8 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t* r { XBT_DEBUG("getRouteAndLatency from %s to %s", src->name(), dst->name()); if (NULL == *route) { - xbt_dynar_reset(routing_platf->p_lastRoute); - *route = routing_platf->p_lastRoute; + xbt_dynar_reset(routing_platf->lastRoute_); + *route = routing_platf->lastRoute_; } _get_route_and_latency(src, dst, route, latency); @@ -429,7 +429,7 @@ void RoutingPlatf::getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t* r } xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){ - return recursiveGetOneLinkRoutes(p_root); + return recursiveGetOneLinkRoutes(root_); } xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(As *rc) @@ -478,9 +478,9 @@ void routing_cluster_add_backbone(simgrid::surf::Link* bb) { simgrid::surf::AsCluster *cluster = dynamic_cast(current_routing); xbt_assert(cluster, "Only hosts from Cluster can get a backbone."); - xbt_assert(nullptr == cluster->p_backbone, "Cluster %s already has a backbone link!", cluster->name_); + xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->name_); - cluster->p_backbone = bb; + cluster->backbone_ = bb; XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name_); } @@ -627,7 +627,7 @@ void sg_platf_new_peer(sg_platf_peer_cbarg_t peer) router.id = router_id; router.coord = peer->coord; sg_platf_new_router(&router); - static_cast(current_routing)->p_router = static_cast(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL)); + static_cast(current_routing)->router_ = static_cast(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL)); XBT_DEBUG(""); sg_platf_new_AS_end(); @@ -813,20 +813,20 @@ namespace simgrid { namespace surf { RoutingPlatf::RoutingPlatf(void *loopback) - : p_loopback(loopback) + : loopback_(loopback) { } RoutingPlatf::~RoutingPlatf() { - xbt_dynar_free(&p_lastRoute); - finalize_rec(p_root); + xbt_dynar_free(&lastRoute_); + finalize_rec(root_); } } } AS_t surf_AS_get_routing_root() { - return routing_platf->p_root; + return routing_platf->root_; } const char *surf_AS_get_name(simgrid::surf::As *as) { @@ -855,7 +855,7 @@ static simgrid::surf::As *surf_AS_recursive_get_by_name( simgrid::surf::As *surf_AS_get_by_name(const char * name) { - simgrid::surf::As *as = surf_AS_recursive_get_by_name(routing_platf->p_root, name); + simgrid::surf::As *as = surf_AS_recursive_get_by_name(routing_platf->root_, name); if(as == NULL) XBT_WARN("Impossible to find an AS with name %s, please check your input", name); return as; diff --git a/src/surf/surf_routing.hpp b/src/surf/surf_routing.hpp index b0d8e0a3c7..9aed674512 100644 --- a/src/surf/surf_routing.hpp +++ b/src/surf/surf_routing.hpp @@ -130,10 +130,10 @@ private: class Onelink { public: Onelink(void *link, NetCard *src, NetCard *dst) - : p_src(src), p_dst(dst), p_link(link) {}; - NetCard *p_src; - NetCard *p_dst; - void *p_link; + : src_(src), dst_(dst), link_(link) {}; + NetCard *src_; + NetCard *dst_; + void *link_; }; /** @ingroup SURF_routing_interface @@ -143,9 +143,9 @@ XBT_PUBLIC_CLASS RoutingPlatf { public: RoutingPlatf(void *loopback); ~RoutingPlatf(); - As *p_root = nullptr; - void *p_loopback; - xbt_dynar_t p_lastRoute = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); + As *root_ = nullptr; + void *loopback_; + xbt_dynar_t lastRoute_ = xbt_dynar_new(sizeof(Link*),NULL); xbt_dynar_t getOneLinkRoutes(void); xbt_dynar_t recursiveGetOneLinkRoutes(As *rc); void getRouteAndLatency(NetCard *src, NetCard *dst, xbt_dynar_t * links, double *latency); diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index fb64f1077a..1b648c5f44 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -27,8 +27,8 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb if (src->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router - if((src->id() == dst->id()) && p_has_loopback ){ - info = xbt_dynar_get_as(upDownLinks, src->id() * p_nb_links_per_node, s_surf_parsing_link_up_down_t); + if((src->id() == dst->id()) && has_loopback_ ){ + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); if (lat) *lat += static_cast(info.link_up)->getLatency(); @@ -36,12 +36,12 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb } - if (p_has_limiter){ // limiter for sender - info = xbt_dynar_get_as(upDownLinks, src->id() * p_nb_links_per_node + p_has_loopback, s_surf_parsing_link_up_down_t); + if (has_limiter_){ // limiter for sender + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); } - info = xbt_dynar_get_as(upDownLinks, src->id() * p_nb_links_per_node + p_has_loopback + p_has_limiter, s_surf_parsing_link_up_down_t); + info = xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_up) { // link up xbt_dynar_push_as(route->link_list, void *, info.link_up); if (lat) @@ -50,23 +50,23 @@ void AsCluster::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cb } - if (p_backbone) { + if (backbone_) { xbt_dynar_push_as(route->link_list, void *, - static_cast(p_backbone)); + static_cast(backbone_)); if (lat) - *lat += p_backbone->getLatency(); + *lat += backbone_->getLatency(); } if (dst->getRcType() != SURF_NETWORK_ELEMENT_ROUTER) { // No specific link for router - info = xbt_dynar_get_as(upDownLinks, dst->id() * p_nb_links_per_node + p_has_loopback + p_has_limiter, s_surf_parsing_link_up_down_t); + info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_ + has_limiter_, s_surf_parsing_link_up_down_t); if (info.link_down) { // link down xbt_dynar_push_as(route->link_list, void *, info.link_down); if (lat) *lat += static_cast(info.link_down)->getLatency(); } - if (p_has_limiter){ // limiter for receiver - info = xbt_dynar_get_as(upDownLinks, dst->id() * p_nb_links_per_node + p_has_loopback, s_surf_parsing_link_up_down_t); + if (has_limiter_){ // limiter for receiver + info = xbt_dynar_get_as(upDownLinks, dst->id() * nb_links_per_node_ + has_loopback_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); } } @@ -81,14 +81,14 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) xbt_node_t current, previous, backboneNode = NULL, routerNode; s_surf_parsing_link_up_down_t info; - xbt_assert(p_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."); /* create the router */ - char *link_name = p_router->name(); + char *link_name = router_->name(); routerNode = new_xbt_graph_node(graph, link_name, nodes); - if(p_backbone) { - const char *link_nameR = p_backbone->getName(); + if(backbone_) { + const char *link_nameR = backbone_->getName(); backboneNode = new_xbt_graph_node(graph, link_nameR, nodes); new_xbt_graph_edge(graph, routerNode, backboneNode, edges); @@ -109,7 +109,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); - if (p_backbone) { + if (backbone_) { new_xbt_graph_edge(graph, current, backboneNode, edges); } else { new_xbt_graph_edge(graph, current, routerNode, edges); @@ -123,7 +123,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) current = new_xbt_graph_node(graph, link_name, nodes); new_xbt_graph_edge(graph, previous, current, edges); - if (p_backbone) { + if (backbone_) { new_xbt_graph_edge(graph, current, backboneNode, edges); } else { new_xbt_graph_edge(graph, current, routerNode, edges); diff --git a/src/surf/surf_routing_cluster.hpp b/src/surf/surf_routing_cluster.hpp index 74018c5e8c..e58bb7e9b0 100644 --- a/src/surf/surf_routing_cluster.hpp +++ b/src/surf/surf_routing_cluster.hpp @@ -36,12 +36,12 @@ public: virtual void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) {} - Link* p_backbone = nullptr; - void *p_loopback = nullptr; - NetCard *p_router = nullptr; - int p_has_limiter = 0; - int p_has_loopback = 0; - int p_nb_links_per_node = 1; + Link* backbone_ = nullptr; + void *loopback_ = nullptr; + NetCard *router_ = nullptr; + int has_limiter_ = 0; + int has_loopback_ = 0; + int nb_links_per_node_ = 1; }; diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 2673e94874..b4667dd4b0 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -28,11 +28,11 @@ AsClusterFatTree::AsClusterFatTree(const char*name) } AsClusterFatTree::~AsClusterFatTree() { - for (unsigned int i = 0 ; i < this->nodes.size() ; i++) { - delete this->nodes[i]; + for (unsigned int i = 0 ; i < this->nodes_.size() ; i++) { + delete this->nodes_[i]; } - for (unsigned int i = 0 ; i < this->links.size() ; i++) { - delete this->links[i]; + for (unsigned int i = 0 ; i < this->links_.size() ; i++) { + delete this->links_[i]; } } @@ -48,7 +48,7 @@ bool AsClusterFatTree::isInSubTree(FatTreeNode *root, FatTreeNode *node) { } } - for (unsigned int i = root->level ; i < this->levels ; i++) { + for (unsigned int i = root->level ; i < this->levels_ ; i++) { if(root->label[i] != node->label[i]) { return false; } @@ -67,16 +67,16 @@ void AsClusterFatTree::getRouteAndLatency(NetCard *src, if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) return; /* Let's find the source and the destination in our internal structure */ - tempIter = this->computeNodes.find(src->id()); + tempIter = this->computeNodes_.find(src->id()); // xbt_die -> assert - if (tempIter == this->computeNodes.end()) { + if (tempIter == this->computeNodes_.end()) { xbt_die("Could not find the source %s [%d] in the fat tree", src->name(), src->id()); } source = tempIter->second; - tempIter = this->computeNodes.find(dst->id()); - if (tempIter == this->computeNodes.end()) { + tempIter = this->computeNodes_.find(dst->id()); + if (tempIter == this->computeNodes_.end()) { xbt_die("Could not find the destination %s [%d] in the fat tree", dst->name(), dst->id()); } @@ -89,7 +89,7 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ /* In case destination is the source, and there is a loopback, let's get through it instead of going up to a switch*/ - if(source->id == destination->id && this->p_has_loopback) { + if(source->id == destination->id && this->has_loopback_) { xbt_dynar_push_as(into->link_list, void*, source->loopback); if(latency) { *latency += source->loopback->getLatency(); @@ -105,9 +105,9 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ d = destination->position; for (unsigned int i = 0 ; i < currentNode->level ; i++) { - d /= this->upperLevelNodesNumber[i]; + d /= this->upperLevelNodesNumber_[i]; } - k = this->upperLevelNodesNumber[currentNode->level]; + k = this->upperLevelNodesNumber_[currentNode->level]; d = d % k; xbt_dynar_push_as(into->link_list, void*,currentNode->parents[d]->upLink); @@ -115,7 +115,7 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ *latency += currentNode->parents[d]->upLink->getLatency(); } - if (this->p_has_limiter) { + if (this->has_limiter_) { xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink); } currentNode = currentNode->parents[d]->upNode; @@ -128,14 +128,14 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ // Down part while(currentNode != destination) { for(unsigned int i = 0 ; i < currentNode->children.size() ; i++) { - if(i % this->lowerLevelNodesNumber[currentNode->level - 1] == + if(i % this->lowerLevelNodesNumber_[currentNode->level - 1] == destination->label[currentNode->level - 1]) { xbt_dynar_push_as(into->link_list, void*,currentNode->children[i]->downLink); if(latency) { *latency += currentNode->children[i]->downLink->getLatency(); } currentNode = currentNode->children[i]->downNode; - if (this->p_has_limiter) { + if (this->has_limiter_) { xbt_dynar_push_as(into->link_list, void*,currentNode->limiterLink); } XBT_DEBUG("%d(%u,%u) is accessible through %d(%u,%u)", destination->id, @@ -150,7 +150,7 @@ if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_ * addNodes() have already been called */ void AsClusterFatTree::create_links(){ - if(this->levels == 0) { + if(this->levels_ == 0) { return; } this->generateSwitches(); @@ -159,18 +159,18 @@ void AsClusterFatTree::create_links(){ if(XBT_LOG_ISENABLED(surf_route_fat_tree, xbt_log_priority_debug)) { std::stringstream msgBuffer; - msgBuffer << "We are creating a fat tree of " << this->levels << " levels " - << "with " << this->nodesByLevel[0] << " processing nodes"; - for (unsigned int i = 1 ; i <= this->levels ; i++) { - msgBuffer << ", " << this->nodesByLevel[i] << " switches at level " << i; + msgBuffer << "We are creating a fat tree of " << this->levels_ << " levels " + << "with " << this->nodesByLevel_[0] << " processing nodes"; + for (unsigned int i = 1 ; i <= this->levels_ ; i++) { + msgBuffer << ", " << this->nodesByLevel_[i] << " switches at level " << i; } XBT_DEBUG("%s", msgBuffer.str().c_str()); msgBuffer.str(""); msgBuffer << "Nodes are : "; - for (unsigned int i = 0 ; i < this->nodes.size() ; i++) { - msgBuffer << this->nodes[i]->id << "(" << this->nodes[i]->level << "," - << this->nodes[i]->position << ") "; + for (unsigned int i = 0 ; i < this->nodes_.size() ; i++) { + msgBuffer << this->nodes_[i]->id << "(" << this->nodes_[i]->level << "," + << this->nodes_[i]->position << ") "; } XBT_DEBUG("%s", msgBuffer.str().c_str()); } @@ -180,9 +180,9 @@ void AsClusterFatTree::create_links(){ unsigned int k = 0; // Nodes are totally ordered, by level and then by position, in this->nodes - for (unsigned int i = 0 ; i < this->levels ; i++) { - for (unsigned int j = 0 ; j < this->nodesByLevel[i] ; j++) { - this->connectNodeToParents(this->nodes[k]); + for (unsigned int i = 0 ; i < this->levels_ ; i++) { + for (unsigned int j = 0 ; j < this->nodesByLevel_[i] ; j++) { + this->connectNodeToParents(this->nodes_[k]); k++; } } @@ -190,9 +190,9 @@ void AsClusterFatTree::create_links(){ if(XBT_LOG_ISENABLED(surf_route_fat_tree, xbt_log_priority_debug)) { std::stringstream msgBuffer; msgBuffer << "Links are : "; - for (unsigned int i = 0 ; i < this->links.size() ; i++) { - msgBuffer << "(" << this->links[i]->upNode->id << "," - << this->links[i]->downNode->id << ") "; + for (unsigned int i = 0 ; i < this->links_.size() ; i++) { + msgBuffer << "(" << this->links_[i]->upNode->id << "," + << this->links_[i]->downNode->id << ") "; } XBT_DEBUG("%s", msgBuffer.str().c_str()); } @@ -201,23 +201,23 @@ void AsClusterFatTree::create_links(){ } int AsClusterFatTree::connectNodeToParents(FatTreeNode *node) { - std::vector::iterator currentParentNode = this->nodes.begin(); + std::vector::iterator currentParentNode = this->nodes_.begin(); int connectionsNumber = 0; const int level = node->level; XBT_DEBUG("We are connecting node %d(%u,%u) to his parents.", node->id, node->level, node->position); currentParentNode += this->getLevelPosition(level + 1); - for (unsigned int i = 0 ; i < this->nodesByLevel[level + 1] ; i++ ) { + for (unsigned int i = 0 ; i < this->nodesByLevel_[level + 1] ; i++ ) { if(this->areRelated(*currentParentNode, node)) { XBT_DEBUG("%d(%u,%u) and %d(%u,%u) are related," " with %u links between them.", node->id, node->level, node->position, (*currentParentNode)->id, - (*currentParentNode)->level, (*currentParentNode)->position, this->lowerLevelPortsNumber[level]); - for (unsigned int j = 0 ; j < this->lowerLevelPortsNumber[level] ; j++) { + (*currentParentNode)->level, (*currentParentNode)->position, this->lowerLevelPortsNumber_[level]); + for (unsigned int j = 0 ; j < this->lowerLevelPortsNumber_[level] ; j++) { this->addLink(*currentParentNode, node->label[level] + - j * this->lowerLevelNodesNumber[level], node, + j * this->lowerLevelNodesNumber_[level], node, (*currentParentNode)->label[level] + - j * this->upperLevelNodesNumber[level]); + j * this->upperLevelNodesNumber_[level]); } connectionsNumber++; } @@ -234,14 +234,14 @@ bool AsClusterFatTree::areRelated(FatTreeNode *parent, FatTreeNode *child) { msgBuffer << "Are " << child->id << "(" << child->level << "," << child->position << ") <"; - for (unsigned int i = 0 ; i < this->levels ; i++) { + for (unsigned int i = 0 ; i < this->levels_ ; i++) { msgBuffer << child->label[i] << ","; } msgBuffer << ">"; msgBuffer << " and " << parent->id << "(" << parent->level << "," << parent->position << ") <"; - for (unsigned int i = 0 ; i < this->levels ; i++) { + for (unsigned int i = 0 ; i < this->levels_ ; i++) { msgBuffer << parent->label[i] << ","; } msgBuffer << ">"; @@ -253,7 +253,7 @@ bool AsClusterFatTree::areRelated(FatTreeNode *parent, FatTreeNode *child) { return false; } - for (unsigned int i = 0 ; i < this->levels; i++) { + for (unsigned int i = 0 ; i < this->levels_; i++) { if (parent->label[i] != child->label[i] && i + 1 != parent->level) { return false; } @@ -263,56 +263,56 @@ bool AsClusterFatTree::areRelated(FatTreeNode *parent, FatTreeNode *child) { void AsClusterFatTree::generateSwitches() { XBT_DEBUG("Generating switches."); - this->nodesByLevel.resize(this->levels + 1, 0); + this->nodesByLevel_.resize(this->levels_ + 1, 0); unsigned int nodesRequired = 0; // We take care of the number of nodes by level - this->nodesByLevel[0] = 1; - for (unsigned int i = 0 ; i < this->levels ; i++) { - this->nodesByLevel[0] *= this->lowerLevelNodesNumber[i]; + this->nodesByLevel_[0] = 1; + for (unsigned int i = 0 ; i < this->levels_ ; i++) { + this->nodesByLevel_[0] *= this->lowerLevelNodesNumber_[i]; } - if(this->nodesByLevel[0] != this->nodes.size()) { + if(this->nodesByLevel_[0] != this->nodes_.size()) { surf_parse_error("The number of provided nodes does not fit with the wanted topology." " Please check your platform description (We need %d nodes, we got %zu)", - this->nodesByLevel[0], this->nodes.size()); + this->nodesByLevel_[0], this->nodes_.size()); return; } - for (unsigned int i = 0 ; i < this->levels ; i++) { + for (unsigned int i = 0 ; i < this->levels_ ; i++) { int nodesInThisLevel = 1; for (unsigned int j = 0 ; j <= i ; j++) { - nodesInThisLevel *= this->upperLevelNodesNumber[j]; + nodesInThisLevel *= this->upperLevelNodesNumber_[j]; } - for (unsigned int j = i+1 ; j < this->levels ; j++) { - nodesInThisLevel *= this->lowerLevelNodesNumber[j]; + for (unsigned int j = i+1 ; j < this->levels_ ; j++) { + nodesInThisLevel *= this->lowerLevelNodesNumber_[j]; } - this->nodesByLevel[i+1] = nodesInThisLevel; + this->nodesByLevel_[i+1] = nodesInThisLevel; nodesRequired += nodesInThisLevel; } // We create the switches int k = 0; - for (unsigned int i = 0 ; i < this->levels ; i++) { - for (unsigned int j = 0 ; j < this->nodesByLevel[i + 1] ; j++) { + for (unsigned int i = 0 ; i < this->levels_ ; i++) { + for (unsigned int j = 0 ; j < this->nodesByLevel_[i + 1] ; j++) { FatTreeNode* newNode; - newNode = new FatTreeNode(this->cluster, --k, i + 1, j); + newNode = new FatTreeNode(this->cluster_, --k, i + 1, j); XBT_DEBUG("We create the switch %d(%d,%d)", newNode->id, newNode->level, newNode->position); - newNode->children.resize(this->lowerLevelNodesNumber[i] * - this->lowerLevelPortsNumber[i]); - if (i != this->levels - 1) { - newNode->parents.resize(this->upperLevelNodesNumber[i + 1] * - this->lowerLevelPortsNumber[i + 1]); + newNode->children.resize(this->lowerLevelNodesNumber_[i] * + this->lowerLevelPortsNumber_[i]); + if (i != this->levels_ - 1) { + newNode->parents.resize(this->upperLevelNodesNumber_[i + 1] * + this->lowerLevelPortsNumber_[i + 1]); } - newNode->label.resize(this->levels); - this->nodes.push_back(newNode); + newNode->label.resize(this->levels_); + this->nodes_.push_back(newNode); } } } @@ -320,30 +320,30 @@ void AsClusterFatTree::generateSwitches() { void AsClusterFatTree::generateLabels() { XBT_DEBUG("Generating labels."); // TODO : check if nodesByLevel and nodes are filled - std::vector maxLabel(this->levels); - std::vector currentLabel(this->levels); + std::vector maxLabel(this->levels_); + std::vector currentLabel(this->levels_); unsigned int k = 0; - for (unsigned int i = 0 ; i <= this->levels ; i++) { - currentLabel.assign(this->levels, 0); - for (unsigned int j = 0 ; j < this->levels ; j++) { + for (unsigned int i = 0 ; i <= this->levels_ ; i++) { + currentLabel.assign(this->levels_, 0); + for (unsigned int j = 0 ; j < this->levels_ ; j++) { maxLabel[j] = j + 1 > i ? - this->lowerLevelNodesNumber[j] : this->upperLevelNodesNumber[j]; + this->lowerLevelNodesNumber_[j] : this->upperLevelNodesNumber_[j]; } - for (unsigned int j = 0 ; j < this->nodesByLevel[i] ; j++) { + for (unsigned int j = 0 ; j < this->nodesByLevel_[i] ; j++) { if(XBT_LOG_ISENABLED(surf_route_fat_tree, xbt_log_priority_debug )) { std::stringstream msgBuffer; msgBuffer << "Assigning label <"; - for (unsigned int l = 0 ; l < this->levels ; l++) { + for (unsigned int l = 0 ; l < this->levels_ ; l++) { msgBuffer << currentLabel[l] << ","; } msgBuffer << "> to " << k << " (" << i << "," << j <<")"; XBT_DEBUG("%s", msgBuffer.str().c_str()); } - this->nodes[k]->label.assign(currentLabel.begin(), currentLabel.end()); + this->nodes_[k]->label.assign(currentLabel.begin(), currentLabel.end()); bool remainder = true; @@ -366,7 +366,7 @@ void AsClusterFatTree::generateLabels() { ++pos; } } - while(remainder && pos < this->levels); + while(remainder && pos < this->levels_); k++; } } @@ -374,14 +374,14 @@ void AsClusterFatTree::generateLabels() { int AsClusterFatTree::getLevelPosition(const unsigned int level) { - if (level > this->levels) { + if (level > this->levels_) { // Well, that should never happen. Maybe should we throw instead. return -1; } int tempPosition = 0; for (unsigned int i = 0 ; i < level ; i++) { - tempPosition += this->nodesByLevel[i]; + tempPosition += this->nodesByLevel_[i]; } return tempPosition; } @@ -390,25 +390,25 @@ void AsClusterFatTree::addProcessingNode(int id) { using std::make_pair; static int position = 0; FatTreeNode* newNode; - newNode = new FatTreeNode(this->cluster, id, 0, position++); - newNode->parents.resize(this->upperLevelNodesNumber[0] * - this->lowerLevelPortsNumber[0]); - newNode->label.resize(this->levels); - this->computeNodes.insert(make_pair(id,newNode)); - this->nodes.push_back(newNode); + newNode = new FatTreeNode(this->cluster_, id, 0, position++); + newNode->parents.resize(this->upperLevelNodesNumber_[0] * + this->lowerLevelPortsNumber_[0]); + newNode->label.resize(this->levels_); + this->computeNodes_.insert(make_pair(id,newNode)); + this->nodes_.push_back(newNode); } void AsClusterFatTree::addLink(FatTreeNode *parent, unsigned int parentPort, FatTreeNode *child, unsigned int childPort) { FatTreeLink *newLink; - newLink = new FatTreeLink(this->cluster, child, parent); + newLink = new FatTreeLink(this->cluster_, child, parent); XBT_DEBUG("Creating a link between the parent (%d,%d,%u)" " and the child (%d,%d,%u)", parent->level, parent->position, parentPort, child->level, child->position, childPort); parent->children[parentPort] = newLink; child->parents[childPort] = newLink; - this->links.push_back(newLink); + this->links_.push_back(newLink); @@ -428,39 +428,39 @@ void AsClusterFatTree::parse_specific_arguments(sg_platf_cluster_cbarg_t } // The first parts of topo_parameters should be the levels number - this->levels = xbt_str_parse_int(parameters[0].c_str(), "First parameter is not the amount of levels: %s"); + this->levels_ = xbt_str_parse_int(parameters[0].c_str(), "First parameter is not the amount of levels: %s"); // Then, a l-sized vector standing for the childs number by level boost::split(tmp, parameters[1], boost::is_any_of(",")); - if(tmp.size() != this->levels) { + if(tmp.size() != this->levels_) { surf_parse_error("Fat trees are defined by the levels number and 3 vectors" ", see the documentation for more informations"); } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->lowerLevelNodesNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); + this->lowerLevelNodesNumber_.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); } // Then, a l-sized vector standing for the parents number by level boost::split(tmp, parameters[2], boost::is_any_of(",")); - if(tmp.size() != this->levels) { + if(tmp.size() != this->levels_) { surf_parse_error("Fat trees are defined by the levels number and 3 vectors" ", see the documentation for more informations"); } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->upperLevelNodesNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid upper level node number: %s")); + this->upperLevelNodesNumber_.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid upper level node number: %s")); } // Finally, a l-sized vector standing for the ports number with the lower level boost::split(tmp, parameters[3], boost::is_any_of(",")); - if(tmp.size() != this->levels) { + if(tmp.size() != this->levels_) { surf_parse_error("Fat trees are defined by the levels number and 3 vectors" ", see the documentation for more informations"); } for(size_t i = 0 ; i < tmp.size() ; i++){ - this->lowerLevelPortsNumber.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); + this->lowerLevelPortsNumber_.push_back(xbt_str_parse_int(tmp[i].c_str(), "Invalid lower level node number: %s")); } - this->cluster = cluster; + this->cluster_ = cluster; } @@ -473,9 +473,9 @@ void AsClusterFatTree::generateDotFile(const std::string& filename) const { if(file.is_open()) { file << "graph AsClusterFatTree {\n"; - for (unsigned int i = 0 ; i < this->nodes.size() ; i++) { - file << this->nodes[i]->id; - if(this->nodes[i]->id < 0) { + for (unsigned int i = 0 ; i < this->nodes_.size() ; i++) { + file << this->nodes_[i]->id; + if(this->nodes_[i]->id < 0) { file << " [shape=circle];\n"; } else { @@ -483,10 +483,10 @@ void AsClusterFatTree::generateDotFile(const std::string& filename) const { } } - for (unsigned int i = 0 ; i < this->links.size() ; i++ ) { - file << this->links[i]->downNode->id + for (unsigned int i = 0 ; i < this->links_.size() ; i++ ) { + file << this->links_[i]->downNode->id << " -- " - << this->links[i]->upNode->id + << this->links_[i]->upNode->id << ";\n"; } file << "}"; diff --git a/src/surf/surf_routing_cluster_fat_tree.hpp b/src/surf/surf_routing_cluster_fat_tree.hpp index 258dcd6ebd..410479f93b 100644 --- a/src/surf/surf_routing_cluster_fat_tree.hpp +++ b/src/surf/surf_routing_cluster_fat_tree.hpp @@ -140,17 +140,17 @@ public: private: //description of a PGFT (TODO : better doc) - unsigned int levels = 0; - std::vector lowerLevelNodesNumber; // number of children by node - std::vector upperLevelNodesNumber; // number of parents by node - std::vector lowerLevelPortsNumber; // ports between each level l and l-1 + unsigned int levels_ = 0; + std::vector lowerLevelNodesNumber_; // number of children by node + std::vector upperLevelNodesNumber_; // number of parents by node + std::vector lowerLevelPortsNumber_; // ports between each level l and l-1 - std::map computeNodes; - std::vector nodes; - std::vector links; - std::vector nodesByLevel; + std::map computeNodes_; + std::vector nodes_; + std::vector links_; + std::vector nodesByLevel_; - sg_platf_cluster_cbarg_t cluster; + sg_platf_cluster_cbarg_t cluster_; void addLink(FatTreeNode *parent, unsigned int parentPort, FatTreeNode *child, unsigned int childPort); diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 8efc676335..6f6c6bc772 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -31,7 +31,7 @@ namespace simgrid { : AsCluster(name) { } AsClusterTorus::~AsClusterTorus() { - xbt_dynar_free(&p_dimensions); + xbt_dynar_free(&p_dimensions_); } void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) { @@ -47,10 +47,10 @@ namespace simgrid { // we need to iterate over all dimensions // and create all links there dim_product = 1; // Needed to calculate the next neighbour_id - for (j = 0; j < xbt_dynar_length(p_dimensions); j++) { + for (j = 0; j < xbt_dynar_length(p_dimensions_); j++) { memset(&link, 0, sizeof(link)); - current_dimension = xbt_dynar_get_as(p_dimensions, j, int); + current_dimension = xbt_dynar_get_as(p_dimensions_, j, int); neighbour_rank_id = (((int) rank / dim_product) % current_dimension == current_dimension - 1) ? rank - (current_dimension - 1) * dim_product : rank + dim_product; @@ -93,7 +93,7 @@ namespace simgrid { xbt_dynar_t dimensions = xbt_str_split(cluster->topo_parameters, ","); if (!xbt_dynar_is_empty(dimensions)) { - p_dimensions = xbt_dynar_new(sizeof(int), NULL); + p_dimensions_ = xbt_dynar_new(sizeof(int), NULL); /** * We are in a torus cluster * Parse attribute dimensions="dim1,dim2,dim3,...,dimN" @@ -102,10 +102,10 @@ namespace simgrid { */ 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); + xbt_dynar_set_as(p_dimensions_, iter, int, tmp); } - p_nb_links_per_node = xbt_dynar_length(p_dimensions); + nb_links_per_node_ = xbt_dynar_length(p_dimensions_); } xbt_dynar_free(&dimensions); @@ -119,9 +119,9 @@ namespace simgrid { if (dst->getRcType() == SURF_NETWORK_ELEMENT_ROUTER || src->getRcType() == SURF_NETWORK_ELEMENT_ROUTER) return; - if ((src->id() == dst->id()) && p_has_loopback) { + if ((src->id() == dst->id()) && has_loopback_) { s_surf_parsing_link_up_down_t info = - xbt_dynar_get_as(upDownLinks, src->id() * p_nb_links_per_node, s_surf_parsing_link_up_down_t); + xbt_dynar_get_as(upDownLinks, src->id() * nb_links_per_node_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); if (lat) @@ -144,8 +144,8 @@ namespace simgrid { * into this dimension or not. */ unsigned int *myCoords, *targetCoords; - myCoords = rankId_to_coords(src->id(), p_dimensions); - targetCoords = rankId_to_coords(dst->id(), p_dimensions); + myCoords = rankId_to_coords(src->id(), p_dimensions_); + targetCoords = rankId_to_coords(dst->id(), p_dimensions_); /** * linkOffset describes the offset where the link * we want to use is stored @@ -153,15 +153,15 @@ namespace simgrid { * which can only be the case if src->m_id == dst->m_id -- see above * for this special case) */ - int nodeOffset = (xbt_dynar_length(p_dimensions) + 1) * src->id(); + int nodeOffset = (xbt_dynar_length(p_dimensions_) + 1) * src->id(); int linkOffset = nodeOffset; bool use_lnk_up = false; // Is this link of the form "cur -> next" or "next -> cur"? // false means: next -> cur while (current_node != dst->id()) { 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); + 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 ((current_node / dim_product) % cur_dim != (dst->id() / dim_product) % cur_dim) { @@ -174,8 +174,8 @@ namespace simgrid { next_node = (current_node + dim_product); // HERE: We use *CURRENT* node for calculation (as opposed to next_node) - nodeOffset = current_node * (p_nb_links_per_node); - linkOffset = nodeOffset + p_has_loopback + p_has_limiter + j; + nodeOffset = current_node * (nb_links_per_node_); + linkOffset = nodeOffset + has_loopback_ + has_limiter_ + j; use_lnk_up = true; assert(linkOffset >= 0); } else { // Route to the left @@ -185,8 +185,8 @@ namespace simgrid { next_node = (current_node - dim_product); // HERE: We use *next* node for calculation (as opposed to current_node!) - nodeOffset = next_node * (p_nb_links_per_node); - linkOffset = nodeOffset + j + p_has_loopback + p_has_limiter; + nodeOffset = next_node * (nb_links_per_node_); + linkOffset = nodeOffset + j + has_loopback_ + has_limiter_; use_lnk_up = false; assert(linkOffset >= 0); @@ -202,8 +202,8 @@ namespace simgrid { s_surf_parsing_link_up_down_t info; - if (p_has_limiter) { // limiter for sender - info = xbt_dynar_get_as(upDownLinks, nodeOffset + p_has_loopback, s_surf_parsing_link_up_down_t); + if (has_limiter_) { // limiter for sender + info = xbt_dynar_get_as(upDownLinks, nodeOffset + has_loopback_, s_surf_parsing_link_up_down_t); xbt_dynar_push_as(route->link_list, void *, info.link_up); } diff --git a/src/surf/surf_routing_cluster_torus.hpp b/src/surf/surf_routing_cluster_torus.hpp index b516c73b02..f92c67fcab 100644 --- a/src/surf/surf_routing_cluster_torus.hpp +++ b/src/surf/surf_routing_cluster_torus.hpp @@ -24,7 +24,7 @@ namespace simgrid { void create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) override; void getRouteAndLatency(NetCard * src, NetCard * dst, sg_platf_route_cbarg_t into, double *latency) override; void parse_specific_arguments(sg_platf_cluster_cbarg_t cluster) override; - xbt_dynar_t p_dimensions = NULL; + xbt_dynar_t p_dimensions_ = NULL; }; }} diff --git a/src/surf/surf_routing_dijkstra.cpp b/src/surf/surf_routing_dijkstra.cpp index 940269bcac..e880ba32cf 100644 --- a/src/surf/surf_routing_dijkstra.cpp +++ b/src/surf/surf_routing_dijkstra.cpp @@ -43,17 +43,17 @@ namespace surf { void AsDijkstra::Seal() { /* Create the topology graph */ - if(!p_routeGraph) - p_routeGraph = xbt_graph_new_graph(1, NULL); - if(!p_graphNodeMap) - p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free); + if(!routeGraph_) + routeGraph_ = xbt_graph_new_graph(1, NULL); + if(!graphNodeMap_) + graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free); /* Add the loopback if needed */ - if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE) + if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) addLoopback(); /* initialize graph indexes in nodes after graph has been built */ - xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph); + xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node = NULL; unsigned int cursor2; @@ -72,11 +72,11 @@ xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id) data = xbt_new0(struct graph_node_data, 1); data->id = id; data->graph_id = graph_id; - node = xbt_graph_new_node(p_routeGraph, data); + node = xbt_graph_new_node(routeGraph_, data); elm = xbt_new0(struct graph_node_map_element, 1); elm->node = node; - xbt_dict_set_ext(p_graphNodeMap, (char *) (&id), sizeof(int), + xbt_dict_set_ext(graphNodeMap_, (char *) (&id), sizeof(int), (xbt_dictelm_t) elm, NULL); return node; @@ -85,7 +85,7 @@ xbt_node_t AsDijkstra::routeGraphNewNode(int id, int graph_id) graph_node_map_element_t AsDijkstra::nodeMapSearch(int id) { graph_node_map_element_t elm = (graph_node_map_element_t) - xbt_dict_get_or_null_ext(p_graphNodeMap, + xbt_dict_get_or_null_ext(graphNodeMap_, (char *) (&id), sizeof(int)); return elm; @@ -100,11 +100,11 @@ void AsDijkstra::newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route xbt_node_t dst = NULL; graph_node_map_element_t src_elm = (graph_node_map_element_t) - xbt_dict_get_or_null_ext(p_graphNodeMap, + xbt_dict_get_or_null_ext(graphNodeMap_, (char *) (&src_id), sizeof(int)); graph_node_map_element_t dst_elm = (graph_node_map_element_t) - xbt_dict_get_or_null_ext(p_graphNodeMap, + xbt_dict_get_or_null_ext(graphNodeMap_, (char *) (&dst_id), sizeof(int)); @@ -129,11 +129,11 @@ void AsDijkstra::newRoute(int src_id, int dst_id, sg_platf_route_cbarg_t e_route } /* add link as edge to graph */ - xbt_graph_new_edge(p_routeGraph, src, dst, e_route); + xbt_graph_new_edge(routeGraph_, src, dst, e_route); } void AsDijkstra::addLoopback() { - xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph); + xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node = NULL; unsigned int cursor2; @@ -153,9 +153,9 @@ void AsDijkstra::addLoopback() { if (!found) { sg_platf_route_cbarg_t e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback); - xbt_graph_new_edge(p_routeGraph, node, node, e_route); + e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); + xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); + xbt_graph_new_edge(routeGraph_, node, node, e_route); } } } @@ -164,7 +164,7 @@ xbt_dynar_t AsDijkstra::getOneLinkRoutes() { xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t,1); - route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t),NULL); + route->link_list = xbt_dynar_new(sizeof(Link*),NULL); int src,dst; NetCard *src_elm, *dst_elm; @@ -206,7 +206,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c int size = 0; unsigned int cpt; void *link; - xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph); + xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); /* Use the graph_node id mapping set to quickly find the nodes */ graph_node_map_element_t src_elm = nodeMapSearch(src_id); @@ -220,7 +220,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_node_id, xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_node_id, xbt_node_t); - xbt_edge_t edge = xbt_graph_get_edge(p_routeGraph, node_s_v, node_e_v); + xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_s_v, node_e_v); if (edge == NULL) THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name()); @@ -236,9 +236,9 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c } route_cache_element_t elm = NULL; - if (p_routeCache) { /* cache mode */ + if (routeCache_) { /* cache mode */ elm = (route_cache_element_t) - xbt_dict_get_or_null_ext(p_routeCache, (char *) (&src_id), sizeof(int)); + xbt_dict_get_or_null_ext(routeCache_, (char *) (&src_id), sizeof(int)); } if (elm) { /* cached mode and cache hit */ @@ -305,7 +305,7 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c for (int v = dst_node_id; v != src_node_id; v = pred_arr[v]) { xbt_node_t node_pred_v = xbt_dynar_get_as(nodes, pred_arr[v], xbt_node_t); xbt_node_t node_v = xbt_dynar_get_as(nodes, v, xbt_node_t); - xbt_edge_t edge = xbt_graph_get_edge(p_routeGraph, node_pred_v, node_v); + xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_pred_v, node_v); if (edge == NULL) THROWF(arg_error, 0, "No route from '%s' to '%s'", src->name(), dst->name()); @@ -348,23 +348,23 @@ void AsDijkstra::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_c route->gw_dst = first_gw; } - if (p_routeCache && elm == NULL) { + if (routeCache_ && elm == NULL) { /* add to predecessor list of the current src-host to cache */ elm = xbt_new0(struct route_cache_element, 1); elm->pred_arr = pred_arr; elm->size = size; - xbt_dict_set_ext(p_routeCache, (char *) (&src_id), sizeof(int), (xbt_dictelm_t) elm, NULL); + xbt_dict_set_ext(routeCache_, (char *) (&src_id), sizeof(int), (xbt_dictelm_t) elm, NULL); } - if (!p_routeCache) + if (!routeCache_) xbt_free(pred_arr); } AsDijkstra::~AsDijkstra() { - xbt_graph_free_graph(p_routeGraph, &xbt_free_f, &graph_edge_data_free, &xbt_free_f); - xbt_dict_free(&p_graphNodeMap); - xbt_dict_free(&p_routeCache); + xbt_graph_free_graph(routeGraph_, &xbt_free_f, &graph_edge_data_free, &xbt_free_f); + xbt_dict_free(&graphNodeMap_); + xbt_dict_free(&routeCache_); } /* Creation routing model functions */ @@ -373,7 +373,7 @@ AsDijkstra::AsDijkstra(const char*name, bool cached) : AsGeneric(name) { if (cached) - p_routeCache = xbt_dict_new_homogeneous(&route_cache_elem_free); + routeCache_ = xbt_dict_new_homogeneous(&route_cache_elem_free); } void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route) @@ -386,10 +386,10 @@ void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route) parseRouteCheckParams(route); /* Create the topology graph */ - if(!p_routeGraph) - p_routeGraph = xbt_graph_new_graph(1, NULL); - if(!p_graphNodeMap) - p_graphNodeMap = xbt_dict_new_homogeneous(&graph_node_map_elem_free); + if(!routeGraph_) + routeGraph_ = xbt_graph_new_graph(1, NULL); + if(!graphNodeMap_) + graphNodeMap_ = xbt_dict_new_homogeneous(&graph_node_map_elem_free); sg_platf_route_cbarg_t e_route = newExtendedRoute(hierarchy_, route, 1); newRoute(src_net_elm->id(), dst_net_elm->id(), e_route); @@ -401,10 +401,10 @@ void AsDijkstra::parseRoute(sg_platf_route_cbarg_t route) else XBT_DEBUG("Load ASroute from %s@%s to %s@%s", dst, route->gw_dst->name(), src, route->gw_src->name()); - xbt_dynar_t nodes = xbt_graph_get_nodes(p_routeGraph); + xbt_dynar_t nodes = xbt_graph_get_nodes(routeGraph_); xbt_node_t node_s_v = xbt_dynar_get_as(nodes, src_net_elm->id(), xbt_node_t); xbt_node_t node_e_v = xbt_dynar_get_as(nodes, dst_net_elm->id(), xbt_node_t); - xbt_edge_t edge = xbt_graph_get_edge(p_routeGraph, node_e_v, node_s_v); + xbt_edge_t edge = xbt_graph_get_edge(routeGraph_, node_e_v, node_s_v); if (edge) THROWF(arg_error,0, "Route from %s@%s to %s@%s already exists", dst, route->gw_dst->name(), src, route->gw_src->name()); diff --git a/src/surf/surf_routing_dijkstra.hpp b/src/surf/surf_routing_dijkstra.hpp index 7e3b8ffa85..6f161c19b2 100644 --- a/src/surf/surf_routing_dijkstra.hpp +++ b/src/surf/surf_routing_dijkstra.hpp @@ -62,9 +62,9 @@ public: xbt_dynar_t getOneLinkRoutes() override; void parseRoute(sg_platf_route_cbarg_t route) override; - xbt_graph_t p_routeGraph = nullptr; /* xbt_graph */ - xbt_dict_t p_graphNodeMap = nullptr; /* map */ - xbt_dict_t p_routeCache = nullptr; /* use in cache mode */ + xbt_graph_t routeGraph_ = nullptr; /* xbt_graph */ + xbt_dict_t graphNodeMap_ = nullptr; /* map */ + xbt_dict_t routeCache_ = nullptr; /* use in cache mode */ }; } diff --git a/src/surf/surf_routing_floyd.cpp b/src/surf/surf_routing_floyd.cpp index 07543520e8..b05296456e 100644 --- a/src/surf/surf_routing_floyd.cpp +++ b/src/surf/surf_routing_floyd.cpp @@ -10,9 +10,9 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_floyd, surf, "Routing part of surf"); -#define TO_FLOYD_COST(i,j) (p_costTable)[(i)+(j)*table_size] -#define TO_FLOYD_PRED(i,j) (p_predecessorTable)[(i)+(j)*table_size] -#define TO_FLOYD_LINK(i,j) (p_linkTable)[(i)+(j)*table_size] +#define TO_FLOYD_COST(i,j) (costTable_)[(i)+(j)*table_size] +#define TO_FLOYD_PRED(i,j) (predecessorTable_)[(i)+(j)*table_size] +#define TO_FLOYD_LINK(i,j) (linkTable_)[(i)+(j)*table_size] namespace simgrid { namespace surf { @@ -20,28 +20,28 @@ namespace surf { AsFloyd::AsFloyd(const char*name) : AsGeneric(name) { - p_predecessorTable = NULL; - p_costTable = NULL; - p_linkTable = NULL; + predecessorTable_ = NULL; + costTable_ = NULL; + linkTable_ = NULL; } AsFloyd::~AsFloyd(){ int i, j; int table_size; table_size = (int)xbt_dynar_length(vertices_); - if (p_linkTable == NULL) // Dealing with a parse error in the file? + if (linkTable_ == NULL) // Dealing with a parse error in the file? return; /* Delete link_table */ for (i = 0; i < table_size; i++) for (j = 0; j < table_size; j++) { routing_route_free(TO_FLOYD_LINK(i, j)); } - xbt_free(p_linkTable); + xbt_free(linkTable_); /* Delete bypass dict */ xbt_dict_free(&bypassRoutes_); /* Delete predecessor and cost table */ - xbt_free(p_predecessorTable); - xbt_free(p_costTable); + xbt_free(predecessorTable_); + xbt_free(costTable_); } /* Business methods */ @@ -49,7 +49,7 @@ xbt_dynar_t AsFloyd::getOneLinkRoutes() { xbt_dynar_t ret = xbt_dynar_new(sizeof(Onelink*), xbt_free_f); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + route->link_list = xbt_dynar_new(sizeof(Link*), NULL); int src,dst; sg_netcard_t src_elm, dst_elm; @@ -118,7 +118,7 @@ void AsFloyd::getRouteAndLatency(NetCard *src, NetCard *dst, sg_platf_route_cbar links = e_route->link_list; xbt_dynar_foreach(links, cpt, link) { - xbt_dynar_push_as(res->link_list, sg_routing_link_t, link); + xbt_dynar_push_as(res->link_list, Link*, (Link*)link); if (lat) *lat += static_cast(link)->getLatency(); } @@ -145,13 +145,13 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) parseRouteCheckParams(route); - if(!p_linkTable) + if(!linkTable_) { int i,j; /* Create Cost, Predecessor and Link tables */ - p_costTable = xbt_new0(double, table_size * table_size); /* link cost from host to host */ - p_predecessorTable = xbt_new0(int, table_size * table_size); /* predecessor host numbers */ - p_linkTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */ + costTable_ = xbt_new0(double, table_size * table_size); /* link cost from host to host */ + predecessorTable_ = xbt_new0(int, table_size * table_size); /* predecessor host numbers */ + linkTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */ /* Initialize costs and predecessors */ for (i = 0; i < table_size; i++) @@ -167,7 +167,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) char * link_name; unsigned int cpt; - xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL); xbt_dynar_foreach(route->link_list,cpt,link_name) { void *link = Link::byName(link_name); @@ -198,7 +198,7 @@ void AsFloyd::parseRoute(sg_platf_route_cbarg_t route) XBT_DEBUG("See ASroute from \"%s(%s)\" to \"%s(%s)\"", dst, route->gw_src->name(), src, route->gw_dst->name()); char * link_name; - xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL); for(int i=xbt_dynar_length(route->link_list) ;i>0 ;i--) { link_name = xbt_dynar_get_as(route->link_list,i-1,char *); void *link = Link::byName(link_name); @@ -241,11 +241,11 @@ void AsFloyd::Seal(){ /* set the size of table routing */ size_t table_size = xbt_dynar_length(vertices_); - if(!p_linkTable) { + if(!linkTable_) { /* Create Cost, Predecessor and Link tables */ - p_costTable = xbt_new0(double, table_size * table_size); /* link cost from host to host */ - p_predecessorTable = xbt_new0(int, table_size * table_size); /* predecessor host numbers */ - p_linkTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */ + costTable_ = xbt_new0(double, table_size * table_size); /* link cost from host to host */ + predecessorTable_ = xbt_new0(int, table_size * table_size); /* predecessor host numbers */ + linkTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* actual link between src and dst */ /* Initialize costs and predecessors */ for (i = 0; i < table_size; i++) @@ -257,15 +257,15 @@ void AsFloyd::Seal(){ } /* Add the loopback if needed */ - if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE) { + if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) { for (i = 0; i < table_size; i++) { sg_platf_route_cbarg_t e_route = TO_FLOYD_LINK(i, i); if (!e_route) { e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback); + e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); + xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); TO_FLOYD_LINK(i, i) = e_route; TO_FLOYD_PRED(i, i) = i; TO_FLOYD_COST(i, i) = 1; diff --git a/src/surf/surf_routing_floyd.hpp b/src/surf/surf_routing_floyd.hpp index 90016cba48..9e3d722353 100644 --- a/src/surf/surf_routing_floyd.hpp +++ b/src/surf/surf_routing_floyd.hpp @@ -33,9 +33,9 @@ public: private: /* vars to compute the Floyd algorithm. */ - int *p_predecessorTable; - double *p_costTable; - sg_platf_route_cbarg_t *p_linkTable; + int *predecessorTable_; + double *costTable_; + sg_platf_route_cbarg_t *linkTable_; }; } diff --git a/src/surf/surf_routing_full.cpp b/src/surf/surf_routing_full.cpp index 5bd17ec881..9cf68f16ed 100644 --- a/src/surf/surf_routing_full.cpp +++ b/src/surf/surf_routing_full.cpp @@ -10,7 +10,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf"); -#define TO_ROUTE_FULL(i,j) p_routingTable[(i)+(j)*table_size] +#define TO_ROUTE_FULL(i,j) routingTable_[(i)+(j)*table_size] namespace simgrid { namespace surf { @@ -27,19 +27,19 @@ void AsFull::Seal() { int table_size = (int)xbt_dynar_length(vertices_); /* Create table if necessary */ - if (!p_routingTable) - p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); + if (!routingTable_) + routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); /* Add the loopback if needed */ - if (routing_platf->p_loopback && hierarchy_ == SURF_ROUTING_BASE) { + if (routing_platf->loopback_ && hierarchy_ == SURF_ROUTING_BASE) { for (i = 0; i < table_size; i++) { e_route = TO_ROUTE_FULL(i, i); if (!e_route) { e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1); e_route->gw_src = NULL; e_route->gw_dst = NULL; - e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); - xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback); + e_route->link_list = xbt_dynar_new(sizeof(Link*), NULL); + xbt_dynar_push(e_route->link_list, &routing_platf->loopback_); TO_ROUTE_FULL(i, i) = e_route; } } @@ -47,7 +47,7 @@ void AsFull::Seal() { } AsFull::~AsFull(){ - if (p_routingTable) { + if (routingTable_) { int table_size = (int)xbt_dynar_length(vertices_); int i, j; /* Delete routing table */ @@ -58,7 +58,7 @@ AsFull::~AsFull(){ xbt_free(TO_ROUTE_FULL(i,j)); } } - xbt_free(p_routingTable); + xbt_free(routingTable_); } } @@ -141,14 +141,14 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route) size_t table_size = xbt_dynar_length(vertices_); - if (!p_routingTable) - p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); + if (!routingTable_) + routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size); if (TO_ROUTE_FULL(src_net_elm->id(), dst_net_elm->id())) { char *link_name; unsigned int i; xbt_dynar_t link_route_to_test = - xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + xbt_dynar_new(sizeof(Link*), NULL); xbt_dynar_foreach(route->link_list, i, link_name) { void *link = Link::byName(link_name); xbt_assert(link, "Link : '%s' doesn't exists.", link_name); @@ -192,7 +192,7 @@ void AsFull::parseRoute(sg_platf_route_cbarg_t route) if (TO_ROUTE_FULL(dst_net_elm->id(), src_net_elm->id())) { char *link_name; unsigned int i; - xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + xbt_dynar_t link_route_to_test = xbt_dynar_new(sizeof(Link*), NULL); for (i = xbt_dynar_length(route->link_list); i > 0; i--) { link_name = xbt_dynar_get_as(route->link_list, i - 1, char *); void *link = Link::byName(link_name); diff --git a/src/surf/surf_routing_full.hpp b/src/surf/surf_routing_full.hpp index 91de4a4160..da84f718ea 100644 --- a/src/surf/surf_routing_full.hpp +++ b/src/surf/surf_routing_full.hpp @@ -31,7 +31,7 @@ public: xbt_dynar_t getOneLinkRoutes() override; void parseRoute(sg_platf_route_cbarg_t route) override; - sg_platf_route_cbarg_t *p_routingTable = nullptr; + sg_platf_route_cbarg_t *routingTable_ = nullptr; }; } diff --git a/src/surf/surf_routing_generic.cpp b/src/surf/surf_routing_generic.cpp index 11c4e7297f..142731f239 100644 --- a/src/surf/surf_routing_generic.cpp +++ b/src/surf/surf_routing_generic.cpp @@ -149,7 +149,7 @@ void AsGeneric::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) xbt_dynar_get_as(vertices_, dst, NetCard*); sg_platf_route_cbarg_t route = xbt_new0(s_sg_platf_route_cbarg_t, 1); - route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + route->link_list = xbt_dynar_new(sizeof(Link*), NULL); getRouteAndLatency(my_src, my_dst, route, NULL); @@ -320,7 +320,7 @@ sg_platf_route_cbarg_t AsGeneric::getBypassRoute(NetCard *src, new_e_route->gw_src = e_route_bypass->gw_src; new_e_route->gw_dst = e_route_bypass->gw_dst; new_e_route->link_list = - xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + xbt_dynar_new(sizeof(Link*), NULL); xbt_dynar_foreach(e_route_bypass->link_list, cpt, link) { xbt_dynar_push(new_e_route->link_list, &link); if (lat) @@ -342,7 +342,7 @@ sg_platf_route_cbarg_t AsGeneric::newExtendedRoute(e_surf_routing_hierarchy_t hi unsigned int cpt; result = xbt_new0(s_sg_platf_route_cbarg_t, 1); - result->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL); + result->link_list = xbt_dynar_new(sizeof(Link*), NULL); xbt_assert(hierarchy == SURF_ROUTING_BASE || hierarchy == SURF_ROUTING_RECURSIVE, -- 2.20.1