Commit 821107fc authored by Robert Ricci's avatar Robert Ricci
Browse files

A lot of bugfixes relating, primarily, to multiplexed nodes:

Split the function that determines if a vnode can be mapped to a given pnode
out of find_pnode, so that I can spread it out and make it more comprehensible.
In doing so, fixed a bug in which static types were not getting handled
correctly - a static type would only be found if no vnodes with dynamic types
were allocated to the pnode.

Fixed a bug in which, on allocation of a dynamic ptype, nodes where being
removed from their static type lists in the type_table.

Fixed a bug when there is a combination of fixed and un-fixed vnodes in the top
file.

I have more on the way, but this seemed like a good checkpoint.
parent 828b56fc
...@@ -48,6 +48,64 @@ inline int accept(double change, double temperature) ...@@ -48,6 +48,64 @@ inline int accept(double change, double temperature)
return 0; return 0;
} }
/*
* This overly-verbose function returns true if it's okay to map vn to pn,
* false otherwise
*/
bool pnode_is_match(tb_vnode *vn, tb_pnode *pn) {
// Find the type record for this type
tb_pnode::types_map::iterator mit = pn->types.find(vn->type);
if (mit == pn->types.end()) {
// The node doesn't even have this type, we can exit early
return false;
}
bool matched = false;
tb_pnode::type_record *tr = mit->second;
if (tr->is_static) {
if (tr->current_load >= tr->current_load) {
// It's at or over its max load
if (allow_overload) {
// That's okay, we're allowing overload
matched = true;
} else {
// Nope, it's full
matched = false;
}
} else {
// Plenty of room for us
matched = true;
}
} else { // the type is not static
if (pn->typed) {
if (pn->current_type.compare(vn->type)) {
// Failure - the pnode has a type, and it isn't ours
matched = false;
} else {
if (pn->current_type_record->current_load >=
pn->current_type_record->max_load) {
// It's at or over its max load
if (allow_overload) {
// That's okay, we're allowing overload
matched = true;
} else {
// Failure - the type is right, but the pnode is full
matched = false;
}
} else {
// It's under its max load, we can fit in
matched = true;
}
}
} else {
// pnode doesn't have a type
matched = true;
}
}
return matched;
}
tb_pnode *find_pnode(tb_vnode *vn) tb_pnode *find_pnode(tb_vnode *vn)
{ {
#ifdef PER_VNODE_TT #ifdef PER_VNODE_TT
...@@ -110,6 +168,7 @@ REDO_SEARCH: ...@@ -110,6 +168,7 @@ REDO_SEARCH:
continue; continue;
} }
#endif #endif
list<tb_pnode*>::iterator it = (*acceptable_types)[i]->members[vn->type]->L.begin(); list<tb_pnode*>::iterator it = (*acceptable_types)[i]->members[vn->type]->L.begin();
#ifdef LOAD_BALANCE #ifdef LOAD_BALANCE
int skip = std::rand() % (*acceptable_types)[i]->members[vn->type]->L.size(); int skip = std::rand() % (*acceptable_types)[i]->members[vn->type]->L.size();
...@@ -141,13 +200,10 @@ REDO_SEARCH: ...@@ -141,13 +200,10 @@ REDO_SEARCH:
break; break;
} }
#else // LOAD_BALANCE #else // LOAD_BALANCE
if ((*it)->typed && ((*it)->current_type.compare(vn->type) || if (pnode_is_match(vn,*it)) {
(!allow_overload && break;
((*it)->current_type_record->current_load >=
(*it)->current_type_record->max_load)))) {
it++;
} else { } else {
break; it++;
} }
#endif // LOAD_BALANCE #endif // LOAD_BALANCE
} }
...@@ -269,9 +325,8 @@ void anneal(bool scoring_selftest, double scale_neighborhood) ...@@ -269,9 +325,8 @@ void anneal(bool scoring_selftest, double scale_neighborhood)
// Subtract the number of fixed nodes from nnodes, since they don't really // Subtract the number of fixed nodes from nnodes, since they don't really
// count // count
if (num_fixed) { if (num_fixed) {
nnodes -= num_fixed;
cout << "Adjusting dificulty estimate for fixed nodes, " << cout << "Adjusting dificulty estimate for fixed nodes, " <<
nnodes << " remain.\n"; (nnodes - num_fixed) << " remain.\n";
} }
/* We'll check against this later to make sure that whe we've unmapped /* We'll check against this later to make sure that whe we've unmapped
...@@ -304,7 +359,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood) ...@@ -304,7 +359,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood)
} }
int neighborsize; int neighborsize;
neighborsize = nnodes * npclasses; neighborsize = (nnodes - num_fixed) * npclasses;
if (neighborsize < min_neighborhood_size) { if (neighborsize < min_neighborhood_size) {
neighborsize = min_neighborhood_size; neighborsize = min_neighborhood_size;
} }
...@@ -317,7 +372,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood) ...@@ -317,7 +372,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood)
double scores[neighborsize]; double scores[neighborsize];
#endif #endif
if (nnodes <= 0) { if (num_fixed >= nnodes) {
cout << "All nodes are fixed. No annealing." << endl; cout << "All nodes are fixed. No annealing." << endl;
goto DONE; goto DONE;
} }
...@@ -433,7 +488,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood) ...@@ -433,7 +488,7 @@ void anneal(bool scoring_selftest, double scale_neighborhood)
if (choice >= 0) { if (choice >= 0) {
vv = virtual_nodes[choice]; vv = virtual_nodes[choice];
} else { } else {
cout << "All nodes are fixed or LANs. No annealing." << endl; cerr << "**** Error, unable to find any non-fixed nodes" << endl;
goto DONE; goto DONE;
} }
} }
......
...@@ -306,8 +306,11 @@ int pclass_set(tb_vnode *v,tb_pnode *p) ...@@ -306,8 +306,11 @@ int pclass_set(tb_vnode *v,tb_pnode *p)
} }
} }
} else { } else {
// If it's not in the list then this fails quietly. // XXX - should be made faster
(*dit).second->remove(p); if (!p->types[dit->first]->is_static) {
// If it's not in the list then this fails quietly.
(*dit).second->remove(p);
}
} }
#ifdef SMART_UNMAP #ifdef SMART_UNMAP
if (c->used_members.find((*dit).first) == c->used_members.end()) { if (c->used_members.find((*dit).first) == c->used_members.end()) {
......
Markdown is supported
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