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
Factorized better debugging output.
[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
05c1f65
..
6dfc258
100644
(file)
--- a/
src/surf/gtnets/gtnets_topology.cc
+++ b/
src/surf/gtnets/gtnets_topology.cc
@@
-46,7
+46,10
@@
int GTNETS_Node::add_host(int hostid){
// return -1.
int GTNETS_Node::add_router(int routerid){
xbt_assert0(!(hosts_.size() > 1), "Router node should have only one router");
// return -1.
int GTNETS_Node::add_router(int routerid){
xbt_assert0(!(hosts_.size() > 1), "Router node should have only one router");
- xbt_assert1(((hosts_.size() == 1)&&(hosts_.find(routerid) != hosts_.end())), "Node %d is a different router", routerid);
+ if (hosts_.size() == 1){
+ xbt_assert1((hosts_.find(routerid) != hosts_.end()), "Node %d is a different router", routerid);
+ return 0;
+ }
is_router_ = true;
hosts_.insert(routerid);
return 0;
is_router_ = true;
hosts_.insert(routerid);
return 0;
@@
-64,7
+67,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);
+ DEBUG1("host id %d", *it);
}
}
}
}
@@
-92,15
+95,13
@@
GTNETS_Link::~GTNETS_Link(){
}
void GTNETS_Link::print_link_status(){
}
void GTNETS_Link::print_link_status(){
- DEBUG1("
link id: %d", ID_);
+ DEBUG1("
******
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();
+ DEBUG2("[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();
+ DEBUG2("[dst] id: %d, is it router?: %d",dst_node_->id(), dst_node_->is_router());
}
}
}
}
@@
-177,8
+178,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{
+ DEBUG1("Router (#%d) already exists", id);
+ }
return 0;
}
return 0;
}
@@
-208,23
+212,15
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
xbt_assert1(!(iter == links_.end()), "Link %d not found", linkid);
link = iter->second;
xbt_assert1(!(iter == links_.end()), "Link %d not found", linkid);
link = iter->second;
- DEBUG4("Add onehop route, src
: %d, dst: %d, linkid: %d, %d
",src, dst, linkid, link->id());
+ DEBUG4("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();
- }
-
- xbt_assert0((src_node && dst_node), "Either src or dst is null");
-
// 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;
@@
-260,6
+256,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_assert0((src_node && dst_node), "Either src or dst is null");
}
// case 1: link has two routers
}
// case 1: link has two routers
@@
-275,7
+273,7
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
// case 2: link has one router and one host
else if (src_node->is_router() && !dst_node->is_router()){
int newsrc, newdst;
// case 2: link has one router and one host
else if (src_node->is_router() && !dst_node->is_router()){
int newsrc, newdst;
- xbt_assert0( ((is_router(src))||(is_router(dst))), "
o
ne of nodes should be a router");
+ xbt_assert0( ((is_router(src))||(is_router(dst))), "
O
ne of nodes should be a router");
if (is_router(src)){
newsrc = src;
if (is_router(src)){
newsrc = src;
@@
-361,6
+359,7
@@
int GTNETS_Topology::add_onehop_route(int src, int dst, int linkid){
else{
xbt_assert0(0, "Shouldn't be here");
}
else{
xbt_assert0(0, "Shouldn't be here");
}
+
return 0;
}
return 0;
}