3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-15 23:35:26 +00:00

reworking cancellation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-12-11 16:21:24 -08:00
parent 981f8226fe
commit baee4225a7
145 changed files with 172 additions and 958 deletions

View file

@ -54,8 +54,7 @@ asserted_formulas::asserted_formulas(ast_manager & m, smt_params & p):
m_macro_manager(m, m_simplifier),
m_bit2int(m),
m_bv_sharing(m),
m_inconsistent(false),
m_cancel_flag(false) {
m_inconsistent(false){
m_bsimp = 0;
m_bvsimp = 0;
@ -223,9 +222,6 @@ void asserted_formulas::reset() {
m_inconsistent = false;
}
void asserted_formulas::set_cancel_flag(bool f) {
m_cancel_flag = f;
}
#ifdef Z3DEBUG
bool asserted_formulas::check_well_sorted() const {

View file

@ -62,7 +62,6 @@ class asserted_formulas {
bool m_inconsistent_old;
};
svector<scope> m_scopes;
volatile bool m_cancel_flag;
void setup_simplifier_plugins(simplifier & s, basic_simplifier_plugin * & bsimp, arith_simplifier_plugin * & asimp, bv_simplifier_plugin * & bvsimp);
void reduce_asserted_formulas();
@ -97,7 +96,7 @@ class asserted_formulas {
unsigned get_total_size() const;
bool has_bv() const;
void max_bv_sharing();
bool canceled() { return m_cancel_flag; }
bool canceled() { return m_manager.canceled(); }
public:
asserted_formulas(ast_manager & m, smt_params & p);

View file

@ -77,7 +77,6 @@ public:
void collect_statistics(statistics & st) const { m_solver.collect_statistics(st); }
void reset_statistics() { m_solver.reset_statistics(); }
void set_cancel(bool f) { m_solver.set_cancel(f); }
};
#endif /* EXPR_CONTEXT_SIMPLIFIER_H_ */

View file

@ -45,7 +45,6 @@ namespace smt {
m_fparams(p),
m_params(_p),
m_setup(*this, p),
m_cancel_flag(false),
m_asserted_formulas(m, p),
m_qmanager(alloc(quantifier_manager, *this, p, _p)),
m_model_generator(alloc(model_generator, m)),
@ -3069,11 +3068,6 @@ namespace smt {
if (m_manager.has_trace_stream())
m_manager.trace_stream() << "[begin-check] " << m_scope_lvl << "\n";
if (reset_cancel) {
m_cancel_flag = false;
m_asserted_formulas.set_cancel_flag(false);
}
if (memory::above_high_watermark()) {
m_last_search_failure = MEMOUT;
return false;
@ -4154,11 +4148,6 @@ namespace smt {
return m_last_search_failure;
}
void context::set_cancel_flag(bool f) {
m_cancel_flag = f;
m_asserted_formulas.set_cancel_flag(f);
}
};
#ifdef Z3DEBUG

View file

@ -79,7 +79,6 @@ namespace smt {
smt_params & m_fparams;
params_ref m_params;
setup m_setup;
volatile bool m_cancel_flag;
timer m_timer;
asserted_formulas m_asserted_formulas;
scoped_ptr<quantifier_manager> m_qmanager;
@ -233,9 +232,8 @@ namespace smt {
return m_params;
}
virtual void set_cancel_flag(bool f = true);
bool get_cancel_flag() { return m_cancel_flag || !m_manager.limit().inc(); }
bool get_cancel_flag() { return !m_manager.limit().inc(); }
region & get_region() {
return m_region;

View file

@ -169,10 +169,6 @@ namespace smt {
void display_istatistics(std::ostream & out) const {
m_kernel.display_istatistics(out);
}
void set_cancel(bool f) {
m_kernel.set_cancel_flag(f);
}
bool canceled() {
return m_kernel.get_cancel_flag();
@ -328,14 +324,6 @@ namespace smt {
m_imp->display_istatistics(out);
}
void kernel::set_cancel(bool f) {
#pragma omp critical (smt_kernel)
{
if (m_imp)
m_imp->set_cancel(f);
}
}
bool kernel::canceled() const {
return m_imp->canceled();
}

View file

@ -204,18 +204,7 @@ namespace smt {
\brief Display statistics in low level format.
*/
void display_istatistics(std::ostream & out) const;
/**
\brief Interrupt the kernel.
*/
void set_cancel(bool f = true);
void cancel() { set_cancel(true); }
/**
\brief Reset interruption.
*/
void reset_cancel() { set_cancel(false); }
/**
\brief Return true if the kernel was interrupted.
*/

View file

@ -101,9 +101,8 @@ namespace smt {
r.append(tmp.size(), tmp.c_ptr());
}
virtual void set_cancel(bool f) {
m_context.set_cancel(f);
}
virtual ast_manager& get_manager() { return m_context.m(); }
virtual void set_progress_callback(progress_callback * callback) {
m_callback = callback;

View file

@ -35,12 +35,10 @@ class ctx_solver_simplify_tactic : public tactic {
func_decl_ref m_fn;
obj_map<sort, func_decl*> m_fns;
unsigned m_num_steps;
volatile bool m_cancel;
public:
ctx_solver_simplify_tactic(ast_manager & m, params_ref const & p = params_ref()):
m(m), m_params(p), m_solver(m, m_front_p),
m_arith(m), m_mk_app(m), m_fn(m), m_num_steps(0),
m_cancel(false) {
m_arith(m), m_mk_app(m), m_fn(m), m_num_steps(0) {
sort* i_sort = m_arith.mk_int();
m_fn = m.mk_func_decl(symbol(0xbeef101), i_sort, m.mk_bool_sort());
}
@ -86,15 +84,10 @@ public:
virtual void cleanup() {
reset_statistics();
m_solver.reset();
m_cancel = false;
}
protected:
virtual void set_cancel(bool f) {
m_solver.set_cancel(f);
m_cancel = false;
}
void reduce(goal& g) {
SASSERT(g.is_well_sorted());
@ -177,7 +170,7 @@ protected:
names.push_back(n);
m_solver.push();
while (!todo.empty() && !m_cancel) {
while (!todo.empty() && !m.canceled()) {
expr_ref res(m);
args.reset();
expr* e = todo.back().m_expr;
@ -249,7 +242,7 @@ protected:
names.pop_back();
m_solver.pop(1);
}
if (!m_cancel) {
if (!m.canceled()) {
VERIFY(cache.find(fml, path_r));
result = path_r.m_expr;
}

View file

@ -132,10 +132,6 @@ public:
smt_params_helper::collect_param_descrs(r);
}
virtual void set_cancel(bool f) {
if (m_ctx)
m_ctx->set_cancel(f);
}
virtual void collect_statistics(statistics & st) const {
if (m_ctx)

View file

@ -22,7 +22,6 @@ struct unit_subsumption_tactic : public tactic {
ast_manager& m;
params_ref m_params;
smt_params m_fparams;
volatile bool m_cancel;
smt::context m_context;
expr_ref_vector m_clauses;
unsigned m_clause_count;
@ -34,19 +33,11 @@ struct unit_subsumption_tactic : public tactic {
params_ref const& p):
m(m),
m_params(p),
m_cancel(false),
m_context(m, m_fparams, p),
m_clauses(m) {
}
void set_cancel(bool f) {
m_cancel = f;
m_context.set_cancel_flag(f);
}
virtual void cleanup() {
set_cancel(false);
}
void cleanup() {}
virtual void operator()(/* in */ goal_ref const & in,
/* out */ goal_ref_buffer & result,
@ -66,7 +57,7 @@ struct unit_subsumption_tactic : public tactic {
}
void checkpoint() {
if (m_cancel) {
if (m.canceled()) {
throw tactic_exception(TACTIC_CANCELED_MSG);
}
}