-
Notifications
You must be signed in to change notification settings - Fork 7
added option to pass candidate functions #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: aig-shared-ptr-better-fix
Are you sure you want to change the base?
Changes from all commits
6f2d663
547c4a4
3f180b4
b2fa586
3405c7d
2779b72
e5de3db
c5d9955
189e4de
80a9fd4
21976ff
aa83290
5a6b7af
812ac5e
55941de
5156579
31dd021
a616cfb
860aefc
6c38c9c
091121c
ad8f088
53602a1
b4279c8
b8daad2
d858259
68ca086
76af7e0
0c1d685
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,13 +83,15 @@ int do_synth_bve = true; | |
| int do_pre_backbone = 0; | ||
| int manthan_rep_mult = 4; | ||
| int manthan_strategy = 0; | ||
| constexpr uint32_t unate_def_backward_rerun_threshold = 8; | ||
|
|
||
| int synthesis = false; | ||
| int do_unate = false; | ||
| int do_unate_def = false; | ||
| int do_revbce = false; | ||
| int do_minim_indep = true; | ||
| string debug_minim; | ||
| string candidate_defs_file; | ||
| double cms_glob_mult = -1.0; | ||
| int mode = 0; | ||
| unique_ptr<FieldGen> fg = nullptr; | ||
|
|
@@ -165,6 +167,7 @@ void add_arjun_options() { | |
| // synth -- debug | ||
| myopt("--manthancnf", mconf.write_manthan_cnf, string, "Write Manthan CNF to this file"); | ||
| myopt("--debugsynth", conf.debug_synth, string,"Debug synthesis, prefix with this fname"); | ||
| myopt("--candidatefuns", candidate_defs_file, string, "Load candidate functions from AIG-defs file"); | ||
|
|
||
|
|
||
| // Simplification options for minim | ||
|
|
@@ -298,73 +301,140 @@ void do_synthesis() { | |
| check_cnf_sat(cnf); | ||
| cout << "c o ignoring --backbone option, doing backbone for synth no matter what" << endl; | ||
| cnf.get_var_types(conf.verb | verbose_debug_enabled, "start do_synthesis"); | ||
| if (do_synth_bve && !cnf.synth_done()) { | ||
| if (!candidate_defs_file.empty()) { | ||
| cnf.set_preserve_existing_defs(true); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be default. When this Also, can't we just skip defining them completely, and use the definitions from the file? Then we wouldn't need to overwrite. I'd prefer that actually :)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the reason I defined these is because there can be two cases: we are trying to overwrite definitions because another pass discovered new definition: for example, backward definability can discover one definition and then when we are doing BVE, we may want to overwrite them or preserve the earlier definition. Perhaps more acute is the case when a variable is detected to be unate but we also want to eliminate it via BVE. |
||
| cnf.import_candidate_functions(candidate_defs_file, conf.verb); | ||
| cnf.simplify_aigs(conf.verb); | ||
| cnf.get_var_types(conf.verb | verbose_debug_enabled, "after importing candidate functions"); | ||
| } | ||
| const bool has_candidate_funs = !candidate_defs_file.empty(); | ||
| const bool candidate_all_specified = (has_candidate_funs && cnf.synth_done()); | ||
| if (candidate_all_specified) { | ||
| cout << "c o [synth] all non-input functions provided by candidate file;" | ||
| << " skipping synth preprocessing and starting from counterexample checks" << endl; | ||
| } | ||
| if (has_candidate_funs && do_synth_bve) { | ||
| cout << "c o [synth] candidate functions supplied; skipping --synthbve preprocessing" << endl; | ||
| } | ||
|
|
||
| if (!has_candidate_funs && !candidate_all_specified && do_synth_bve && !cnf.synth_done()) { | ||
| /* simp_conf.bve_too_large_resolvent = -1; */ | ||
| cnf = arjun->standalone_get_simplified_cnf(cnf, simp_conf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-simplified_cnf.aig"); | ||
| } | ||
|
|
||
| if (etof_conf.do_autarky && !cnf.synth_done()) { | ||
| if (!candidate_all_specified && etof_conf.do_autarky && !cnf.synth_done()) { | ||
| arjun->standalone_autarky(cnf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-autarky.aig"); | ||
| } | ||
|
|
||
| if (etof_conf.do_extend_indep && !cnf.synth_done()) { | ||
| if (!candidate_all_specified && etof_conf.do_extend_indep && !cnf.synth_done()) { | ||
| arjun->standalone_unsat_define(cnf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-extend_synth.aig"); | ||
| cnf.simplify_aigs(conf.verb); | ||
| } | ||
|
|
||
| if (do_minim_indep && !cnf.synth_done()) { | ||
| if (!candidate_all_specified && do_minim_indep && !cnf.synth_done()) { | ||
| arjun->standalone_backward_round_synth(cnf, mconf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-minim_idep_synt.aig"); | ||
| cnf.simplify_aigs(conf.verb); | ||
| } | ||
|
|
||
| if (do_unate && !cnf.synth_done()) { | ||
| if (!candidate_all_specified && do_unate && !cnf.synth_done()) { | ||
| arjun->standalone_unate(cnf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-unsat_unate.aig"); | ||
| } | ||
|
|
||
| if (do_unate_def && !cnf.synth_done()) { | ||
| if (!candidate_all_specified && do_unate_def && !cnf.synth_done()) { | ||
| uint32_t unate_def_newly_defined = 0; | ||
| auto [input_before_unate_def, to_define_before_unate_def, backward_before_unate_def] = | ||
| cnf.get_var_types(0 | verbose_debug_enabled, "pre_unate_def_count"); | ||
| arjun->standalone_unate_def(cnf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-unsat_unate_def.aig"); | ||
| auto [input_after_unate_def, to_define_after_unate_def, backward_after_unate_def] = | ||
| cnf.get_var_types(0 | verbose_debug_enabled, "post_unate_def_count"); | ||
| (void)input_after_unate_def; | ||
| (void)backward_after_unate_def; | ||
| if (to_define_before_unate_def.size() >= to_define_after_unate_def.size()) { | ||
| unate_def_newly_defined += to_define_before_unate_def.size() - to_define_after_unate_def.size(); | ||
| } | ||
|
|
||
| if (do_minim_indep && !cnf.synth_done() | ||
| && unate_def_newly_defined >= unate_def_backward_rerun_threshold) { | ||
| cout << "c o [synth] unate_def defined " << unate_def_newly_defined | ||
| << " vars (threshold " << unate_def_backward_rerun_threshold | ||
| << "), rerunning backward synthesis" << endl; | ||
| arjun->standalone_backward_round_synth(cnf, mconf); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-minim_idep_synt-post_unate_def.aig"); | ||
| cnf.simplify_aigs(conf.verb); | ||
| } | ||
| } | ||
|
|
||
| auto mconf_orig = mconf; | ||
| int effective_strategy = manthan_strategy; | ||
| if (has_candidate_funs && effective_strategy == 4) { | ||
| cout << "c o [synth] candidate functions supplied; ignoring --mstrategy 4 (BVE-only), using strategy 2" << endl; | ||
| effective_strategy = 2; | ||
| } | ||
| uint32_t tries; | ||
| if (manthan_strategy > 4) { | ||
| cout << "ERROR: unknown strategy " << manthan_strategy << endl; | ||
| exit(EXIT_FAILURE); | ||
| } | ||
| if (!cnf.synth_done() && (manthan_strategy == 0 || manthan_strategy == 1)) { | ||
| const bool all_defined_before_manthan = cnf.synth_done(); | ||
| if (all_defined_before_manthan) { | ||
| mconf = mconf_orig; | ||
| if (!candidate_all_specified) { | ||
| cout << "c o [synth] all non-input functions are already defined;" | ||
| << " running final counterexample check before returning" << endl; | ||
| } | ||
| mconf.start_from_candidate_cex = 1; | ||
| mconf.manthan_bve = 0; | ||
| if (mconf.manthan_order == 2) mconf.manthan_order = 0; | ||
| tries = std::numeric_limits<uint32_t>::max(); | ||
| cnf = arjun->standalone_manthan(cnf, mconf, tries); | ||
| } else if (!cnf.synth_done() && (effective_strategy == 0 || effective_strategy == 1)) { | ||
| mconf = mconf_orig; | ||
| // Learning with no samples | ||
| mconf.manthan_bve = 0; | ||
| if (has_candidate_funs && mconf.manthan_order == 2) mconf.manthan_order = 0; | ||
| mconf.num_samples = 1; | ||
| mconf.num_samples_ccnr = 0; | ||
| mconf.manthan_bve = 0; | ||
| tries = 20*manthan_rep_mult; | ||
| if (manthan_strategy == 1) tries = std::numeric_limits<uint32_t>::max(); | ||
| if (effective_strategy == 1) tries = std::numeric_limits<uint32_t>::max(); | ||
| cnf = arjun->standalone_manthan(cnf, mconf, tries); | ||
| if (cnf.synth_done()) verb_print(1, "Manthan finished with strategy 1"); | ||
| } | ||
| if (!cnf.synth_done() && (manthan_strategy == 0 || manthan_strategy == 2)) { | ||
| if (!candidate_all_specified && !cnf.synth_done() && (effective_strategy == 0 || effective_strategy == 2)) { | ||
| // Learning with (larger) samples size | ||
| mconf = mconf_orig; | ||
| mconf.manthan_bve = 0; | ||
| if (has_candidate_funs && mconf.manthan_order == 2) mconf.manthan_order = 0; | ||
| tries = 100*manthan_rep_mult; | ||
| if (manthan_strategy == 2) tries = std::numeric_limits<uint32_t>::max(); | ||
| if (effective_strategy == 2) tries = std::numeric_limits<uint32_t>::max(); | ||
| cnf = arjun->standalone_manthan(cnf, mconf, tries); | ||
| if (cnf.synth_done()) verb_print(1, "Manthan finished with strategy 2"); | ||
| } | ||
| if (!cnf.synth_done() && (manthan_strategy == 0 || manthan_strategy == 3)) { | ||
| if (!cnf.synth_done() && (effective_strategy == 0 || effective_strategy == 3)) { | ||
| // Learning, no BW, only input var learning, no silent update | ||
| mconf = mconf_orig; | ||
| mconf.manthan_bve = 0; | ||
| mconf.force_bw_equal = 1; | ||
| mconf.silent_var_update = 0; | ||
| mconf.do_use_all_variables_as_features = 0; | ||
| tries = 100*manthan_rep_mult; | ||
| if (effective_strategy == 3) tries = std::numeric_limits<uint32_t>::max(); | ||
| cnf = arjun->standalone_manthan(cnf, mconf, tries); | ||
| if (cnf.synth_done()) verb_print(1, "Manthan finished with strategy 3"); | ||
| } | ||
| if (!has_candidate_funs && !cnf.synth_done() && (effective_strategy == 0 || effective_strategy == 4)) { | ||
| // BVE strategy | ||
| mconf = mconf_orig; | ||
| mconf.manthan_bve = 1; | ||
| tries = std::numeric_limits<uint32_t>::max(); | ||
| cnf = arjun->standalone_manthan(cnf, mconf, tries); | ||
| if (cnf.synth_done()) verb_print(1, "Manthan finished with strategy 3"); | ||
| if (cnf.synth_done()) verb_print(1, "Manthan finished with strategy 4"); | ||
| } | ||
| release_assert(cnf.synth_done() && "Synthesis should be done by now, but it is not!"); | ||
| if (!conf.debug_synth.empty()) cnf.write_aig_defs_to_file(conf.debug_synth + "-5-manthan.aig"); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be true by default. I don't see why it needs to be false by default?