Skip to content

Commit

Permalink
extract stats with finalize for parallel mode
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Dec 13, 2024
1 parent b429562 commit 538f74d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 30 deletions.
8 changes: 2 additions & 6 deletions src/ast/sls/sls_smt_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ namespace sls {
if (!m_ddfw)
return;
m_result = m_ddfw->check(0, nullptr);
m_ddfw->collect_statistics(m_st);
IF_VERBOSE(1, verbose_stream() << "sls-result " << m_result << "\n");
for (auto v : m_shared_bool_vars) {
auto w = m_smt_bool_var2sls_bool_var[v];
Expand All @@ -115,7 +114,7 @@ namespace sls {
m_ddfw->rlimit().pop();
}

void smt_plugin::finalize(model_ref& mdl) {
void smt_plugin::finalize(model_ref& mdl, ::statistics& st) {
auto* d = m_ddfw;
if (!d)
return;
Expand All @@ -127,6 +126,7 @@ namespace sls {
m_thread.join();
SASSERT(m_completed);
mdl = nullptr;
m_ddfw->collect_statistics(st);
if (m_result == l_true && m_sls_model) {
ast_translation tr(m_sls, m);
mdl = m_sls_model->translate(tr);
Expand All @@ -139,10 +139,6 @@ namespace sls {
dealloc(d);
}

void smt_plugin::collect_statistics(::statistics& st) const {
st.copy(m_st);
}

void smt_plugin::get_shared_clauses(vector<sat::literal_vector>& _clauses) {
_clauses.reset();
for (auto const& clause : clauses()) {
Expand Down
4 changes: 1 addition & 3 deletions src/ast/sls/sls_smt_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ namespace sls {

sat::literal_vector m_units;
model_ref m_sls_model;
::statistics m_st;

bool m_new_clause_added = false;
unsigned m_min_unsat_size = UINT_MAX;
Expand Down Expand Up @@ -106,8 +105,7 @@ namespace sls {

// interface to calling solver:
void check(expr_ref_vector const& fmls, vector <sat::literal_vector> const& clauses);
void collect_statistics(::statistics& st) const;
void finalize(model_ref& md);
void finalize(model_ref& md, ::statistics& st);
void get_shared_clauses(vector<sat::literal_vector>& clauses);
void updt_params(params_ref& p) {}
std::ostream& display(std::ostream& out) override;
Expand Down
6 changes: 2 additions & 4 deletions src/sat/smt/sls_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ namespace sls {
if (!m_smt_plugin)
return;

m_smt_plugin->collect_statistics(m_st);
m_smt_plugin->finalize(m_model);
m_smt_plugin->finalize(m_model, m_st);
m_model = nullptr;
m_smt_plugin = nullptr;
}
Expand All @@ -90,8 +89,7 @@ namespace sls {
return false;
if (!m_smt_plugin->completed())
return false;
m_smt_plugin->collect_statistics(m_st);
m_smt_plugin->finalize(m_model);
m_smt_plugin->finalize(m_model, m_st);
m_smt_plugin = nullptr;
return true;
}
Expand Down
18 changes: 6 additions & 12 deletions src/smt/theory_sls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ namespace smt {
m_init_search = true;
}

void theory_sls::finalize() {
void theory_sls::finalize() const {
if (!m_smt_plugin)
return;

m_smt_plugin->collect_statistics(m_st);
m_smt_plugin->finalize(m_model);
m_smt_plugin->finalize(m_model, m_st);
m_model = nullptr;
m_smt_plugin = nullptr;
m_init_search = false;
Expand All @@ -108,8 +106,7 @@ namespace smt {
else if (!m_parallel_mode)
propagate_local_search();
else if (m_smt_plugin->completed()) {
m_smt_plugin->collect_statistics(m_st);
m_smt_plugin->finalize(m_model);
m_smt_plugin->finalize(m_model, m_st);
m_smt_plugin = nullptr;
m_init_search = false;
}
Expand Down Expand Up @@ -197,10 +194,8 @@ namespace smt {
}

void theory_sls::collect_statistics(::statistics& st) const {
if (m_smt_plugin)
m_smt_plugin->collect_statistics(st);
else
st.copy(m_st);
finalize();
st.copy(m_st);
st.update("sls-num-guided-search", m_stats.m_num_guided_sls);
st.update("sls-num-restart-search", m_stats.m_num_restart_sls);
}
Expand All @@ -222,8 +217,7 @@ namespace smt {
void theory_sls::bounded_run(unsigned num_steps) {
m_smt_plugin->bounded_run(num_steps);
if (m_smt_plugin->result() == l_true) {
m_smt_plugin->collect_statistics(m_st);
m_smt_plugin->finalize(m_model);
m_smt_plugin->finalize(m_model, m_st);
m_smt_plugin = nullptr;
m_init_search = false;
}
Expand Down
12 changes: 7 additions & 5 deletions src/smt/theory_sls.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ namespace smt {
unsigned m_num_restart_sls = 0;
};
stats m_stats;
model_ref m_model;
sls::smt_plugin* m_smt_plugin = nullptr;
mutable model_ref m_model;
mutable sls::smt_plugin* m_smt_plugin = nullptr;
unsigned m_trail_lim = 0;
bool m_checking = false;
bool m_parallel_mode = true;
Expand All @@ -72,11 +72,11 @@ namespace smt {
unsigned m_after_resolve_decide_count = 0;
unsigned m_resolve_count = 0;
unsigned m_resolve_gap = 0;
bool m_init_search = false;
::statistics m_st;
mutable bool m_init_search = false;
mutable ::statistics m_st;
vector<sat::literal_vector> m_shared_clauses;

void finalize();

void bounded_run(unsigned num_steps);
void inc_restart_ls_steps() {
if (m_restart_ls_steps < m_restart_ls_steps_max)
Expand All @@ -92,10 +92,12 @@ namespace smt {
void propagate_local_search();

void run_guided_sls();
void finalize() const;

public:
theory_sls(context& ctx);
~theory_sls() override;

model_ref get_model() { return m_model; }

// smt::theory interface
Expand Down

0 comments on commit 538f74d

Please sign in to comment.