Commit 62838bae authored by Robert Ricci's avatar Robert Ricci

Beef up the type preecheck - actually count the number of 'slots' of each ptype

available, and check that against the types of the vnodes in the top file. This
way, we can bail early with a comprehensible error message if, say, there are
not enough pc850s free!

This fixes the following item from the todo list:
13.  add type-count checks
parent daa2534b
......@@ -7,7 +7,6 @@
#include "port.h"
#include <hash_map>
#include <slist>
#include <rope>
#include <queue>
......@@ -38,6 +37,11 @@ using namespace boost;
#include "pclass.h"
#include "score.h"
/*
* 'optimal' score - computes a lower bound on the optimal score for this
* mapping, so that if we find this score, we know we're done and can exit
* early.
*/
#ifdef USE_OPTIMAL
#define OPTIMAL_SCORE(edges,nodes) (nodes*SCORE_PNODE + \
nodes/opt_nodes_per_sw*SCORE_SWITCH + \
......@@ -89,7 +93,7 @@ tb_vgraph_edge_pmap vedge_pmap = get(edge_data, VG);
name_pvertex_map pname2vertex;
// A simple list of physical types.
name_slist ptypes;
name_count_map ptypes;
// Map of virtual node name to its vertex descriptor.
name_vvertex_map vname2vertex;
......@@ -104,7 +108,7 @@ vvertex_vector virtual_nodes;
name_name_map fixed_nodes;
// List of virtual types by name.
name_slist vtypes;
name_count_map vtypes;
// Priority queue of unassigned virtual nodes. Basically a fancy way
// of randomly choosing a unassigned virtual node. When nodes become
......@@ -1366,7 +1370,7 @@ void print_solution()
} else if (vlink->link_info.type == tb_link_info::LINK_TRIVIAL) {
cout << " trivial" << endl;
} else {
cout << " Unknown link type" << endl;
cout << " Mapping Failed" << endl;
}
}
cout << "End Edges" << endl;
......@@ -1624,19 +1628,36 @@ int main(int argc,char **argv)
read_virtual_topology(argv[1]);
cout << "Type preecheck." << endl;
ptypes.push_front("lan");
cout << "Type preecheck:" << endl;
// Type precheck
bool ok=true;
for (name_slist::iterator it=vtypes.begin();
it != vtypes.end();++it) {
if (find(ptypes.begin(),ptypes.end(),*it) == ptypes.end()) {
cout << " No physical nodes of type " << *it << endl;
ok=false;
for (name_count_map::iterator vtype_it=vtypes.begin();
vtype_it != vtypes.end();++vtype_it) {
// Ignore LAN vnodes
if (vtype_it->first == crope("lan")) {
continue;
}
// Check to see if there were any pnodes of the type at all
name_count_map::iterator ptype_it = ptypes.find(vtype_it->first);
if (ptype_it == ptypes.end()) {
cout << " *** No physical nodes of type " << vtype_it->first << " found"
<< endl;
ok = false;
} else {
// Okay, there are some - are there enough?
if (ptype_it->second < vtype_it->second) {
cout << " *** " << vtype_it->second << " nodes of type " <<
vtype_it->first << " requested, but only " << ptype_it->second <<
" found" << endl;
ok = false;
}
}
}
if (! ok) exit(-1);
cout << "Type preecheck passed." << endl;
#ifdef PER_VNODE_TT
vvertex_iterator vit,vendit;
......
......@@ -119,9 +119,4 @@ This is the current TODO list for assign (not in order by priority):
up a mapping for an unassignable vnode. Doesn't seem to hurt anything, so is
low priority
13. add type-count checks
A common swapin failure comes become there are not, for example, enough
pc600s. Should be easy to count up the total number of slots for each time,
and the required slots, and exit with a good error message if it's not going
to be mappable, based on this type information.
(next free #:14)
......@@ -142,6 +142,11 @@ namespace boost {
typedef hash_map<crope,crope> name_name_map;
typedef slist<crope> name_slist;
/*
* Used to count the number of nodes in each ptype and vtype
*/
typedef hash_map<crope,int> name_count_map;
template <class T> struct hashptr {
size_t operator()(T const &A) const {
return (size_t) A;
......
......@@ -30,7 +30,7 @@ using namespace boost;
#include "parser.h"
extern name_pvertex_map pname2vertex;
extern name_slist ptypes;
extern name_count_map ptypes;
#define ptop_error(s) errors++;cerr << "PTOP:" << line << ": " << s << endl
......@@ -81,7 +81,11 @@ int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
ptop_error("Bad node line, bad load: " << load << ".");
iload = 1;
}
ptypes.push_front(type);
if (ptypes.find(type) == ptypes.end()) {
ptypes[type] = iload;
} else {
ptypes[type] += iload;
}
if (type.compare("switch") == 0) {
isswitch = true;
p->types["switch"] = 1;
......
......@@ -30,7 +30,7 @@ using namespace boost;
extern name_vvertex_map vname2vertex;
extern name_name_map fixed_nodes;
extern name_slist vtypes;
extern name_count_map vtypes;
extern vvertex_vector virtual_nodes;
#define top_error(s) errors++;cerr << "TOP:" << line << ": " << s << endl
......@@ -71,7 +71,11 @@ int parse_top(tb_vgraph &VG, istream& i)
} else {
v->type=type;
v->vclass=NULL;
vtypes.push_front(v->type);
if (vtypes.find(v->type) == vtypes.end()) {
vtypes[v->type] = 1;
} else {
vtypes[v->type]++;
}
}
v->fixed = false; // this may get set to true later
#ifdef PER_VNODE_TT
......@@ -224,7 +228,10 @@ int parse_top(tb_vgraph &VG, istream& i)
vclass_map[name] = v;
for (unsigned int i = 3;i<parsed_line.size();++i) {
v->add_type(parsed_line[i]);
vtypes.push_front(parsed_line[i]);
// XXX - in order not to break vtypes, we don't put them in the
// vtypes map (otherwise, the type precheck would complain, but the
// top may still be mappable).
//vtypes.push_front(parsed_line[i]);
}
}
} else if (command.compare("fix-node") == 0) {
......
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