3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

adding rlimit resource limit facility to provide platform and architecture independent method for canceling activities

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-09-28 13:37:59 -07:00
parent ad16cc0ce2
commit 9b3e242990
26 changed files with 165 additions and 14 deletions

View file

@ -35,6 +35,7 @@ void smt_params::updt_local_params(params_ref const & _p) {
m_delay_units_threshold = p.delay_units_threshold();
m_preprocess = _p.get_bool("preprocess", true); // hidden parameter
m_timeout = p.timeout();
m_rlimit = p.rlimit();
m_max_conflicts = p.max_conflicts();
m_core_validate = p.core_validate();
model_params mp(_p);

View file

@ -206,6 +206,7 @@ struct smt_params : public preprocessor_params,
bool m_user_theory_preprocess_axioms;
bool m_user_theory_persist_axioms;
unsigned m_timeout;
unsigned m_rlimit;
bool m_at_labels_cex; // only use labels which contains the @ symbol when building multiple counterexamples.
bool m_check_at_labels; // check that @ labels are inserted to generate unique counter-examples.
bool m_dump_goal_as_smt;
@ -275,6 +276,7 @@ struct smt_params : public preprocessor_params,
m_user_theory_preprocess_axioms(false),
m_user_theory_persist_axioms(false),
m_timeout(0),
m_rlimit(0),
m_at_labels_cex(false),
m_check_at_labels(false),
m_dump_goal_as_smt(false),

View file

@ -16,6 +16,7 @@ def_module_params(module_name='smt',
('pull_nested_quantifiers', BOOL, False, 'pull nested quantifiers'),
('refine_inj_axioms', BOOL, True, 'refine injectivity axioms'),
('timeout', UINT, 0, 'timeout (0 means no timeout)'),
('rlimit', UINT, 0, 'resource limit (0 means no limit)'),
('max_conflicts', UINT, UINT_MAX, 'maximum number of conflicts before giving up.'),
('mbqi', BOOL, True, 'model based quantifier instantiation (MBQI)'),
('mbqi.max_cexs', UINT, 1, 'initial maximal number of counterexamples used in MBQI, each counterexample generates a quantifier instantiation'),

View file

@ -199,7 +199,7 @@ namespace smt {
bool context::bcp() {
SASSERT(!inconsistent());
while (m_qhead < m_assigned_literals.size()) {
if (m_cancel_flag) {
if (get_cancel_flag()) {
return true;
}
literal l = m_assigned_literals[m_qhead];
@ -1616,7 +1616,7 @@ namespace smt {
unsigned qhead = m_qhead;
if (!bcp())
return false;
if (m_cancel_flag)
if (get_cancel_flag())
return true;
SASSERT(!inconsistent());
propagate_relevancy(qhead);
@ -2773,7 +2773,7 @@ namespace smt {
}
void context::assert_expr_core(expr * e, proof * pr) {
if (m_cancel_flag) return;
if (get_cancel_flag()) return;
SASSERT(is_well_sorted(m_manager, e));
TRACE("begin_assert_expr", tout << mk_pp(e, m_manager) << "\n";);
TRACE("begin_assert_expr_ll", tout << mk_ll_pp(e, m_manager) << "\n";);
@ -2803,7 +2803,7 @@ namespace smt {
}
void context::internalize_assertions() {
if (m_cancel_flag) return;
if (get_cancel_flag()) return;
TRACE("internalize_assertions", tout << "internalize_assertions()...\n";);
timeit tt(get_verbosity_level() >= 100, "smt.preprocessing");
reduce_assertions();
@ -3311,6 +3311,9 @@ namespace smt {
if (!inconsistent()) {
if (resource_limits_exceeded())
return l_undef;
if (!m_manager.limit().inc())
return l_undef;
if (m_num_conflicts_since_restart > m_restart_threshold && m_scope_lvl - m_base_lvl > 2) {
TRACE("search_bug", tout << "bounded-search return undef, inconsistent: " << inconsistent() << "\n";);
@ -3337,9 +3340,11 @@ namespace smt {
return l_undef;
}
if (!m_manager.limit().inc())
return l_undef;
if (m_base_lvl == m_scope_lvl && m_fparams.m_simplify_clauses)
simplify_clauses();
if (!decide()) {
final_check_status fcs = final_check();
@ -3381,7 +3386,7 @@ namespace smt {
}
}
if (m_cancel_flag) {
if (get_cancel_flag()) {
m_last_search_failure = CANCELED;
return true;
}

View file

@ -235,7 +235,7 @@ namespace smt {
virtual void set_cancel_flag(bool f = true);
bool get_cancel_flag() { return m_cancel_flag; }
bool get_cancel_flag() { return m_cancel_flag || !m_manager.limit().inc(); }
region & get_region() {
return m_region;