Commit 53d30ab4 authored by David G Andersen's avatar David G Andersen
Browse files

Big changes. Physical topology meaning just changed

(now supply the total number of nodes).  Internal representation changed
to a linear list.  Scoring now assigns nodes to appropriate spots
in their switch and tries to match interface constraints.
Delay node coalescing now occurs.

todo:  Currently there's no way to set a node type via the GUI.
We should add this if we get time.
parent d72641b8
......@@ -40,7 +40,7 @@ node_array<int> bestnodes, absnodes;
float bestscore, absbest;
float *interlinks;
float *numnodes;
int *numnodes;
/*
* Basic simulated annealing parameters:
......@@ -78,10 +78,69 @@ float score()
if (interlinks[i] > intercap) {
sc += (interlinks[i]-intercap);
}
/* XXX: THIS MUST BE OPTIMIZED */
/* Experimental: Collapse delay nodes together
* and handle node fanout restrictions */
/* Mark all nodes unused */
for (int j = 0; j < topo->switches[i]->numnodes(); j++) {
topo->switches[i]->nodes[j].used = 0;
}
int numdelays = 0;
int assigned = 0;
node n;
forall_nodes(n, G) {
if (G[n].partition() == i) {
if (G[n].type() == testnode::TYPE_DELAY) {
numdelays++;
} else {
assigned = 0;
/* Assign to an available node */
for (int j = 0;
j < topo->switches[i]->numnodes();
j++) {
if (topo->switches[i]->nodes[j].used == 0 && (topo->switches[i]->nodes[j].ints >= G.degree(n))) {
topo->switches[i]->nodes[j].used = 1;
assigned = 1;
break;
}
}
if (!assigned) {
sc += 1;
}
}
}
}
int numn = numnodes[i];
numn -= numdelays;
/* Now turn normal nodes into delay nodes as needed */
/* XXX: THIS IS NOT OPTIMAL. We should improve on this
* so it uses the right size nodes a bit... but oh well */
int maxnodes = topo->switches[i]->numnodes();
int j = 0;
while (numdelays > 0 && j < maxnodes) {
if (topo->switches[i]->nodes[j].used) { continue; }
numdelays -= topo->switches[i]->nodes[j].ints/2;
topo->switches[i]->nodes[j].used = 1;
j++;
}
/* Add in the unsatisfied delay nodes */
if (numdelays > 0) {
sc += numdelays;
}
/* XXX: This should now be obsolete and handled by the
* assigned part above */
#if 0
/* Do we have too many nodes per switch? */
if (numnodes[i] > nodecap[i]) {
sc += (numnodes[i] - nodecap[i]);
}
#endif
/* Try to minimize the number of switches used */
/* This is likely NOT an effective way to do it! */
if (numnodes[i] > 0) {
......@@ -289,6 +348,12 @@ void loopassign()
totaltime = used_time(timestart);
cout << "Total time to find solution "
<< totaltime << " seconds" << endl;
node n;
#if 0
forall_nodes(n, G) {
cout << "Node degree: " << G.degree(n) << endl;
}
#endif
}
void chopgraph(GraphWin& gw) {
......@@ -434,7 +499,7 @@ int main(int argc, char **argv)
argv += optind;
interlinks = new float[nparts];
numnodes = new float[nparts];
numnodes = new int[nparts];
for (int i = 0; i < nparts; i++) {
interlinks[i] = 0;
numnodes[i] = 0;
......@@ -487,6 +552,7 @@ int main(int argc, char **argv)
for (int i = 0; i < nparts; i++) {
nodecap[i] = topo->switches[i]->numnodes();
}
topo->print_topo();
}
gw.display();
......
......@@ -73,15 +73,15 @@ topology *parse_phys(char *filename)
perror("Could not allocate a tbswitch");
exit(-1);
}
for (int i = 0; i < nodecount; i++) {
infile >> newsw->nodes[i].ints;
infile >> newsw->nodes[i].count;
newsw->nodes[i].used = 0;
#ifdef VERBOSE
printf("Adding node %d with %d %d\n",
i, newsw->nodes[i].ints,
newsw->nodes[i].count);
#endif
for (int i = 0; i < nodecount;) {
int ints, count;
infile >> ints;
infile >> count;
for (int j = 0; j < count; j++) {
newsw->nodes[i].ints = ints;
newsw->nodes[i].used = 0;
i++;
}
}
}
}
......
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include "phys.h"
toponode::toponode() {
ints = count = used = 0;
ints = used = 0;
}
tbswitch::tbswitch() {
......@@ -29,10 +30,7 @@ tbswitch::~tbswitch() {
}
inline int tbswitch::numnodes() {
int nc = 0;
for (int i = 0; i < nodecount; i++)
nc += nodes[i].count;
return nc;
return nodecount;
}
topology::topology(int nswitches) {
......@@ -43,3 +41,17 @@ topology::topology(int nswitches) {
topology::~topology() {
if (switches) delete(switches);
}
void topology::print_topo() {
cout << "Topology has " << switchcount << " switches" << endl;
cout << "--------" << endl;
for (int i = 0; i < switchcount; i++) {
cout << " sw " << i << " has " << switches[i]->numnodes() << " nodes"
<< endl;
for (int j = 0; j < switches[i]->nodecount; j++) {
cout << switches[i]->nodes[j].ints << " ";
}
cout << endl;
}
}
......@@ -2,7 +2,6 @@ class toponode {
public:
toponode();
int ints;
int count;
int used;
};
......@@ -23,9 +22,11 @@ public:
class topology {
public:
topology(int nswitches);
void print_topo();
virtual ~topology();
int switchcount;
tbswitch **switches;
};
topology *parse_phys(char *filename);
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