mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 17:45:32 +00:00
use vectors instead of hash-tables in dimacs serialization to avoid hash-table contention
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
e623f1e9c9
commit
e4d6aa07dc
3 changed files with 26 additions and 14 deletions
|
@ -332,10 +332,17 @@ namespace sat {
|
|||
}
|
||||
|
||||
void drat::verify(unsigned n, literal const* c) {
|
||||
if (m_check_unsat && !is_drup(n, c) && !is_drat(n, c)) {
|
||||
if (!m_check_unsat) {
|
||||
return;
|
||||
}
|
||||
for (unsigned i = 0; i < n; ++i) {
|
||||
declare(c[i]);
|
||||
}
|
||||
if (!is_drup(n, c) && !is_drat(n, c)) {
|
||||
literal_vector lits(n, c);
|
||||
std::cout << "Verification of " << lits << " failed\n";
|
||||
s.display(std::cout);
|
||||
SASSERT(false);
|
||||
exit(0);
|
||||
UNREACHABLE();
|
||||
//display(std::cout);
|
||||
|
@ -476,6 +483,10 @@ namespace sat {
|
|||
literal lit = c[i];
|
||||
if (lit != wc.m_l1 && lit != wc.m_l2 && value(lit) != l_false) {
|
||||
wc.m_l2 = lit;
|
||||
if (m_watches.size() <= (~lit).index())
|
||||
{
|
||||
IF_VERBOSE(0, verbose_stream() << m_watches.size() << " " << lit << " " << (~lit).index() << "\n");
|
||||
}
|
||||
m_watches[(~lit).index()].push_back(idx);
|
||||
done = true;
|
||||
}
|
||||
|
|
|
@ -344,11 +344,11 @@ namespace sat {
|
|||
|
||||
void solver::mk_bin_clause(literal l1, literal l2, bool learned) {
|
||||
if (find_binary_watch(get_wlist(~l1), ~l2)) {
|
||||
assign_core(l1, 0, justification(l2));
|
||||
assign_core(l1, 0, justification(l1));
|
||||
return;
|
||||
}
|
||||
if (find_binary_watch(get_wlist(~l2), ~l1)) {
|
||||
assign_core(l2, 0, justification(l1));
|
||||
assign_core(l2, 0, justification(l2));
|
||||
return;
|
||||
}
|
||||
watched* w0 = find_binary_watch(get_wlist(~l1), l2);
|
||||
|
|
|
@ -434,7 +434,8 @@ void goal::display_ll(std::ostream & out) const {
|
|||
\brief Assumes that the formula is already in CNF.
|
||||
*/
|
||||
void goal::display_dimacs(std::ostream & out) const {
|
||||
obj_map<expr, unsigned> expr2var;
|
||||
unsigned_vector expr2var;
|
||||
ptr_vector<expr> exprs;
|
||||
unsigned num_vars = 0;
|
||||
unsigned num_cls = size();
|
||||
for (unsigned i = 0; i < num_cls; i++) {
|
||||
|
@ -453,10 +454,11 @@ void goal::display_dimacs(std::ostream & out) const {
|
|||
expr * l = lits[j];
|
||||
if (m().is_not(l))
|
||||
l = to_app(l)->get_arg(0);
|
||||
if (expr2var.contains(l))
|
||||
continue;
|
||||
num_vars++;
|
||||
expr2var.insert(l, num_vars);
|
||||
if (expr2var.get(l->get_id(), UINT_MAX) == UINT_MAX) {
|
||||
num_vars++;
|
||||
expr2var.setx(l->get_id(), num_vars, UINT_MAX);
|
||||
exprs.setx(l->get_id(), l, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
out << "p cnf " << num_vars << " " << num_cls << "\n";
|
||||
|
@ -478,17 +480,16 @@ void goal::display_dimacs(std::ostream & out) const {
|
|||
out << "-";
|
||||
l = to_app(l)->get_arg(0);
|
||||
}
|
||||
unsigned id = UINT_MAX;
|
||||
expr2var.find(l, id);
|
||||
unsigned id = expr2var[l->get_id()];
|
||||
SASSERT(id != UINT_MAX);
|
||||
out << id << " ";
|
||||
}
|
||||
out << "0\n";
|
||||
}
|
||||
for (auto const& kv : expr2var) {
|
||||
expr* key = kv.m_key;
|
||||
if (is_app(key))
|
||||
out << "c " << kv.m_value << " " << to_app(key)->get_decl()->get_name() << "\n";
|
||||
for (expr* e : exprs) {
|
||||
if (e && is_app(e)) {
|
||||
out << "c " << expr2var[e->get_id()] << " " << to_app(e)->get_decl()->get_name() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue