From dacaec8826f773f5d8cd95229d23da035df0425e Mon Sep 17 00:00:00 2001 From: bdr7fv <bdr7fv@git.zephyr-software.com> Date: Sun, 27 May 2012 20:09:25 +0000 Subject: [PATCH] Added a few more options for always and only validate functions, and an option to turn off validation for p1, by default it is on. I have commented out some the hard coded blacklist based on a substring, since this was only used for TNE. Will have to come up with a solution for this later. Former-commit-id: 40564240b9d4a4be0ed781db878a2ed9b2447062 --- tools/transforms/PNMain.cpp | 28 ++++++-- tools/transforms/PNTransformDriver.cpp | 91 ++++++++++++++++---------- tools/transforms/PNTransformDriver.hpp | 7 +- 3 files changed, 87 insertions(+), 39 deletions(-) diff --git a/tools/transforms/PNMain.cpp b/tools/transforms/PNMain.cpp index f5075c9e8..74a28735d 100644 --- a/tools/transforms/PNMain.cpp +++ b/tools/transforms/PNMain.cpp @@ -36,6 +36,8 @@ enum COVERAGE_FILE_OPTION, PN_THRESHOLD_OPTION, CANARIES_OPTION, + ALWAYS_ONLY_VALIDATE_OPTION, + NO_P1_VALIDATE_OPTION, APRIORI_OPTION }; @@ -49,6 +51,8 @@ static struct option const long_options[] = {"coverage_file",required_argument, NULL, COVERAGE_FILE_OPTION}, {"pn_threshold",required_argument, NULL, PN_THRESHOLD_OPTION}, {"canaries", required_argument, NULL, CANARIES_OPTION}, + {"always_only_validate",required_argument, NULL, ALWAYS_ONLY_VALIDATE_OPTION}, + {"no_p1_validate",no_argument,NULL,NO_P1_VALIDATE_OPTION}, {"apriori_layout_file",required_argument, NULL, APRIORI_OPTION}, {NULL, 0, NULL, 0} }; @@ -149,6 +153,8 @@ int main(int argc, char **argv) char *BED_script=NULL; char *blacklist_file=NULL; char *coverage_file=NULL; + char *always_only_validate=NULL; + bool validate_p1=true; while((c = getopt_long(argc, argv, "", long_options, NULL)) != -1) { switch(c) @@ -200,6 +206,16 @@ int main(int argc, char **argv) } break; } + case ALWAYS_ONLY_VALIDATE_OPTION: + { + always_only_validate=optarg; + break; + } + case NO_P1_VALIDATE_OPTION: + { + validate_p1 = false; + break; + } case '?': { //error message already printed by getopt_long @@ -230,11 +246,12 @@ int main(int argc, char **argv) catch (DatabaseError_t pnide) { cout<<"Unexpected database error: "<<pnide<<endl; - exit(-1); - } + exit(-1); } set<std::string> blackListOfFunctions; blackListOfFunctions = getFunctionList(blacklist_file); + set<std::string> aoValidateFunctions; + aoValidateFunctions = getFunctionList(always_only_validate); map<string,double> coverage_map = getCoverageMap(coverage_file); cout<<"P1threshold parsed = "<<p1threshold<<endl; @@ -254,6 +271,7 @@ int main(int argc, char **argv) PNTransformDriver transform_driver(pidp,BED_script); transform_driver.AddBlacklist(blackListOfFunctions); + transform_driver.AddAlwaysAndOnlyValidateList(aoValidateFunctions); OffsetInference *offset_inference = new OffsetInference(); @@ -281,8 +299,10 @@ int main(int argc, char **argv) transform_driver.AddInference(conservative_memset_inference,2); transform_driver.AddInference(p1,2); - //TODO: I need an option for this - transform_driver.GenerateTransforms(coverage_map,p1threshold,2); + if(!validate_p1) + transform_driver.GenerateTransforms(coverage_map,p1threshold,2,2); + else + transform_driver.GenerateTransforms(coverage_map,p1threshold,2,-1); //transform_driver.GenerateTransforms(); /* diff --git a/tools/transforms/PNTransformDriver.cpp b/tools/transforms/PNTransformDriver.cpp index cae670c7c..92f6cca2f 100644 --- a/tools/transforms/PNTransformDriver.cpp +++ b/tools/transforms/PNTransformDriver.cpp @@ -77,11 +77,21 @@ void PNTransformDriver::AddBlacklist(set<string> &blacklist) } } -void PNTransformDriver::AddBlacklistFunction(string &func_name) +void PNTransformDriver::AddBlacklistFunction(string func_name) { blacklist.insert(func_name); } +void PNTransformDriver::AddAlwaysAndOnlyValidateList(std::set<std::string> &always_validate_list) +{ + set<string>::iterator it; + for(it = always_validate_list.begin();it != always_validate_list.end();it++) + { + this->always_validate_list.insert(*it); + } +} + + /* void PNTransformDriver::GenerateTransforms2(VariantIR_t *virp,vector<Function_t*> funcs,string BED_script, int progid) { @@ -193,7 +203,7 @@ void PNTransformDriver::GenerateTransforms2(VariantIR_t *virp,vector<Function_t* void PNTransformDriver::GenerateTransforms() { map<string,double> empty_map; - GenerateTransforms(empty_map,0,0); + GenerateTransforms(empty_map,0,0,-1); } void PNTransformDriver::GenerateTransformsInit() @@ -376,6 +386,7 @@ bool PNTransformDriver::IsBlacklisted(Function_t *func) // filter out _L_lock_* // filter out _L_unlock_* +/* if (func->GetName().find("_L_lock_") == 0 || func->GetName().find("_L_unlock_") == 0 || func->GetName().find("__gnu_") != string::npos || @@ -390,6 +401,8 @@ bool PNTransformDriver::IsBlacklisted(Function_t *func) func->GetName().find("__PRETTY_FUNCTION__") != string::npos || func->GetName().find("__cxa") != string::npos || blacklist.find(func->GetName()) != blacklist.end()) +*/ + if(blacklist.find(func->GetName()) != blacklist.end()) { cerr<<"PNTransformDriver: Blacklisted Function "<<func->GetName()<<endl; blacklist_funcs++; @@ -402,7 +415,7 @@ bool PNTransformDriver::IsBlacklisted(Function_t *func) //TODO: break into smaller functions //threshold_level is the hierarchy level to start at if the coverage for a function is less than the threshold. //Set this value to a negative integer to abort transformation of the function if the threshold is not met. -void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, double threshold, int threshold_level) +void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, double threshold, int threshold_level, int never_validate_level) { if(transform_hierarchy.size() == 0) { @@ -410,6 +423,8 @@ void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, doub return; } + this->never_validate_level = never_validate_level; + GenerateTransformsInit(); if(threshold < 0) @@ -451,6 +466,8 @@ void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, doub unsigned int level=0; double func_coverage = 0; + //TODO: check a priori map, if in the map, ignore coverage + //see if the function is in the coverage map if(coverage_map.find(func->GetName()) != coverage_map.end()) { @@ -458,42 +475,25 @@ void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, doub //do nothing, otherwise set hierachy to start at the level //passed. func_coverage = coverage_map[func->GetName()]; - - if(func_coverage < threshold) - { - level = threshold_level; - - if(threshold_level < 0) - { - cout<<"PNTransformDriver: Function "<<func->GetName()<< - " has insufficient coverage, aborting transformation"<<endl; - continue; - } - else - { - cout<<"PNTransformDriver: Function "<<func->GetName()<< - " has insufficient coverage, starting at hierarchy at " - " level "<<threshold_level<<endl; - } - - } } - else + + if(func_coverage < threshold) { level = threshold_level; - if(threshold_level < 0) - { - cout<<"PNTransformDriver: Function "<<func->GetName()<< + if(threshold_level < 0) + { + cout<<"PNTransformDriver: Function "<<func->GetName()<< " has insufficient coverage, aborting transformation"<<endl; - continue; - } - else - { - cout<<"PNTransformDriver: Function "<<func->GetName()<< + continue; + } + else + { + cout<<"PNTransformDriver: Function "<<func->GetName()<< " has insufficient coverage, starting at hierarchy at " " level "<<threshold_level<<endl; - } + } + } //Get a layout inference for each level of the hierarchy. Sort these layouts based on @@ -526,7 +526,32 @@ void PNTransformDriver::GenerateTransforms(map<string,double> coverage_map, doub //TODO: it is assumed now that the threshold_level is a level at which no validation need be done //but what if no threshold level is desired or provided? Hack for post TNE testing. - bool do_validate = (func_coverage != 0 && level != threshold_level); + //bool do_validate = (func_coverage != 0 && level != threshold_level); + bool do_validate = true; + if(always_validate_list.size() != 0) + { + if(always_validate_list.find(func->GetName()) == always_validate_list.end()) + { + do_validate = false; + } + + } + else + { + do_validate = (level != never_validate_level); + } + + + +/* + bool do_validate = func->GetName().compare("MAIN_parseCommandLine") == 0 || func->GetName().compare("MAIN_printInfo") == 0 || func->GetName().compare("BZ2_decompress") == 0 || func->GetName().compare("fallbackSort") == 0 || func->GetName().compare("BZ2_hbMakeCodeLengths")==0 || func->GetName().compare("BZ2_compressBlock")==0 || + func->GetName().compare("quantum_bmeasure")==0 || func->GetName().compare("main")==0 || func->GetName().compare("quantum_hadamard")==0 || func->GetName().compare("muln")==0 || func->GetName().compare("quantum_cond_phase")==0 ||func->GetName().compare("quantum_gate1")==0 || + func->GetName().compare("main")==0 || func->GetName().compare("think")==0 || func->GetName().compare("search")==0 || func->GetName().compare("comp_to_san")==0 || func->GetName().compare("display_board")==0 || func->GetName().compare("run_autotest")==0 || func->GetName().compare("search_root")==0 || func->GetName().compare("qsearch")==0 || + func->GetName().compare("add_basic_path")==0 || func->GetName().compare("make_loop_table")==0 || func->GetName().compare("imp_gauge_force")==0 || func->GetName().compare("char_num")==0 || func->GetName().compare("f_meas_imp")==0 || func->GetName().compare("dslash_fn")==0 || func->GetName().compare("load_longlinks")==0 || func->GetName().compare("eo_fermion_force")==0 || func->GetName().compare("g_measure")==0 || func->GetName().compare("coldlat")==0||func->GetName().compare("mult_adj_su3_mat_4vec")==0 || func->GetName().compare("ploop")==0 || + func->GetName().compare("main")==0 || func->GetName().compare("dict_read")==0 || func->GetName().compare("vithist_rescore")==0 || func->GetName().compare("subvq_init")==0 || func->GetName().compare("mdef_init")==0 || func->GetName().compare("bio_readhdr")==0 + || func->GetName().compare("std_eval")==0 + || func->GetName().compare("unlimit") == 0; +*/ //TODO: for TNE if there is no coverage for a function, perform the transform (which should be p1 at this point) blindly //May need to reconsider this in the future. diff --git a/tools/transforms/PNTransformDriver.hpp b/tools/transforms/PNTransformDriver.hpp index ff079f7de..d83965a90 100644 --- a/tools/transforms/PNTransformDriver.hpp +++ b/tools/transforms/PNTransformDriver.hpp @@ -27,6 +27,8 @@ protected: std::vector< std::vector<PNStackLayoutInference*> > transform_hierarchy; PNRegularExpressions pn_regex; std::set<std::string> blacklist; + std::set<std::string> always_validate_list; + int never_validate_level; //std::map<libIRDB::Instruction_t*,std::string> undo_list; std::map<libIRDB::Instruction_t*,libIRDB::Instruction_t*> undo_list; std::map< std::string,std::vector<PNStackLayout*> > transformed_history; @@ -70,9 +72,10 @@ public: //provided, the default is level 1. virtual void AddInference(PNStackLayoutInference *inference, int level=0); virtual void AddBlacklist(std::set<std::string> &blacklist); - virtual void AddBlacklistFunction(std::string &func_name); + virtual void AddBlacklistFunction(std::string func_name); + virtual void AddAlwaysAndOnlyValidateList(std::set<std::string> &always_validate_list); virtual void GenerateTransforms(); - virtual void GenerateTransforms(std::map<std::string,double> coverage_map, double threshold, int threshold_level); + virtual void GenerateTransforms(std::map<std::string,double> coverage_map, double threshold, int threshold_level, int never_validate_level); }; #endif -- GitLab