Commit cf06552f authored by Christopher Alfeld's avatar Christopher Alfeld

Added support for emulated links. Emulated links can share physical links

with other emulated links.  Also added a trivial link type for virtual
links between vnodes in the same pnode.
parent 86c0ffa5
......@@ -64,7 +64,7 @@ node <node> <type> [<desires>]
OR
link <src> <dst> <bw>
link <src> <dst> <bw> [emulated]
OR
......
......@@ -565,6 +565,8 @@ void print_solution()
}
cout << " " << lp2.name << " (" << lp2.srcmac << "," <<
lp2.dstmac << ")" << endl;
} else if (v.type == tb_vlink::LINK_TRIVIAL) {
cout << " trivial" << endl;
} else {
cout << "Unknown link type" << endl;
}
......
......@@ -33,7 +33,8 @@ static float SCORE_DESIRE = 1;/* Multiplier for desire costs*/
static float SCORE_FEATURE = 1;/* Multiplier for feature weights*/
static float SCORE_PCLASS = 0.5; /* Cost of each pclass */
static float SCORE_VCLASS = 1; /* vclass score multiplier */
static float SCORE_EMULATED_LINK = 0.01; /* cost of an emualted link */
static struct config_param options[] = {
{ "IT", CONFIG_INT, &init_temp, 0 },
{ "OP", CONFIG_INT, &USE_OPTIMAL, 0 },
......@@ -54,6 +55,7 @@ static struct config_param options[] = {
{ "PC", CONFIG_FLOAT, &SCORE_PCLASS, 0 },
{ "VC", CONFIG_FLOAT, &SCORE_VCLASS, 0 },
{ "SW", CONFIG_FLOAT, &SCORE_SWITCH, 0 },
{ "EL", CONFIG_FLOAT, &SCORE_EMULATED_LINK, 0 },
{ "ON", CONFIG_FLOAT, &opt_nodes_per_sw, 0 },
{ "TR", CONFIG_FLOAT, &temp_rate, 0 }
};
......
......@@ -30,12 +30,13 @@ int parse_top(tb_vgraph &G, istream& i)
node no1;
string s1, s2;
char inbuf[255];
char n1[1024], n2[1024];
char n1[1024], n2[1024],emustring[1024];
char lname[1024];
int num_nodes = 0;
int bw;
int r;
dictionary<string,tb_vclass*> vclass_map;
bool emulated=false;
while (!i.eof()) {
char *ret;
......@@ -89,11 +90,15 @@ int parse_top(tb_vgraph &G, istream& i)
}
}
} else if (!strncmp(inbuf, "link", 4)) {
r=sscanf(inbuf, "link %s %s %s %d", lname, n1, n2,&bw);
if (r < 3) {
r=sscanf(inbuf, "link %s %s %s %d %s", lname, n1, n2,&bw,emustring);
if ((r <= 3) || ((r == 5) && strcmp(emustring,"emulated"))) {
fprintf(stderr, "bad link line: %s\n", inbuf);
} else {
if (r == 3) bw = 10;
if (r == 4) {
emulated = false;
} else {
emulated = true;
}
string s1(n1);
string s2(n2);
edge e;
......@@ -105,6 +110,7 @@ int parse_top(tb_vgraph &G, istream& i)
G[e].plink = NULL;
G[e].plink_two = NULL;
G[e].name = string(lname);
G[e].emulated = emulated;
}
} else if (! strncmp(inbuf, "fix-node",8)) {
r=sscanf(inbuf,"fix-node %s %s",n1,n2);
......
......@@ -213,7 +213,7 @@ void remove_node(node n)
unscore_link(vlink->plink,e,false);
unscore_link(vlink->plink_two,e,false);
} else {
} else if (vlink->type != tb_vlink::LINK_TRIVIAL) {
// No link
fprintf(stderr,"Internal error - no link\n");
abort();
......@@ -381,7 +381,12 @@ int add_node(node n,int ploc)
cerr << " goes to " << dpnoder.name << endl;
#endif
if ((pedge=direct_link(dpnode,pnode)) != NULL) {
if (dpnode == pnode) {
#ifdef SCORE_DEBUG
fprintf(stderr," trivial link\n");
#endif SCORE_DEBUG
er->type = tb_vlink::LINK_TRIVIAL;
} else if ((pedge=direct_link(dpnode,pnode)) != NULL) {
#ifdef SCORE_DEBUG
fprintf(stderr," found direct link = %p\n",pedge);
#endif
......@@ -675,21 +680,32 @@ void score_link(edge e,edge v,bool interswitch)
#endif
if (! interswitch) {
pl.users++;
if (pl.users == 1) {
if (! er.emulated) {
pl.users++;
if (pl.users == 1) {
#ifdef SCORE_DEBUG
fprintf(stderr," first user\n");
fprintf(stderr," first user\n");
#endif
SADD(SCORE_DIRECT_LINK);
SADD(SCORE_DIRECT_LINK);
} else {
#ifdef SCORE_DEBUG
fprintf(stderr," not first user - penalty\n");
#endif
SADD(SCORE_DIRECT_LINK_PENALTY);
vinfo.link_users++;
violated++;
}
} else {
pl.users++;
SADD(SCORE_EMULATED_LINK);
if (pl.users == 1) {
#ifdef SCORE_DEBUG
fprintf(stderr," not first user - penalty\n");
fprintf(stderr," emulated - first user\n");
#endif
SADD(SCORE_DIRECT_LINK_PENALTY);
vinfo.link_users++;
violated++;
SADD(SCORE_DIRECT_LINK);
}
}
}
}
// bandwidth
int prev_bw = pl.bw_used;
......@@ -716,21 +732,33 @@ void unscore_link(edge e,edge v,bool interswitch)
#endif
if (!interswitch) {
pl.users--;
if (pl.users == 0) {
// link no longer used
if (! er.emulated) {
pl.users--;
if (pl.users == 0) {
// link no longer used
#ifdef SCORE_DEBUG
fprintf(stderr," freeing link\n");
fprintf(stderr," freeing link\n");
#endif
SSUB(SCORE_DIRECT_LINK);
SSUB(SCORE_DIRECT_LINK);
} else {
// getting close to no violations
#ifdef SCORE_DEBUG
fprintf(stderr," reducing users\n");
#endif
SSUB(SCORE_DIRECT_LINK_PENALTY);
vinfo.link_users--;
violated--;
}
} else {
// getting close to no violations
pl.users--;
SSUB(SCORE_EMULATED_LINK);
if (pl.users == 0) {
// link no longer used
#ifdef SCORE_DEBUG
fprintf(stderr," reducing users\n");
fprintf(stderr," emulated - freeing link\n");
#endif
SSUB(SCORE_DIRECT_LINK_PENALTY);
vinfo.link_users--;
violated--;
SSUB(SCORE_DIRECT_LINK);
}
}
}
......
......@@ -40,7 +40,8 @@ public:
return i;
}
typedef enum {LINK_UNKNOWN, LINK_DIRECT,
LINK_INTRASWITCH, LINK_INTERSWITCH} linkType;
LINK_INTRASWITCH, LINK_INTERSWITCH,
LINK_TRIVIAL} linkType;
int bandwidth; // how much bandwidth this uses
linkType type; // link type
......@@ -50,6 +51,8 @@ public:
edge plink_local_two; // only used in inter - link to local switch
list<edge> path; // path for interswitch links
string name; // name
bool emulated; // is this an emulated link, i.e. can it
// share a plink withouter emulated vlinks
};
typedef GRAPH<tb_vnode,tb_vlink> tb_vgraph;
......
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