Commit 99c2a1ab authored by Robert Ricci's avatar Robert Ricci

Use #defines for the exit values, and include comments explaining what

they mean.
parent 5154179e
......@@ -304,25 +304,25 @@ void anneal(bool scoring_selftest, double scale_neighborhood)
if (vname2vertex.find((*fixed_it).first) == vname2vertex.end()) {
cout << "Fixed node: " << (*fixed_it).first <<
"does not exist." << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
vvertex vv = vname2vertex[(*fixed_it).first];
if (pname2vertex.find((*fixed_it).second) == pname2vertex.end()) {
cout << "Fixed node: " << (*fixed_it).second <<
" not available." << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
pvertex pv = pname2vertex[(*fixed_it).second];
tb_vnode *vn = get(vvertex_pmap,vv);
tb_pnode *pn = get(pvertex_pmap,pv);
if (vn->vclass != NULL) {
cout << "Can not have fixed nodes be in a vclass!.\n";
exit(2);
exit(EXIT_UNRETRYABLE);
}
if (add_node(vv,pv,false,false) == 1) {
cout << "Fixed node: Could not map " << vn->name <<
" to " << pn->name << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
vn->fixed = true;
num_fixed++;
......
......@@ -132,7 +132,7 @@ void read_physical_topology(char *filename)
ptopfile.open(filename);
if (!ptopfile.is_open()) {
cout << "Unable to open ptop file " << filename << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
cout << "Physical Graph: " << parse_ptop(PG,SG,ptopfile) << endl;
......@@ -241,7 +241,7 @@ void read_virtual_topology(char *filename)
topfile.open(filename);
if (!topfile.is_open()) {
cout << "Unable to open top file " << filename << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
cout << "Virtual Graph: " << parse_top(VG,topfile) << endl;
......@@ -314,7 +314,7 @@ void print_help()
cout << " -T - Doing some scoring self-testing." << endl;
cout << " -H <float> - Try <float> times harder." << endl;
cout << " -o - Allow overloaded pnodes to be considered." << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
// Perfrom a pre-cehck to make sure that there are enough free nodes of the
......@@ -560,7 +560,7 @@ int mapping_precheck() {
// unretryable error
void exit_unretryable(int signal) {
cout << "Killed with signal " << signal << " - exiting!" << endl;
_exit(2);
_exit(EXIT_UNRETRYABLE);
}
int main(int argc,char **argv)
......@@ -680,12 +680,12 @@ int main(int argc,char **argv)
// Run the type precheck
if (!type_precheck()) {
exit(2);
exit(EXIT_UNRETRYABLE);
}
// Run the mapping precheck
if (!mapping_precheck()) {
exit(2);
exit(EXIT_UNRETRYABLE);
}
#ifdef PER_VNODE_TT
......@@ -748,9 +748,9 @@ int main(int argc,char **argv)
}
if (violated != 0) {
return 1;
exit(EXIT_RETRYABLE);
} else {
return 0;
exit(EXIT_SUCCESS);
}
}
......@@ -9,7 +9,22 @@
#include "config.h"
const int MAX_PNODES = 1024; /* maximum # of physical nodes */
/*
* Exit vaules from assign
*/
// A solution with no violations was found
#define EXIT_SUCCESS 0
// No valid solution was found, but one may exist
// No violation-free solution was found after annealing, or there was an
// internal error
#define EXIT_RETRYABLE 1
// It is not possible to map the given top file into the given ptop file,
// so there's no point in re-running assign.
// Can also occur if the top or ptop file does not exist or cannot be parsed
#define EXIT_UNRETRYABLE 2
/*
To use these on the command line, each entry gets a
......
......@@ -302,7 +302,7 @@ int parse_ptop(tb_pgraph &PG, tb_sgraph &SG, istream& i)
errors += bind_ptop_subnodes();
if (errors > 0) {exit(2);}
if (errors > 0) {exit(EXIT_UNRETRYABLE);}
return num_nodes;
}
......
......@@ -311,7 +311,7 @@ int parse_top(tb_vgraph &VG, istream& i)
errors += bind_top_subnodes();
if (errors > 0) {exit(2);}
if (errors > 0) {exit(EXIT_UNRETRYABLE);}
return num_nodes;
}
......@@ -539,7 +539,7 @@ void score_link_info(vedge ve, tb_pnode *src_pnode, tb_pnode *dst_pnode, tb_vnod
#endif
case tb_link_info::LINK_UNKNOWN:
cout << "Internal error: Should not be here either." << endl;
exit(1);
exit(EXIT_RETRYABLE);
break;
}
......@@ -953,7 +953,7 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
case tb_link_info::LINK_UNKNOWN:
case tb_link_info::LINK_TRIVIAL:
cerr << "Internal error: Should not be here." << endl;
exit(1);
exit(EXIT_RETRYABLE);
break;
}
if (choice < 0) break;
......@@ -1544,7 +1544,7 @@ double fd_score(tb_vnode *vnode,tb_pnode *pnode,int &fd_violated,
default:
// Global features are required to have some kind of type
cout << "Bad global feature " << (*feature_it).first << endl;
exit(2);
exit(EXIT_UNRETRYABLE);
}
} else {
desire_it = vnode->desires.find(feature_name);
......
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