Commit 13c6d59f authored by Robert Ricci's avatar Robert Ricci

Add the ability to have vritual nodes that consume more than one

'slot'. In the top file, you can how give' the virtual node's type as
type:count - sim:5, for example. If you give no count, it defaults to
one.

The idea here is to allow a pre-pass to assign to 'coarsen' the
virtual graph. This pre-pass could, for example, combine several
virtual or simulated nodes into one so that assign has a simpler
virtual graph to work with.
parent aad59ea6
......@@ -63,8 +63,8 @@ inline bool pnode_is_match(tb_vnode *vn, tb_pnode *pn) {
bool matched = false;
tb_pnode::type_record *tr = mit->second;
if (tr->is_static) {
if (tr->current_load >= tr->max_load) {
// It's at or over its max load
if ((tr->current_load + vn->typecount) > tr->max_load) {
// This would put us over its max load
if (allow_overload) {
// That's okay, we're allowing overload
matched = true;
......@@ -82,9 +82,9 @@ inline bool pnode_is_match(tb_vnode *vn, tb_pnode *pn) {
// Failure - the pnode has a type, and it isn't ours
matched = false;
} else {
if (pn->current_type_record->current_load >=
if ((pn->current_type_record->current_load + vn->typecount) >
pn->current_type_record->max_load) {
// It's at or over its max load
// This would put us over its max load
if (allow_overload) {
// That's okay, we're allowing overload
matched = true;
......
......@@ -454,6 +454,18 @@ int mapping_precheck() {
potential_match = false;
}
// Check to see if if the pnode has enough slots of the
// appropriate type available
tb_pnode::types_map::iterator mit = pnode->types.find(v->type);
if (mit == pnode->types.end()) {
// Must have been a vtype to get here - ignore it
} else {
if (v->typecount > mit->second->max_load) {
// Nope, this vnode is too demanding
potential_match = false;
}
}
//
// Check features and desires
//
......
......@@ -86,7 +86,19 @@ int parse_top(tb_vgraph &VG, istream& i)
top_error("Bad node line, too few arguments.");
} else {
crope name = parsed_line[1];
crope type = parsed_line[2];
crope unparsed_type = parsed_line[2];
// Type might now a have a 'number of slots' assoicated with it
crope type;
crope typecount_str;
split_two(unparsed_type,':',type,typecount_str,"1");
int typecount;
if (sscanf(typecount_str.c_str(),"%i",&typecount) != 1) {
top_error("Bad type slot count.");
typecount = 1;
}
num_nodes++;
tb_vnode *v = new tb_vnode();
vvertex vv = add_vertex(VG);
......@@ -107,6 +119,7 @@ int parse_top(tb_vgraph &VG, istream& i)
vtypes[v->type]++;
}
}
v->typecount = typecount;
#ifdef PER_VNODE_TT
v->num_links = 0;
v->total_bandwidth = 0;
......
......@@ -91,6 +91,9 @@ void score_link_endpoints(pedge pe);
#define SDEBUG(a)
#endif
#define MIN(a,b) (((a) < (b))? (a) : (b))
#define MAX(a,b) (((a) > (b))? (a) : (b))
/*
* For features and desires that have a some sort of global impact
*/
......@@ -473,8 +476,9 @@ void remove_node(vvertex vv)
/*
* Adjust scores for the pnode
*/
tr->current_load--;
pnode->total_load--;
int old_load = tr->current_load;
tr->current_load -= vnode->typecount;
pnode->total_load -= vnode->typecount;
#ifdef LOAD_BALANCE
// Use this tricky formula to score based on how 'full' the pnode is, so that
// we prefer to equally fill the minimum number of pnodes
......@@ -487,15 +491,17 @@ void remove_node(vvertex vv)
SDEBUG(cerr << " releasing pnode" << endl);
SSUB(SCORE_PNODE);
pnode->remove_current_type();
} else if (tr->current_load >= tr->max_load) {
// If the pnode is still over its max load, reduce the penalty to adjust
// for the new load.
SDEBUG(cerr << " reducing penalty, new load=" <<
pnode->current_type_record->current_load <<
" (>= " << pnode->current_type_record->max_load << ")" << endl);
SSUB(SCORE_PNODE_PENALTY);
vinfo.pnode_load--;
violated--;
} else if (old_load > tr->max_load) {
// If the pnode was over its load, remove the penalties for the nodes we
// just removed, down to the max_load.
SDEBUG(cerr << " reducing penalty, old load was " << old_load <<
", new load = " << tr->current_load << ", max load = " <<
tr->max_load << endl);
for (int i = old_load; i > MAX(tr->current_load,tr->max_load); i--) {
SSUB(SCORE_PNODE_PENALTY);
vinfo.pnode_load--;
violated--;
}
}
/*
......@@ -1069,9 +1075,12 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
}
}
int old_load = tr->current_load;
int old_total_load = pnode->total_load;
// finish setting up pnode
tr->current_load++;
pnode->total_load++;
tr->current_load += vnode->typecount;
pnode->total_load += vnode->typecount;
#ifdef PENALIZE_UNUSED_INTERFACES
assert(pnode->used_interfaces <= pnode->total_interfaces);
......@@ -1081,13 +1090,15 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
if (tr->current_load > tr->max_load) {
SDEBUG(cerr << " load too high - penalty (" <<
pnode->current_type_record->current_load << ")" << endl);
SADD(SCORE_PNODE_PENALTY);
vinfo.pnode_load++;
violated++;
for (int i = MAX(old_load,tr->max_load); i < tr->current_load; i++) {
SADD(SCORE_PNODE_PENALTY);
vinfo.pnode_load++;
violated++;
}
} else {
SDEBUG(cerr << " load is fine" << endl);
}
if (pnode->total_load == 1) {
if (old_total_load == 0) {
SDEBUG(cerr << " new pnode" << endl);
SADD(SCORE_PNODE);
}
......
......@@ -67,12 +67,12 @@ public:
class tb_vnode {
public:
tb_vnode(): vclass(NULL), fixed(false), assigned(false), subnode_of(NULL),
subnode_of_name("") {;}
subnode_of_name(""), typecount(1) {;}
friend ostream &operator<<(ostream &o, const tb_vnode& node)
{
o << "tb_vnode: " << node.name << " (" << &node << ")" << endl;
o << " Type: " << node.type << endl;
o << " Type: " << node.type << " Count: " << node.typecount << endl;
o << " Desires:" << endl;
for (desires_map::const_iterator it = node.desires.begin();
it!=node.desires.end();it++)
......@@ -89,6 +89,7 @@ public:
desires_map desires;
crope type; // the current type of the node
int typecount; // How many slots of the type this vnode takes up
tb_vclass *vclass; // the virtual class of the node, if any
crope name; // string name of the node
bool fixed; // is this node fixed
......
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