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,
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<simgrid::surf::NetworkNS3Link *>(onelink->p_link);
+ static_cast<simgrid::surf::NetworkNS3Link *>(onelink->link_);
if (strcmp(src,dst) && link->m_created){
XBT_DEBUG("Route from '%s' to '%s' with link '%s'", src, dst, link->getName());
static_cast<AsCluster*>(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;
}
info_loop.link_down = info_loop.link_up;
free(tmp_link);
xbt_dynar_set(current_routing->upDownLinks,
- rankId*(static_cast<AsCluster*>(current_routing))->p_nb_links_per_node, &info_loop);
+ rankId*(static_cast<AsCluster*>(current_routing))->nb_links_per_node_, &info_loop);
}
//add a limiter link (shared link to account for maximal bandwidth of the node)
free(tmp_link);
auto as_cluster = static_cast<AsCluster*>(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);
}
}
else {
static_cast<AsCluster*>(current_routing)->create_links_for_node(cluster, i, rankId, rankId*
- static_cast<AsCluster*>(current_routing)->p_nb_links_per_node
- + static_cast<AsCluster*>(current_routing)->p_has_loopback
- + static_cast<AsCluster*>(current_routing)->p_has_limiter );
+ static_cast<AsCluster*>(current_routing)->nb_links_per_node_
+ + static_cast<AsCluster*>(current_routing)->has_loopback_
+ + static_cast<AsCluster*>(current_routing)->has_limiter_ );
}
xbt_free(link_id);
xbt_free(host_id);
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
/* 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);
/* 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_;
}
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){
{
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);
}
xbt_dynar_t RoutingPlatf::getOneLinkRoutes(){
- return recursiveGetOneLinkRoutes(p_root);
+ return recursiveGetOneLinkRoutes(root_);
}
xbt_dynar_t RoutingPlatf::recursiveGetOneLinkRoutes(As *rc)
simgrid::surf::AsCluster *cluster = dynamic_cast<simgrid::surf::AsCluster*>(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_);
}
router.id = router_id;
router.coord = peer->coord;
sg_platf_new_router(&router);
- static_cast<AsCluster*>(current_routing)->p_router = static_cast<NetCard*>(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL));
+ static_cast<AsCluster*>(current_routing)->router_ = static_cast<NetCard*>(xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL));
XBT_DEBUG("</AS>");
sg_platf_new_AS_end();
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) {
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;
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
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);
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<Link*>(info.link_up)->getLatency();
}
- 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)
}
- if (p_backbone) {
+ if (backbone_) {
xbt_dynar_push_as(route->link_list, void *,
- static_cast<simgrid::surf::Resource*>(p_backbone));
+ static_cast<simgrid::surf::Resource*>(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<Link*>(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);
}
}
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);
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);
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);
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;
};
}
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];
}
}
}
}
- 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;
}
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());
}
/* 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();
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);
*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;
// 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,
* addNodes() have already been called
*/
void AsClusterFatTree::create_links(){
- if(this->levels == 0) {
+ if(this->levels_ == 0) {
return;
}
this->generateSwitches();
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());
}
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++;
}
}
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());
}
}
int AsClusterFatTree::connectNodeToParents(FatTreeNode *node) {
- std::vector<FatTreeNode*>::iterator currentParentNode = this->nodes.begin();
+ std::vector<FatTreeNode*>::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++;
}
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 << ">";
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;
}
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);
}
}
}
void AsClusterFatTree::generateLabels() {
XBT_DEBUG("Generating labels.");
// TODO : check if nodesByLevel and nodes are filled
- std::vector<int> maxLabel(this->levels);
- std::vector<int> currentLabel(this->levels);
+ std::vector<int> maxLabel(this->levels_);
+ std::vector<int> 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;
++pos;
}
}
- while(remainder && pos < this->levels);
+ while(remainder && pos < this->levels_);
k++;
}
}
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;
}
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);
}
// 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;
}
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 {
}
}
- 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 << "}";
private:
//description of a PGFT (TODO : better doc)
- unsigned int levels = 0;
- std::vector<unsigned int> lowerLevelNodesNumber; // number of children by node
- std::vector<unsigned int> upperLevelNodesNumber; // number of parents by node
- std::vector<unsigned int> lowerLevelPortsNumber; // ports between each level l and l-1
+ unsigned int levels_ = 0;
+ std::vector<unsigned int> lowerLevelNodesNumber_; // number of children by node
+ std::vector<unsigned int> upperLevelNodesNumber_; // number of parents by node
+ std::vector<unsigned int> lowerLevelPortsNumber_; // ports between each level l and l-1
- std::map<int, FatTreeNode*> computeNodes;
- std::vector<FatTreeNode*> nodes;
- std::vector<FatTreeLink*> links;
- std::vector<unsigned int> nodesByLevel;
+ std::map<int, FatTreeNode*> computeNodes_;
+ std::vector<FatTreeNode*> nodes_;
+ std::vector<FatTreeLink*> links_;
+ std::vector<unsigned int> 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);
: 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) {
// 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;
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"
*/
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);
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)
* 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
* 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) {
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
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);
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);
}
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;
};
}}
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;
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;
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;
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));
}
/* 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;
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);
}
}
}
{
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;
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);
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());
}
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 */
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());
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 */
: 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)
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);
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());
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 */
};
}
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 {
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 */
{
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;
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*>(link)->getLatency();
}
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++)
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);
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);
/* 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++)
}
/* 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;
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_;
};
}
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 {
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;
}
}
}
AsFull::~AsFull(){
- if (p_routingTable) {
+ if (routingTable_) {
int table_size = (int)xbt_dynar_length(vertices_);
int i, j;
/* Delete routing table */
xbt_free(TO_ROUTE_FULL(i,j));
}
}
- xbt_free(p_routingTable);
+ xbt_free(routingTable_);
}
}
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);
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);
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;
};
}
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);
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)
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,