Commit 15ef05a4 authored by Robert Ricci's avatar Robert Ricci

Turn LOAD_BALANCE and PACK_TIGHT into command line args

Looks like we are going to want the ability to tweak vnode placement per
run rather than by building new assign binaries. So, add new '-S
balance' and '-S pack' options. I suspect it would also be useful to add
'-S spread' to try to spread vnodes out across as many hosts as
possible, some people want this when using shared hosts.
parent 8367ac24
...@@ -156,6 +156,14 @@ bool check_fixed_nodes = false; ...@@ -156,6 +156,14 @@ bool check_fixed_nodes = false;
// If true, dump a bunch of configrution information // If true, dump a bunch of configrution information
bool dump_config = false; bool dump_config = false;
// If true, turn on some scoring options that attempt to evenly balance vnodes
// across pnodes
bool strategy_balance = false;
// If true, turn on some scoring options that attempt to pack vnodes as tightly
// as possible onto pnodes
bool strategy_pack = false;
// Use XML for file input // Use XML for file input
// bool xml_input = false; // bool xml_input = false;
#ifdef WITH_XML #ifdef WITH_XML
...@@ -488,6 +496,8 @@ void print_help() { ...@@ -488,6 +496,8 @@ void print_help() {
cout << " -F - Apply additional checking to fixed nodes" << endl; cout << " -F - Apply additional checking to fixed nodes" << endl;
cout << " -D - Dump configuration options" << endl; cout << " -D - Dump configuration options" << endl;
cout << " -R - Randomize order of nodes in pclasses" << endl; cout << " -R - Randomize order of nodes in pclasses" << endl;
cout << " -S <str> - Set vnode packing strategy. Currently supported" << endl;
cout << " values are 'balance' and 'pack'" << endl;
cout << " cparams - You probably don't want to touch these!" << endl; cout << " cparams - You probably don't want to touch these!" << endl;
cout << " If you must, see config.h in the source for a list" cout << " If you must, see config.h in the source for a list"
<< endl; << endl;
...@@ -891,9 +901,9 @@ int main(int argc,char **argv) { ...@@ -891,9 +901,9 @@ int main(int argc,char **argv) {
char* ptopFileFormat; char* ptopFileFormat;
char* vtopFileFormat; char* vtopFileFormat;
char* delims = "/"; char* delims = "/";
char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:W:FDf:R"; char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:W:FDf:RS:";
#else #else
char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:FDR"; char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:FDRS:";
#endif #endif
while ((ch = getopt(argc,argv,flags)) != -1) { while ((ch = getopt(argc,argv,flags)) != -1) {
...@@ -1040,6 +1050,16 @@ int main(int argc,char **argv) { ...@@ -1040,6 +1050,16 @@ int main(int argc,char **argv) {
case 'R': case 'R':
randomize_order = true; randomize_order = true;
break; break;
case 'S':
if (strcmp(optarg,"balance") == 0) {
strategy_balance = true;
} else if (strcmp(optarg,"pack") == 0) {
strategy_pack = true;
} else {
print_help();
}
break;
default: default:
print_help(); print_help();
......
...@@ -50,6 +50,8 @@ using namespace boost; ...@@ -50,6 +50,8 @@ using namespace boost;
extern switch_pred_map_map switch_preds; extern switch_pred_map_map switch_preds;
extern bool disable_pclasses; extern bool disable_pclasses;
extern bool strategy_balance;
extern bool strategy_pack;
double score; // The score of the current mapping double score; // The score of the current mapping
int violated; // How many times the restrictions int violated; // How many times the restrictions
...@@ -1061,17 +1063,17 @@ void remove_node(vvertex vv) ...@@ -1061,17 +1063,17 @@ void remove_node(vvertex vv)
int old_load = tr->get_current_load(); int old_load = tr->get_current_load();
tr->remove_load(vnode->typecount); tr->remove_load(vnode->typecount);
pnode->total_load -= vnode->typecount; pnode->total_load -= vnode->typecount;
#ifdef LOAD_BALANCE if (strategy_balance) {
// Use this tricky formula to score based on how 'full' the pnode is, so that // Use this tricky formula to score based on how 'full' the pnode is, so
// we prefer to equally fill the minimum number of pnodes // that we prefer to equally fill the minimum number of pnodes
SSUB(SCORE_PNODE * (powf(1+ ((tr->get_current_load()+1) * 1.0)/tr->get_max_load(),2))); SSUB(SCORE_PNODE * (powf(1+ ((tr->get_current_load()+1) * 1.0)/tr->get_max_load(),2)));
SADD(SCORE_PNODE * (powf(1+ tr->get_current_load() * 1.0/tr->get_max_load(),2))); SADD(SCORE_PNODE * (powf(1+ tr->get_current_load() * 1.0/tr->get_max_load(),2)));
#endif }
#ifdef PACK_TIGHT if (strategy_pack) {
// Inverse of LOAD_BALANCE // Inverse of strategy_balance
SSUB(SCORE_PNODE * (powf(((tr->get_max_load() - (tr->get_current_load()+1)) * 1.0)/tr->get_max_load(),0.5))); SSUB(SCORE_PNODE * (powf(((tr->get_max_load() - (tr->get_current_load()+1)) * 1.0)/tr->get_max_load(),0.5)));
SADD(SCORE_PNODE * (powf((tr->get_max_load() - tr->get_current_load()) * 1.0/tr->get_max_load(),0.5))); SADD(SCORE_PNODE * (powf((tr->get_max_load() - tr->get_current_load()) * 1.0/tr->get_max_load(),0.5)));
#endif }
if (pnode->total_load == 0) { if (pnode->total_load == 0) {
// If the pnode is now free, we need to do some cleanup // If the pnode is now free, we need to do some cleanup
SDEBUG(cerr << " releasing pnode" << endl); SDEBUG(cerr << " releasing pnode" << endl);
...@@ -1467,14 +1469,15 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip ...@@ -1467,14 +1469,15 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip
lit++; lit++;
} }
} }
#ifdef LOAD_BALANCE
SSUB(SCORE_PNODE * (powf(1 + ((tr->get_current_load()-1) * 1.0)/tr->get_max_load(),2))); if (strategy_balance) {
SADD(SCORE_PNODE * (powf(1 + ((tr->get_current_load()) * 1.0)/tr->get_max_load(),2))); SSUB(SCORE_PNODE * (powf(1 + ((tr->get_current_load()-1) * 1.0)/tr->get_max_load(),2)));
#endif SADD(SCORE_PNODE * (powf(1 + ((tr->get_current_load()) * 1.0)/tr->get_max_load(),2)));
#ifdef PACK_TIGHT }
SSUB(SCORE_PNODE * (powf(((tr->get_max_load() - (tr->get_current_load()-1)) * 1.0)/tr->get_max_load(),0.5))); if (strategy_pack) {
SADD(SCORE_PNODE * (powf(((tr->get_max_load() - tr->get_current_load()) * 1.0)/tr->get_max_load(),0.5))); SSUB(SCORE_PNODE * (powf(((tr->get_max_load() - (tr->get_current_load()-1)) * 1.0)/tr->get_max_load(),0.5)));
#endif SADD(SCORE_PNODE * (powf(((tr->get_max_load() - tr->get_current_load()) * 1.0)/tr->get_max_load(),0.5)));
}
// node no longer unassigned // node no longer unassigned
SSUB(SCORE_UNASSIGNED); SSUB(SCORE_UNASSIGNED);
......
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