Commit 210aa1ec authored by Christopher Alfeld's avatar Christopher Alfeld

This commit contains two signifcant changes:

1. 'tb-set-hardware ... shark' and 'tb-set-hardware ... dnard' are now
functionally identical.  Previously only the former worked but both passed
the parser.

2. Assign will now exit very quickly in the case that, for a given virtual
nodes, there are no physical nodes that could match in type.  This should
never happen as the parser and assign_wrapper have checks that usually
prevent this.  However, in the case of problems in the code (such as #1)
this'll make it easier to debug.  In addition, as we add more types of
nodes and our estimates becoming increasingly inaccurate cases where this
might occur could slip in.  All calling code treats this identically to an
'insufficient resources' failure.
parent 4303838f
......@@ -75,8 +75,14 @@ mapping is made any unused features add their cost to the score and
any unfulfilled desires add their weight to the score. Fulfilled
desires/used features add nothing to the score.
environmental variables
-----------------------
compile type options
ASSIGN_SEED - If present will cause assign to use the value as its
random number seed. Otherwise the seed is taken from the current
time.
compile time options
--------------------
-DVERBOSE adds temperature output and functions as a crude progress meter.
......
......@@ -72,6 +72,18 @@ node_pq<int> unassigned_nodes(G);
int parse_top(tb_vgraph &G, istream& i);
int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i);
/* The following two sets hold all the virtual and physical types. These
* are compared to make sure that every member of vtypes is in ptypes.
* Both are filled by the parse_* routines. I'd love to use LEDA sets
* to implement this but LEDA, an otherwise profession work, did a lousy
* job when it came to sets. They clash with graph iterators! Since
* we only use these once we'll use a much less efficient linked list
* <shudder>
*/
list<string> vtypes;
list<string> ptypes;
/*
* Basic simulated annealing parameters:
*
......@@ -510,6 +522,18 @@ int main(int argc, char **argv)
}
nparts = parse_ptop(PG,SG,ptopfile);
cout << "Nparts: " << nparts << endl;
cout << "Type Precheck" << endl;
string curtype;
int ok=1;
forall (curtype,vtypes) {
if (ptypes.search(curtype) == nil) {
cout << " No physical nodes of type " << curtype << endl;
ok=0;
}
}
if (! ok) exit(-1);
cout << "Initializing data structures." << endl;
edge_costs.init(SG);
switch_distances.init(SG);
......
......@@ -26,6 +26,7 @@
extern node pnodes[MAX_PNODES]; // int -> node map
node_array<int> switch_index;
extern list<string> ptypes;
int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
{
......@@ -86,6 +87,7 @@ int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
} else {
iload=1;
}
ptypes.push(stype);
if (strcmp(t,"switch") == 0) {
isswitch = 1;
PG[no1].types.insert(stype,1);
......
......@@ -17,6 +17,7 @@
#include "common.h"
#include "virtual.h"
extern list<string> vtypes;
extern tb_vgraph G;
extern node_pq<int> unassigned_nodes;
......@@ -60,6 +61,8 @@ int parse_top(tb_vgraph &G, istream& i)
nmap.insert(s1, no1);
scur=strsep(&snext," ");
G[no1].type=string(scur);
vtypes.push(G[no1].type);
/* Read in desires */
while ((scur=strsep(&snext," ")) != NULL) {
char *desire = scur;
......
......@@ -347,6 +347,9 @@ int add_node(node n,int ploc)
fprintf(stderr," comaptible types\n");
#endif
if (pnoder.current_load == pnoder.max_load) {
/* XXX - We could ignore this check and let the code
at the end of the routine penalize for going over
load. Failing here seems to work better though. */
#ifdef SCORE_DEBUG
fprintf(stderr," node is full\n");
#endif
......
......@@ -170,7 +170,7 @@ foreach $lan (keys(%lans)) {
$hassharks = 0;
foreach $member (@{$lans{$lan}}) {
($node) = (split(":",$member))[0];
if ($nodes{$node} eq "shark") {
if (($nodes{$node} eq "shark") || ($nodes{$node} eq "dnard")) {
push(@$sharks,$member);
$hassharks = 1;
} else {
......@@ -226,7 +226,7 @@ $delaynodes=0;
foreach $node (keys(%nodes)) {
# Shark hack
if ($nodes{$node} ne "shark") {
if (($nodes{$node} ne "shark") && ($nodes{$node} ne "dnard")) {
print TOPFILE "node $node $nodes{$node}\n";
if ($nodes{$node} ne "shark-shelf") {
$nodes++;
......@@ -402,12 +402,21 @@ while (1) {
printdb "Reading assign results.\n";
while (<ASSIGNFP>) {
chop;
/No physical nodes of type (.+)$/ && do {
$score=-2;
print $_ . "\n";
};
/^With ([0-9]+) violations$/ && do {
$violations = $1;
last;
};
/^[ \t]+BEST SCORE: [ \t]+([0-9]+\.[0-9]+)/ && ($score=$1);
}
if ($score == -2) {
# Type error
print "Giving up.\n";
exit(2);
}
printdb "Found score $score, violations $violations.\n";
# We don't bother reading anything else if violations occured.
......
......@@ -12,6 +12,7 @@ nodes
ping
set-ip
sharkshelf
dnardshelf
simplelink
singlenode
spinglass
......
......@@ -12,6 +12,7 @@ nodes
ping
set-ip
sharkshelf
dnardshelf
simplelink
singlenode
trafgen
......
If sharks be known as dnards does the world still make sense?
source tb_compat.tcl
set ns [new Simulator]
set node0 [$ns node]
set node1 [$ns node]
set node2 [$ns node]
set node3 [$ns node]
set router [$ns node]
set sharklan [$ns make-lan "$node0 $node1 $node2 $node3 $router" 10Mb 0ms]
tb-set-hardware $node0 dnard
tb-set-hardware $node1 dnard
tb-set-hardware $node2 shark
tb-set-hardware $node3 shark
$ns run
tb_prerun("tbprerun",0);
tb_run("tbswapin",0);
tb_run("tbswapout",0);
tb_run("tbswapin",0);
tb_run("tbswapout",0);
tb_run("tbend",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