3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

prepare polysat

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2022-01-26 06:19:24 +01:00
commit 3f5df04dc4
252 changed files with 5792 additions and 2553 deletions

View file

@ -520,7 +520,7 @@ params_ref::~params_ref() {
params_ref::params_ref(params_ref const & p):
m_params(nullptr) {
operator=(p);
set(p);
}
void params_ref::display(std::ostream & out) const {
@ -553,18 +553,20 @@ void params_ref::validate(param_descrs const & p) {
m_params->validate(p);
}
params_ref & params_ref::operator=(params_ref const & p) {
void params_ref::set(params_ref const & p) {
if (p.m_params)
p.m_params->inc_ref();
if (m_params)
m_params->dec_ref();
m_params = p.m_params;
return *this;
}
void params_ref::copy(params_ref const & src) {
if (m_params == nullptr)
operator=(src);
if (m_params == nullptr || m_params->empty())
set(src);
else if (src.empty())
return;
else {
init();
copy_core(src.m_params);

View file

@ -35,6 +35,8 @@ class params_ref {
params * m_params;
void init();
void copy_core(params const * p);
params_ref& operator=(params_ref const& p) = delete;
void set(params_ref const& p);
public:
params_ref():m_params(nullptr) {}
params_ref(params_ref const & p);
@ -42,8 +44,7 @@ public:
static params_ref const & get_empty() { return g_empty_params_ref; }
params_ref & operator=(params_ref const & p);
// copy params from src
void copy(params_ref const & src);
void append(params_ref const & src) { copy(src); }

View file

@ -33,12 +33,14 @@ Revision History:
#include <pthread.h>
#endif
enum scoped_timer_work_state { IDLE = 0, WORKING = 1, EXITING = 2 };
struct scoped_timer_state {
std::thread m_thread;
std::timed_mutex m_mutex;
event_handler * eh;
unsigned ms;
std::atomic<int> work;
std::atomic<scoped_timer_work_state> work;
std::condition_variable_any cv;
};
@ -49,11 +51,11 @@ static atomic<unsigned> num_workers(0);
static void thread_func(scoped_timer_state *s) {
workers.lock();
while (true) {
s->cv.wait(workers, [=]{ return s->work > 0; });
s->cv.wait(workers, [=]{ return s->work > IDLE; });
workers.unlock();
// exiting..
if (s->work == 2)
if (s->work == EXITING)
return;
auto end = std::chrono::steady_clock::now() + std::chrono::milliseconds(s->ms);
@ -68,9 +70,8 @@ static void thread_func(scoped_timer_state *s) {
s->m_mutex.unlock();
next:
s->work = 0;
s->work = IDLE;
workers.lock();
available_workers.push_back(s);
}
}
@ -97,7 +98,7 @@ public:
s->ms = ms;
s->eh = eh;
s->m_mutex.lock();
s->work = 1;
s->work = WORKING;
if (new_worker) {
s->m_thread = std::thread(thread_func, s);
}
@ -108,8 +109,11 @@ public:
~imp() {
s->m_mutex.unlock();
while (s->work == 1)
while (s->work == WORKING)
std::this_thread::yield();
workers.lock();
available_workers.push_back(s);
workers.unlock();
}
};
@ -139,7 +143,7 @@ void scoped_timer::finalize() {
while (deleted < num_workers) {
workers.lock();
for (auto w : available_workers) {
w->work = 2;
w->work = EXITING;
w->cv.notify_one();
}
decltype(available_workers) cleanup_workers;

View file

@ -445,7 +445,7 @@ bool state_graph::write_dgml() {
}
r = m_state_ufind.next(r);
} while (r != s);
dgml << " Category=\"State\">" << std::endl;
dgml << " Category=\"State\" Group=\"Collapsed\">" << std::endl;
if (m_dead.contains(s))
dgml << "<Category Ref=\"Dead\"/>" << std::endl;
if (m_live.contains(s))
@ -453,18 +453,35 @@ bool state_graph::write_dgml() {
if (m_unexplored.contains(s))
dgml << "<Category Ref=\"Unexplored\"/>" << std::endl;
dgml << "</Node>" << std::endl;
dgml << "<Node Id=\"" << s << "info\" Label=\"";
r = s;
dgml << s << "=";
m_state_pp.pp_state_label(dgml, r);
do {
if (r != s) {
dgml << "&#13;" << r << "=";
m_state_pp.pp_state_label(dgml, r);
}
r = m_state_ufind.next(r);
} while (r != s);
dgml << "\"" << std::endl;
dgml << " Category=\"StateInfo\">" << std::endl;
dgml << "</Node>" << std::endl;
}
}
dgml << "</Nodes>" << std::endl;
dgml << "<Links>" << std::endl;
for (auto s : m_seen) {
if (m_state_ufind.is_root(s))
if (m_state_ufind.is_root(s)) {
for (auto t : m_targets[s]) {
dgml << "<Link Source=\"" << s << "\" Target=\"" << t << "\" Category=\"Transition\">" << std::endl;
if (!m_sources_maybecycle[t].contains(s))
dgml << "<Category Ref=\"Noncycle\"/>" << std::endl;
dgml << "</Link>" << std::endl;
}
dgml << "<Link Source=\"" << s << "\" Target=\"" << s << "info\" Category=\"Contains\">" << std::endl;
dgml << "</Link>" << std::endl;
}
}
dgml << "</Links>" << std::endl;
dgml << "<Categories>" << std::endl
@ -494,6 +511,11 @@ bool state_graph::write_dgml() {
<< "<Setter Property=\"Stroke\" Value=\"black\"/>" << std::endl
<< "<Setter Property=\"Background\" Value=\"white\"/>" << std::endl
<< "<Setter Property=\"MinWidth\" Value=\"0\"/>" << std::endl
<< "<Setter Property=\"FontSize\" Value=\"12\"/>" << std::endl
<< "</Style>" << std::endl
<< "<Style TargetType=\"Node\" GroupLabel=\"StateInfo\" ValueLabel=\"True\">" << std::endl
<< "<Setter Property=\"Stroke\" Value=\"white\"/>" << std::endl
<< "<Setter Property=\"FontSize\" Value=\"24\"/>" << std::endl
<< "</Style>" << std::endl
<< "<Style TargetType=\"Link\" GroupLabel=\"Transition\" ValueLabel=\"True\">" << std::endl
<< "<Condition Expression=\"HasCategory('Transition')\"/>" << std::endl

View file

@ -87,12 +87,12 @@ zstring::zstring(char const* s) {
string_encoding zstring::get_encoding() {
if (gparams::get_value("encoding") == "unicode")
return unicode;
return string_encoding::unicode;
if (gparams::get_value("encoding") == "bmp")
return bmp;
return string_encoding::bmp;
if (gparams::get_value("encoding") == "ascii")
return ascii;
return unicode;
return string_encoding::ascii;
return string_encoding::unicode;
}
bool zstring::well_formed() const {

View file

@ -21,7 +21,7 @@ Author:
#include "util/buffer.h"
#include "util/rational.h"
enum string_encoding {
enum class string_encoding {
ascii, // exactly 8 bits
unicode,
bmp // basic multilingual plane; exactly 16 bits
@ -41,22 +41,22 @@ public:
static unsigned ascii_num_bits() { return 8; }
static unsigned max_char() {
switch (get_encoding()) {
case unicode:
case string_encoding::unicode:
return unicode_max_char();
case bmp:
case string_encoding::bmp:
return bmp_max_char();
case ascii:
case string_encoding::ascii:
return ascii_max_char();
}
return unicode_max_char();
}
static unsigned num_bits() {
switch (get_encoding()) {
case unicode:
case string_encoding::unicode:
return unicode_num_bits();
case bmp:
case string_encoding::bmp:
return bmp_num_bits();
case ascii:
case string_encoding::ascii:
return ascii_num_bits();
}
return unicode_num_bits();