diff --git a/assign/assign.cc b/assign/assign.cc index b98bef7137a17924cc901d6075dc7829e0326b21..e6bab0c45351e8d5f509d8ab0a6d4a684ad80710 100644 --- a/assign/assign.cc +++ b/assign/assign.cc @@ -156,6 +156,14 @@ bool check_fixed_nodes = false; // If true, dump a bunch of configrution information 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 // bool xml_input = false; #ifdef WITH_XML @@ -488,6 +496,8 @@ void print_help() { cout << " -F - Apply additional checking to fixed nodes" << endl; cout << " -D - Dump configuration options" << endl; cout << " -R - Randomize order of nodes in pclasses" << endl; + cout << " -S - 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 << " If you must, see config.h in the source for a list" << endl; @@ -891,9 +901,9 @@ int main(int argc,char **argv) { char* ptopFileFormat; char* vtopFileFormat; 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 - char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:FDR"; + char* flags = "s:v:l:t:rpPTdH:oguc:nx:y:FDRS:"; #endif while ((ch = getopt(argc,argv,flags)) != -1) { @@ -1040,6 +1050,16 @@ int main(int argc,char **argv) { case 'R': randomize_order = true; 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: print_help(); diff --git a/assign/score.cc b/assign/score.cc index 901f22df934d60a9d0036d0badf88e3716571e55..a9d82281fd909f65417fb74413f32e83850e686b 100644 --- a/assign/score.cc +++ b/assign/score.cc @@ -50,6 +50,8 @@ using namespace boost; extern switch_pred_map_map switch_preds; extern bool disable_pclasses; +extern bool strategy_balance; +extern bool strategy_pack; double score; // The score of the current mapping int violated; // How many times the restrictions @@ -1061,17 +1063,17 @@ void remove_node(vvertex vv) int old_load = tr->get_current_load(); tr->remove_load(vnode->typecount); pnode->total_load -= vnode->typecount; -#ifdef LOAD_BALANCE - // Use this tricky formula to score based on how 'full' the pnode is, so 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))); - SADD(SCORE_PNODE * (powf(1+ tr->get_current_load() * 1.0/tr->get_max_load(),2))); -#endif -#ifdef PACK_TIGHT - // Inverse of LOAD_BALANCE - 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))); -#endif + if (strategy_balance) { + // Use this tricky formula to score based on how 'full' the pnode is, so + // 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))); + SADD(SCORE_PNODE * (powf(1+ tr->get_current_load() * 1.0/tr->get_max_load(),2))); + } + if (strategy_pack) { + // 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))); + SADD(SCORE_PNODE * (powf((tr->get_max_load() - tr->get_current_load()) * 1.0/tr->get_max_load(),0.5))); + } if (pnode->total_load == 0) { // If the pnode is now free, we need to do some cleanup SDEBUG(cerr << " releasing pnode" << endl); @@ -1467,14 +1469,15 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed, bool skip lit++; } } -#ifdef LOAD_BALANCE - 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))); -#endif -#ifdef PACK_TIGHT - 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))); -#endif + + if (strategy_balance) { + 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))); + } + if (strategy_pack) { + 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))); + } // node no longer unassigned SSUB(SCORE_UNASSIGNED);