3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-06-03 20:20:36 -07:00 committed by Nuno Lopes
parent 9262908ebb
commit 59330b3855
5 changed files with 23 additions and 15 deletions

View file

@ -104,7 +104,7 @@ namespace sat {
m_solvers.resize(num_extra_solvers);
symbol saved_phase = s.m_params.get_sym("phase", symbol("caching"));
for (unsigned i = 0; i < num_extra_solvers; ++i) {
m_limits.push_back(reslimit());
m_limits.push_back(alloc(reslimit));
}
for (unsigned i = 0; i < num_extra_solvers; ++i) {
@ -112,7 +112,7 @@ namespace sat {
if (i == 1 + num_threads/2) {
s.m_params.set_sym("phase", symbol("random"));
}
m_solvers[i] = alloc(sat::solver, s.m_params, m_limits[i]);
m_solvers[i] = alloc(sat::solver, s.m_params, *m_limits[i]);
m_solvers[i]->copy(s, true);
m_solvers[i]->set_par(this, i);
push_child(m_solvers[i]->rlimit());

View file

@ -23,6 +23,7 @@ Revision History:
#include "util/hashtable.h"
#include "util/map.h"
#include "util/rlimit.h"
#include "util/scoped_ptr_vector.h"
namespace sat {
@ -69,7 +70,7 @@ namespace sat {
bool m_consumer_ready;
scoped_limits m_scoped_rlimit;
vector<reslimit> m_limits;
scoped_ptr_vector<reslimit> m_limits;
ptr_vector<solver> m_solvers;
public:
@ -87,7 +88,7 @@ namespace sat {
solver& get_solver(unsigned i) { return *m_solvers[i]; }
void cancel_solver(unsigned i) { m_limits[i].cancel(); }
void cancel_solver(unsigned i) { m_limits[i]->cancel(); }
// exchange unit literals
void exchange(solver& s, literal_vector const& in, unsigned& limit, literal_vector& out);

View file

@ -1243,8 +1243,7 @@ namespace sat {
unsigned error_code = 0;
lbool result = l_undef;
bool canceled = false;
#pragma omp parallel for
for (int i = 0; i < num_threads; ++i) {
auto worker_thread = [&](int i) {
try {
lbool r = l_undef;
if (IS_AUX_SOLVER(i)) {
@ -1296,6 +1295,14 @@ namespace sat {
ex_msg = ex.msg();
ex_kind = DEFAULT_EX;
}
};
vector<std::thread> threads;
for (int i = 0; i < num_threads; ++i) {
threads.push_back(std::thread([&]() { worker_thread(i); }));
}
for (int i = 0; i < num_threads; ++i) {
threads[i].join();
}
if (IS_AUX_SOLVER(finished_id)) {