Commit 227346c3 authored by Robert Ricci's avatar Robert Ricci
Browse files

A few fixes for 'loopback' links in the virtual topology (links that

connect a vnode to itself):

Move up the point at which we consider a vnode to be assigned - we
want to do this before we look for link resolutions, or the 'other
end' of a loopback link appears to be unassigned, which is not true.

Add a mecahism to watch out for scoring lookpback links twice. The
edge iterator for an undirected graph sees each vlink twice (there
are two 'out' edges from the vnode). So, we have to avoid scoring it
the second time.

Note that we still only allow loopback links if they are 'trivial_ok'.
parent fb546411
......@@ -402,13 +402,20 @@ void remove_node(vvertex vv)
}
}
/*
* Score the fact that we now have one more unassigned vnode
*/
vnode->assigned = false;
SADD(SCORE_UNASSIGNED);
vinfo.unassigned++;
violated++;
/*
* Now, take care of the virtual links that are attached to the vnode
*/
voedge_iterator vedge_it,end_vedge_it;
tie(vedge_it,end_vedge_it) = out_edges(vv,VG);
hash_set<void*> seen_loopback_links;
for (;vedge_it!=end_vedge_it;++vedge_it) {
tb_vlink *vlink = get(vedge_pmap,*vedge_it);
......@@ -420,6 +427,17 @@ void remove_node(vvertex vv)
tb_vnode *dest_vnode = get(vvertex_pmap,dest_vv);
SDEBUG(cerr << " edge to " << dest_vnode->name << endl);
if (dest_vv == vv) {
// We have to be careful with 'loopback' links, because we can see them
// twice - bail out if this is the second time
if (seen_loopback_links.find(vlink) != seen_loopback_links.end()) {
SDEBUG(cerr << " seen before - skipping" << endl);
continue;
} else {
seen_loopback_links.insert(vlink);
}
}
// A 'not-connected' vlink only counts as a violation if both of its
// endpoints are assigned
if (vlink->no_connection) {
......@@ -459,7 +477,7 @@ void remove_node(vvertex vv)
SSUB(SCORE_PNODE * (powf(1+ ((pnode->current_load+1) * 1.0)/pnode->max_load,2)));
SADD(SCORE_PNODE * (powf(1+ pnode->current_load * 1.0/pnode->max_load,2)));
#endif
pnode->remove_current_type();
if (pnode->total_load == 0) {
// If the pnode is now free, we need to do some cleanup
SDEBUG(cerr << " releasing pnode" << endl);
......@@ -476,14 +494,6 @@ void remove_node(vvertex vv)
violated--;
}
/*
* Score the fact that we now have one more unassigned vnode
*/
vnode->assigned = false;
SADD(SCORE_UNASSIGNED);
vinfo.unassigned++;
violated++;
/*
* Scoring for features and desires
*/
......@@ -752,6 +762,13 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
#ifdef SMART_UNMAP
pnode->assigned_nodes.insert(vnode);
#endif
/*
* Record the node's assignment. Need to do this now so that 'loopback' links
* work below.
*/
vnode->assignment = pv;
vnode->assigned = true;
/*
* Assign any links on the vnode that can now be assigned (due to the other
......@@ -759,6 +776,7 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
*/
voedge_iterator vedge_it,end_vedge_it;
tie(vedge_it,end_vedge_it) = out_edges(vv,VG);
hash_set<void*> seen_loopback_links;
for (;vedge_it!=end_vedge_it;++vedge_it) {
tb_vlink *vlink = get(vedge_pmap,*vedge_it);
vvertex dest_vv = target(*vedge_it,VG);
......@@ -789,6 +807,14 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
if (dest_pv == pv) {
SDEBUG(cerr << " trivial link" << endl);
// We have to be careful with 'loopback' links, because we can see them
// twice - bail out if this is the second time
if (seen_loopback_links.find(vlink) != seen_loopback_links.end()) {
SDEBUG(cerr << " seen before - skipping" << endl);
continue;
} else {
seen_loopback_links.insert(vlink);
}
if (allow_trivial_links && vlink->allow_trivial) {
vlink->link_info.type = tb_link_info::LINK_TRIVIAL;
// XXX - okay, this is really bad, but score_link_info doesn't
......@@ -1046,8 +1072,6 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
SADD((pnode->total_interfaces - pnode->used_interfaces) * SCORE_UNUSED_INTERFACE);
#endif
vnode->assignment = pv;
vnode->assigned = true;
if (tr->current_load > tr->max_load) {
SDEBUG(cerr << " load too high - penalty (" <<
pnode->current_type_record->current_load << ")" << endl);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment