A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'hypervisor' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid into hypervisor
[simgrid.git]
/
src
/
surf
/
gtnets
/
gtnets_topology.cc
diff --git
a/src/surf/gtnets/gtnets_topology.cc
b/src/surf/gtnets/gtnets_topology.cc
index
7a21c64
..
d3f2f13
100644
(file)
--- a/
src/surf/gtnets/gtnets_topology.cc
+++ b/
src/surf/gtnets/gtnets_topology.cc
@@
-1,5
+1,3
@@
-/* $ID$ */
-
/* Copyright (c) 2007 Kayo Fujiwara. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
/* Copyright (c) 2007 Kayo Fujiwara. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
@@
-9,11
+7,12
@@
//Temporary classes for generating GTNetS topology
#include "gtnets_topology.h"
//Temporary classes for generating GTNetS topology
#include "gtnets_topology.h"
-#ifdef
DEBUG0
- #undef
DEBUG0
+#ifdef
XBT_DEBUG
+ #undef
XBT_DEBUG
#endif
#include "xbt/log.h"
#include "xbt/asserts.h"
#endif
#include "xbt/log.h"
#include "xbt/asserts.h"
+#include <stdio.h> //for fflush in print_topology
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets_topology, surf_network_gtnets,
"Logging specific to the SURF network GTNetS simulator");
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_network_gtnets_topology, surf_network_gtnets,
"Logging specific to the SURF network GTNetS simulator");
@@
-37,7
+36,7
@@
GTNETS_Node::~GTNETS_Node(){
// hostid = network_card_id
int GTNETS_Node::add_host(int hostid){
// hostid = network_card_id
int GTNETS_Node::add_host(int hostid){
- xbt_assert
0
(!(is_router_), "Cannot add a host to a router node");
+ xbt_assert(!(is_router_), "Cannot add a host to a router node");
hosts_.insert(hostid);
return 0;
}
hosts_.insert(hostid);
return 0;
}
@@
-45,9
+44,9
@@
int GTNETS_Node::add_host(int hostid){
// Add a router. If this node already has a router/host,
// return -1.
int GTNETS_Node::add_router(int routerid){
// Add a router. If this node already has a router/host,
// return -1.
int GTNETS_Node::add_router(int routerid){
- xbt_assert
0
(!(hosts_.size() > 1), "Router node should have only one router");
+ xbt_assert(!(hosts_.size() > 1), "Router node should have only one router");
if (hosts_.size() == 1){
if (hosts_.size() == 1){
- xbt_assert
1
((hosts_.find(routerid) != hosts_.end()), "Node %d is a different router", routerid);
+ xbt_assert((hosts_.find(routerid) != hosts_.end()), "Node %d is a different router", routerid);
return 0;
}
is_router_ = true;
return 0;
}
is_router_ = true;
@@
-67,7
+66,7
@@
bool GTNETS_Node::include(int hostid){
void GTNETS_Node::print_hosts(){
set<int>::iterator it;
for (it = hosts_.begin(); it != hosts_.end(); it++){
void GTNETS_Node::print_hosts(){
set<int>::iterator it;
for (it = hosts_.begin(); it != hosts_.end(); it++){
-
DEBUG1
("host id %d", *it);
+
XBT_DEBUG
("host id %d", *it);
}
}
}
}
@@
-95,15
+94,13
@@
GTNETS_Link::~GTNETS_Link(){
}
void GTNETS_Link::print_link_status(){
}
void GTNETS_Link::print_link_status(){
-
DEBUG1("
link id: %d", ID_);
+
XBT_DEBUG("******
link id: %d", ID_);
if (src_node_){
if (src_node_){
- DEBUG2("[src] id: %d, is it router?: %d, host list: ",src_node_->id(), src_node_->is_router());
- src_node_->print_hosts();
+ XBT_DEBUG("[src] id: %d, is it router?: %d",src_node_->id(), src_node_->is_router());
}
if (dst_node_){
}
if (dst_node_){
- DEBUG2("[dst] id: %d, is it router?: %d, host list: ",dst_node_->id(), dst_node_->is_router());
- dst_node_->print_hosts();
+ XBT_DEBUG("[dst] id: %d, is it router?: %d",dst_node_->id(), dst_node_->is_router());
}
}
}
}
@@
-122,7
+119,7
@@
bool GTNETS_Link::route_exists(){
// return the peer node id
int GTNETS_Link::peer_node(int cur_id){
// return the peer node id
int GTNETS_Link::peer_node(int cur_id){
- xbt_assert
0
(((cur_id == src_node_->id())||(cur_id == dst_node_->id())), "Node not found");
+ xbt_assert(((cur_id == src_node_->id())||(cur_id == dst_node_->id())), "Node not found");
if (cur_id == src_node_->id()) return dst_node_->id();
else if (cur_id == dst_node_->id()) return src_node_->id();
if (cur_id == src_node_->id()) return dst_node_->id();
else if (cur_id == dst_node_->id()) return src_node_->id();
@@
-169,7
+166,7
@@
int GTNETS_Topology::node_size(){
int GTNETS_Topology::add_link(int id){
map<int,GTNETS_Link*>::iterator iter = links_.find(id);
int GTNETS_Topology::add_link(int id){
map<int,GTNETS_Link*>::iterator iter = links_.find(id);
- xbt_assert
1
((iter == links_.end()), "Link %d already exists", id);
+ xbt_assert((iter == links_.end()), "Link %d already exists", id);
if(iter == links_.end()) {
GTNETS_Link* link= new GTNETS_Link(id);
if(iter == links_.end()) {
GTNETS_Link* link= new GTNETS_Link(id);
@@
-180,8
+177,11
@@
int GTNETS_Topology::add_link(int id){
int GTNETS_Topology::add_router(int id){
set<int>::iterator iter = routers_.find(id);
int GTNETS_Topology::add_router(int id){
set<int>::iterator iter = routers_.find(id);
- xbt_assert1((iter == routers_.end()), "Router %d already exists", id);
- routers_.insert(id);
+ if(iter == routers_.end()){
+ routers_.insert(id);
+ }else{
+ XBT_DEBUG("Router (#%d) already exists", id);
+ }
return 0;
}
return 0;
}
@@
-194,11
+194,11
@@
bool GTNETS_Topology::is_router(int id){
//return the node id of the peer of cur_id by linkid.
int GTNETS_Topology::peer_node_id(int linkid, int cur_id){
GTNETS_Link* link = links_[linkid];
//return the node id of the peer of cur_id by linkid.
int GTNETS_Topology::peer_node_id(int linkid, int cur_id){
GTNETS_Link* link = links_[linkid];
- xbt_assert
1
((link), "Link %d not found", linkid);
- xbt_assert
1
(!((cur_id < 0) || (cur_id > nodes_.size()-1)), "Node %d not found", cur_id);
+ xbt_assert((link), "Link %d not found", linkid);
+ xbt_assert(!((cur_id < 0) || (cur_id > nodes_.size()-1)), "Node %d not found", cur_id);
int peer = link->peer_node(nodes_[cur_id]->id());
int peer = link->peer_node(nodes_[cur_id]->id());
- xbt_assert
0
(!(peer < 0), "Peer not found");
+ xbt_assert(!(peer < 0), "Peer not found");
return peer;
}
return peer;
}
@@
-208,25
+208,18
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
map<int, GTNETS_Link*>::iterator iter = links_.find(linkid);
map<int, GTNETS_Link*>::iterator iter = links_.find(linkid);
- xbt_assert
1
(!(iter == links_.end()), "Link %d not found", linkid);
+ xbt_assert(!(iter == links_.end()), "Link %d not found", linkid);
link = iter->second;
link = iter->second;
-
DEBUG4("Add onehop route, src: %d, dst: %d, linkid: %d, %d
",src, dst, linkid, link->id());
+
XBT_DEBUG("Add onehop route, src (#%d), dst (#%d), linkid %d:(#%d)
",src, dst, linkid, link->id());
GTNETS_Node *src_node, *dst_node;
src_node = link->src_node();
dst_node = link->dst_node();
GTNETS_Node *src_node, *dst_node;
src_node = link->src_node();
dst_node = link->dst_node();
- if (XBT_LOG_ISENABLED(surf_network_gtnets_topology, xbt_log_priority_debug)) {
- link->print_link_status();
- src_node->print_hosts();
- dst_node->print_hosts();
- }
-
-
// If not exists a route, add one.
if (!link->route_exists()){
// If not exists a route, add one.
if (!link->route_exists()){
- //check whether there exists a node for the src
host/router
.
+ //check whether there exists a node for the src.
int s_node_id = nodeid_from_hostid(src);
int node_id;
int s_node_id = nodeid_from_hostid(src);
int node_id;
@@
-262,8
+255,8
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
nodes_[d_node_id]->add_host(dst);
link->add_dst(nodes_[d_node_id]);
nodes_[d_node_id]->add_host(dst);
link->add_dst(nodes_[d_node_id]);
- }else if (
src_node && dst_node
){
- xbt_assert
0
((src_node && dst_node), "Either src or dst is null");
+ }else if (
!(src_node && dst_node)
){
+ xbt_assert((src_node && dst_node), "Either src or dst is null");
}
// case 1: link has two routers
}
// case 1: link has two routers
@@
-272,14
+265,14
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
int tmpsrc2 = nodeid_from_hostid(src);
int tmpdst1 = dst_node->id();
int tmpdst2 = nodeid_from_hostid(dst);
int tmpsrc2 = nodeid_from_hostid(src);
int tmpdst1 = dst_node->id();
int tmpdst2 = nodeid_from_hostid(dst);
- xbt_assert
0
( (((tmpsrc1 == tmpsrc2) && (tmpdst1 == tmpdst2)) ||
+ xbt_assert( (((tmpsrc1 == tmpsrc2) && (tmpdst1 == tmpdst2)) ||
((tmpsrc1 == tmpdst2) && (tmpdst1 == tmpsrc2))), "Different one hop route defined");
}
// case 2: link has one router and one host
else if (src_node->is_router() && !dst_node->is_router()){
int newsrc, newdst;
((tmpsrc1 == tmpdst2) && (tmpdst1 == tmpsrc2))), "Different one hop route defined");
}
// case 2: link has one router and one host
else if (src_node->is_router() && !dst_node->is_router()){
int newsrc, newdst;
- xbt_assert
0
( ((is_router(src))||(is_router(dst))), "One of nodes should be a router");
+ xbt_assert( ((is_router(src))||(is_router(dst))), "One of nodes should be a router");
if (is_router(src)){
newsrc = src;
if (is_router(src)){
newsrc = src;
@@
-289,10
+282,10
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
newdst = src;
}
newdst = src;
}
- xbt_assert
0
(!(src_node->id() != nodeid_from_hostid(newsrc)), "The router should be identical");
+ xbt_assert(!(src_node->id() != nodeid_from_hostid(newsrc)), "The router should be identical");
//now, to add dst to dst_node, dst should be a host.
//now, to add dst to dst_node, dst should be a host.
- xbt_assert
1
(!(is_router(newdst)), "Dst %d is not an endpoint. cannot add it to dst_node", newdst);
+ xbt_assert(!(is_router(newdst)), "Dst %d is not an endpoint. cannot add it to dst_node", newdst);
if (!dst_node->include(newdst)){
dst_node->add_host(newdst);
if (!dst_node->include(newdst)){
dst_node->add_host(newdst);
@@
-301,7
+294,7
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
}
else if (!src_node->is_router() && dst_node->is_router()){
int newsrc, newdst;
}
else if (!src_node->is_router() && dst_node->is_router()){
int newsrc, newdst;
- xbt_assert
0
(((is_router(src))||(is_router(dst))), "One of nodes should be a router");
+ xbt_assert(((is_router(src))||(is_router(dst))), "One of nodes should be a router");
if (is_router(src)){
newsrc = dst;
if (is_router(src)){
newsrc = dst;
@@
-311,9
+304,9
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
newdst = dst;
}
newdst = dst;
}
- xbt_assert
0
(!(dst_node->id() != hosts_[newdst]), "The router should be identical");
+ xbt_assert(!(dst_node->id() != hosts_[newdst]), "The router should be identical");
//now, to add dst to src_node, dst should be a host.
//now, to add dst to src_node, dst should be a host.
- xbt_assert
1
(!(is_router(newsrc)), "Src %d is not an endpoint. cannot add it to src_node", newsrc);
+ xbt_assert(!(is_router(newsrc)), "Src %d is not an endpoint. cannot add it to src_node", newsrc);
if (!src_node->include(newsrc)){
src_node->add_host(newsrc);
if (!src_node->include(newsrc)){
src_node->add_host(newsrc);
@@
-323,7
+316,7
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
// case 3: link has two hosts
else if (!src_node->is_router() && !dst_node->is_router()){
// case 3: link has two hosts
else if (!src_node->is_router() && !dst_node->is_router()){
- xbt_assert
0
(!(is_router(src) || is_router(dst)), "Cannot add a router to host-host link");
+ xbt_assert(!(is_router(src) || is_router(dst)), "Cannot add a router to host-host link");
//if both are hosts, the order doesn't matter.
if (src_node->include(src)){
//if both are hosts, the order doesn't matter.
if (src_node->include(src)){
@@
-363,8
+356,9
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
}
else{
}
else{
- xbt_
assert0(0,
"Shouldn't be here");
+ xbt_
die(
"Shouldn't be here");
}
}
+
return 0;
}
return 0;
}
@@
-376,13
+370,13
@@
int GTNETS_Topology::nodeid_from_hostid(int hostid){
}
void GTNETS_Topology::print_topology(){
}
void GTNETS_Topology::print_topology(){
-
DEBUG0
("<<<<<================================>>>>>");
-
DEBUG0
("Dumping GTNETS topollogy information");
+
XBT_DEBUG
("<<<<<================================>>>>>");
+
XBT_DEBUG
("Dumping GTNETS topollogy information");
map<int, GTNETS_Link*>::iterator it;
for (it = links_.begin(); it != links_.end(); it++){
it->second->print_link_status();
}
map<int, GTNETS_Link*>::iterator it;
for (it = links_.begin(); it != links_.end(); it++){
it->second->print_link_status();
}
-
DEBUG0
(">>>>>================================<<<<<");
+
XBT_DEBUG
(">>>>>================================<<<<<");
fflush(NULL);
}
fflush(NULL);
}