Skip to content

Commit 538f74d

Browse files
extract stats with finalize for parallel mode
1 parent b429562 commit 538f74d

File tree

5 files changed

+18
-30
lines changed

5 files changed

+18
-30
lines changed

src/ast/sls/sls_smt_plugin.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ namespace sls {
9999
if (!m_ddfw)
100100
return;
101101
m_result = m_ddfw->check(0, nullptr);
102-
m_ddfw->collect_statistics(m_st);
103102
IF_VERBOSE(1, verbose_stream() << "sls-result " << m_result << "\n");
104103
for (auto v : m_shared_bool_vars) {
105104
auto w = m_smt_bool_var2sls_bool_var[v];
@@ -115,7 +114,7 @@ namespace sls {
115114
m_ddfw->rlimit().pop();
116115
}
117116

118-
void smt_plugin::finalize(model_ref& mdl) {
117+
void smt_plugin::finalize(model_ref& mdl, ::statistics& st) {
119118
auto* d = m_ddfw;
120119
if (!d)
121120
return;
@@ -127,6 +126,7 @@ namespace sls {
127126
m_thread.join();
128127
SASSERT(m_completed);
129128
mdl = nullptr;
129+
m_ddfw->collect_statistics(st);
130130
if (m_result == l_true && m_sls_model) {
131131
ast_translation tr(m_sls, m);
132132
mdl = m_sls_model->translate(tr);
@@ -139,10 +139,6 @@ namespace sls {
139139
dealloc(d);
140140
}
141141

142-
void smt_plugin::collect_statistics(::statistics& st) const {
143-
st.copy(m_st);
144-
}
145-
146142
void smt_plugin::get_shared_clauses(vector<sat::literal_vector>& _clauses) {
147143
_clauses.reset();
148144
for (auto const& clause : clauses()) {

src/ast/sls/sls_smt_plugin.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ namespace sls {
6565

6666
sat::literal_vector m_units;
6767
model_ref m_sls_model;
68-
::statistics m_st;
6968

7069
bool m_new_clause_added = false;
7170
unsigned m_min_unsat_size = UINT_MAX;
@@ -106,8 +105,7 @@ namespace sls {
106105

107106
// interface to calling solver:
108107
void check(expr_ref_vector const& fmls, vector <sat::literal_vector> const& clauses);
109-
void collect_statistics(::statistics& st) const;
110-
void finalize(model_ref& md);
108+
void finalize(model_ref& md, ::statistics& st);
111109
void get_shared_clauses(vector<sat::literal_vector>& clauses);
112110
void updt_params(params_ref& p) {}
113111
std::ostream& display(std::ostream& out) override;

src/sat/smt/sls_solver.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ namespace sls {
7272
if (!m_smt_plugin)
7373
return;
7474

75-
m_smt_plugin->collect_statistics(m_st);
76-
m_smt_plugin->finalize(m_model);
75+
m_smt_plugin->finalize(m_model, m_st);
7776
m_model = nullptr;
7877
m_smt_plugin = nullptr;
7978
}
@@ -90,8 +89,7 @@ namespace sls {
9089
return false;
9190
if (!m_smt_plugin->completed())
9291
return false;
93-
m_smt_plugin->collect_statistics(m_st);
94-
m_smt_plugin->finalize(m_model);
92+
m_smt_plugin->finalize(m_model, m_st);
9593
m_smt_plugin = nullptr;
9694
return true;
9795
}

src/smt/theory_sls.cpp

+6-12
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@ namespace smt {
8080
m_init_search = true;
8181
}
8282

83-
void theory_sls::finalize() {
83+
void theory_sls::finalize() const {
8484
if (!m_smt_plugin)
8585
return;
86-
87-
m_smt_plugin->collect_statistics(m_st);
88-
m_smt_plugin->finalize(m_model);
86+
m_smt_plugin->finalize(m_model, m_st);
8987
m_model = nullptr;
9088
m_smt_plugin = nullptr;
9189
m_init_search = false;
@@ -108,8 +106,7 @@ namespace smt {
108106
else if (!m_parallel_mode)
109107
propagate_local_search();
110108
else if (m_smt_plugin->completed()) {
111-
m_smt_plugin->collect_statistics(m_st);
112-
m_smt_plugin->finalize(m_model);
109+
m_smt_plugin->finalize(m_model, m_st);
113110
m_smt_plugin = nullptr;
114111
m_init_search = false;
115112
}
@@ -197,10 +194,8 @@ namespace smt {
197194
}
198195

199196
void theory_sls::collect_statistics(::statistics& st) const {
200-
if (m_smt_plugin)
201-
m_smt_plugin->collect_statistics(st);
202-
else
203-
st.copy(m_st);
197+
finalize();
198+
st.copy(m_st);
204199
st.update("sls-num-guided-search", m_stats.m_num_guided_sls);
205200
st.update("sls-num-restart-search", m_stats.m_num_restart_sls);
206201
}
@@ -222,8 +217,7 @@ namespace smt {
222217
void theory_sls::bounded_run(unsigned num_steps) {
223218
m_smt_plugin->bounded_run(num_steps);
224219
if (m_smt_plugin->result() == l_true) {
225-
m_smt_plugin->collect_statistics(m_st);
226-
m_smt_plugin->finalize(m_model);
220+
m_smt_plugin->finalize(m_model, m_st);
227221
m_smt_plugin = nullptr;
228222
m_init_search = false;
229223
}

src/smt/theory_sls.h

+7-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ namespace smt {
5555
unsigned m_num_restart_sls = 0;
5656
};
5757
stats m_stats;
58-
model_ref m_model;
59-
sls::smt_plugin* m_smt_plugin = nullptr;
58+
mutable model_ref m_model;
59+
mutable sls::smt_plugin* m_smt_plugin = nullptr;
6060
unsigned m_trail_lim = 0;
6161
bool m_checking = false;
6262
bool m_parallel_mode = true;
@@ -72,11 +72,11 @@ namespace smt {
7272
unsigned m_after_resolve_decide_count = 0;
7373
unsigned m_resolve_count = 0;
7474
unsigned m_resolve_gap = 0;
75-
bool m_init_search = false;
76-
::statistics m_st;
75+
mutable bool m_init_search = false;
76+
mutable ::statistics m_st;
7777
vector<sat::literal_vector> m_shared_clauses;
7878

79-
void finalize();
79+
8080
void bounded_run(unsigned num_steps);
8181
void inc_restart_ls_steps() {
8282
if (m_restart_ls_steps < m_restart_ls_steps_max)
@@ -92,10 +92,12 @@ namespace smt {
9292
void propagate_local_search();
9393

9494
void run_guided_sls();
95+
void finalize() const;
9596

9697
public:
9798
theory_sls(context& ctx);
9899
~theory_sls() override;
100+
99101
model_ref get_model() { return m_model; }
100102

101103
// smt::theory interface

0 commit comments

Comments
 (0)