mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 06:03:23 +00:00
stash
This commit is contained in:
parent
75ad174567
commit
6a36116b5c
7 changed files with 34 additions and 18 deletions
|
@ -61,13 +61,14 @@ namespace datalog {
|
||||||
void compiler::make_join_project(reg_idx t1, reg_idx t2, const variable_intersection & vars,
|
void compiler::make_join_project(reg_idx t1, reg_idx t2, const variable_intersection & vars,
|
||||||
const unsigned_vector & removed_cols, reg_idx & result, instruction_block & acc) {
|
const unsigned_vector & removed_cols, reg_idx & result, instruction_block & acc) {
|
||||||
relation_signature aux_sig;
|
relation_signature aux_sig;
|
||||||
relation_signature::from_join(m_reg_signatures[t1], m_reg_signatures[t2], vars.size(),
|
relation_signature sig1 = m_reg_signatures[t1];
|
||||||
vars.get_cols1(), vars.get_cols2(), aux_sig);
|
relation_signature sig2 = m_reg_signatures[t2];
|
||||||
|
relation_signature::from_join(sig1, sig2, vars.size(), vars.get_cols1(), vars.get_cols2(), aux_sig);
|
||||||
relation_signature res_sig;
|
relation_signature res_sig;
|
||||||
relation_signature::from_project(aux_sig, removed_cols.size(), removed_cols.c_ptr(),
|
relation_signature::from_project(aux_sig, removed_cols.size(), removed_cols.c_ptr(),
|
||||||
res_sig);
|
res_sig);
|
||||||
|
|
||||||
result = get_fresh_register(res_sig);
|
result = get_fresh_register(res_sig);
|
||||||
|
|
||||||
acc.push_back(instruction::mk_join_project(t1, t2, vars.size(), vars.get_cols1(),
|
acc.push_back(instruction::mk_join_project(t1, t2, vars.size(), vars.get_cols1(),
|
||||||
vars.get_cols2(), removed_cols.size(), removed_cols.c_ptr(), result));
|
vars.get_cols2(), removed_cols.size(), removed_cols.c_ptr(), result));
|
||||||
}
|
}
|
||||||
|
|
|
@ -723,7 +723,8 @@ namespace datalog {
|
||||||
instr_join_project(reg_idx rel1, reg_idx rel2, unsigned joined_col_cnt, const unsigned * cols1,
|
instr_join_project(reg_idx rel1, reg_idx rel2, unsigned joined_col_cnt, const unsigned * cols1,
|
||||||
const unsigned * cols2, unsigned removed_col_cnt, const unsigned * removed_cols, reg_idx result)
|
const unsigned * cols2, unsigned removed_col_cnt, const unsigned * removed_cols, reg_idx result)
|
||||||
: m_rel1(rel1), m_rel2(rel2), m_cols1(joined_col_cnt, cols1),
|
: m_rel1(rel1), m_rel2(rel2), m_cols1(joined_col_cnt, cols1),
|
||||||
m_cols2(joined_col_cnt, cols2), m_removed_cols(removed_col_cnt, removed_cols), m_res(result) {}
|
m_cols2(joined_col_cnt, cols2), m_removed_cols(removed_col_cnt, removed_cols), m_res(result) {
|
||||||
|
}
|
||||||
virtual bool perform(execution_context & ctx) {
|
virtual bool perform(execution_context & ctx) {
|
||||||
ctx.make_empty(m_res);
|
ctx.make_empty(m_res);
|
||||||
if (!ctx.reg(m_rel1) || !ctx.reg(m_rel2)) {
|
if (!ctx.reg(m_rel1) || !ctx.reg(m_rel2)) {
|
||||||
|
|
|
@ -318,7 +318,6 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
|
|
||||||
rule_set * mk_magic_sets::operator()(rule_set const & source) {
|
rule_set * mk_magic_sets::operator()(rule_set const & source) {
|
||||||
SASSERT(!m_context.get_model_converter());
|
|
||||||
unsigned init_rule_cnt = source.get_num_rules();
|
unsigned init_rule_cnt = source.get_num_rules();
|
||||||
{
|
{
|
||||||
func_decl_set intentional;
|
func_decl_set intentional;
|
||||||
|
|
|
@ -500,6 +500,11 @@ namespace datalog {
|
||||||
char * reserve = m_data.get_reserve_ptr();
|
char * reserve = m_data.get_reserve_ptr();
|
||||||
unsigned col_cnt = m_column_layout.size();
|
unsigned col_cnt = m_column_layout.size();
|
||||||
for(unsigned i=0; i<col_cnt; i++) {
|
for(unsigned i=0; i<col_cnt; i++) {
|
||||||
|
if (f[i] >= get_signature()[i]) {
|
||||||
|
std::cout << "***************************\n";
|
||||||
|
std::cout << f[i] << " " << get_signature()[i] << "\n";
|
||||||
|
} //the value fits into the table signature
|
||||||
|
|
||||||
SASSERT(f[i]<get_signature()[i]); //the value fits into the table signature
|
SASSERT(f[i]<get_signature()[i]); //the value fits into the table signature
|
||||||
m_column_layout.set(reserve, i, f[i]);
|
m_column_layout.set(reserve, i, f[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,6 +316,12 @@ namespace datalog {
|
||||||
}
|
}
|
||||||
container[i-ofs] = container[i];
|
container[i-ofs] = container[i];
|
||||||
}
|
}
|
||||||
|
if (r_i != removed_col_cnt) {
|
||||||
|
for (unsigned i = 0; i < removed_col_cnt; ++i) {
|
||||||
|
std::cout << removed_cols[i] << " ";
|
||||||
|
}
|
||||||
|
std::cout << " container size: " << n << "\n";
|
||||||
|
}
|
||||||
SASSERT(r_i==removed_col_cnt);
|
SASSERT(r_i==removed_col_cnt);
|
||||||
container.resize(n-removed_col_cnt);
|
container.resize(n-removed_col_cnt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,29 +88,28 @@ namespace datalog {
|
||||||
|
|
||||||
lbool rel_context::saturate() {
|
lbool rel_context::saturate() {
|
||||||
m_context.ensure_closed();
|
m_context.ensure_closed();
|
||||||
|
|
||||||
bool time_limit = m_context.soft_timeout()!=0;
|
bool time_limit = m_context.soft_timeout()!=0;
|
||||||
unsigned remaining_time_limit = m_context.soft_timeout();
|
unsigned remaining_time_limit = m_context.soft_timeout();
|
||||||
unsigned restart_time = m_context.initial_restart_timeout();
|
unsigned restart_time = m_context.initial_restart_timeout();
|
||||||
|
|
||||||
rule_set original_rules(m_context.get_rules());
|
rule_set original_rules(m_context.get_rules());
|
||||||
decl_set original_predicates;
|
decl_set original_predicates;
|
||||||
m_context.collect_predicates(original_predicates);
|
m_context.collect_predicates(original_predicates);
|
||||||
|
|
||||||
m_code.reset();
|
|
||||||
instruction_block termination_code;
|
instruction_block termination_code;
|
||||||
m_ectx.reset();
|
|
||||||
|
|
||||||
lbool result;
|
lbool result;
|
||||||
|
|
||||||
TRACE("dl", m_context.display(tout););
|
TRACE("dl", m_context.display(tout););
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
m_code.reset();
|
||||||
|
m_ectx.reset();
|
||||||
|
termination_code.reset();
|
||||||
m_context.transform_rules();
|
m_context.transform_rules();
|
||||||
if (m_context.canceled()) {
|
if (m_context.canceled()) {
|
||||||
result = l_undef;
|
result = l_undef;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
TRACE("dl", m_context.display(tout););
|
||||||
|
|
||||||
compiler::compile(m_context, m_context.get_rules(), m_code, termination_code);
|
compiler::compile(m_context, m_context.get_rules(), m_code, termination_code);
|
||||||
|
|
||||||
TRACE("dl", m_code.display(*this, tout); );
|
TRACE("dl", m_code.display(*this, tout); );
|
||||||
|
|
|
@ -48,6 +48,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params,
|
||||||
bool use_magic_sets) {
|
bool use_magic_sets) {
|
||||||
|
|
||||||
dl_decl_util decl_util(m);
|
dl_decl_util decl_util(m);
|
||||||
|
random_gen ran(0);
|
||||||
|
|
||||||
context ctx_q(m, fparams);
|
context ctx_q(m, fparams);
|
||||||
params.set_bool("magic_sets_for_queries", use_magic_sets);
|
params.set_bool("magic_sets_for_queries", use_magic_sets);
|
||||||
|
@ -86,7 +87,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params,
|
||||||
warning_msg("cannot get sort size");
|
warning_msg("cannot get sort size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint64 num = rand()%sort_sz;
|
uint64 num = ran()%sort_sz;
|
||||||
app * el_b = decl_util.mk_numeral(num, sig_b[col]);
|
app * el_b = decl_util.mk_numeral(num, sig_b[col]);
|
||||||
f_b.push_back(el_b);
|
f_b.push_back(el_b);
|
||||||
app * el_q = decl_util.mk_numeral(num, sig_q[col]);
|
app * el_q = decl_util.mk_numeral(num, sig_q[col]);
|
||||||
|
@ -112,7 +113,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params,
|
||||||
table_base::iterator fit = table_b.begin();
|
table_base::iterator fit = table_b.begin();
|
||||||
table_base::iterator fend = table_b.end();
|
table_base::iterator fend = table_b.end();
|
||||||
for(; fit!=fend; ++fit) {
|
for(; fit!=fend; ++fit) {
|
||||||
if(rand()%std::max(1u,table_sz/test_count)!=0) {
|
if(ran()%std::max(1u,table_sz/test_count)!=0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
fit->get_fact(tf);
|
fit->get_fact(tf);
|
||||||
|
@ -127,6 +128,7 @@ void dl_query_test(ast_manager & m, smt_params & fparams, params_ref& params,
|
||||||
void dl_query_test_wpa(smt_params & fparams, params_ref& params) {
|
void dl_query_test_wpa(smt_params & fparams, params_ref& params) {
|
||||||
params.set_bool("magic_sets_for_queries", true);
|
params.set_bool("magic_sets_for_queries", true);
|
||||||
ast_manager m;
|
ast_manager m;
|
||||||
|
random_gen ran(0);
|
||||||
reg_decl_plugins(m);
|
reg_decl_plugins(m);
|
||||||
arith_util arith(m);
|
arith_util arith(m);
|
||||||
const char * problem_dir = "C:\\tvm\\src\\z3_2\\debug\\test\\w0.datalog";
|
const char * problem_dir = "C:\\tvm\\src\\z3_2\\debug\\test\\w0.datalog";
|
||||||
|
@ -151,8 +153,8 @@ void dl_query_test_wpa(smt_params & fparams, params_ref& params) {
|
||||||
TRUSTME( ctx.try_get_sort_constant_count(var_sort, var_sz) );
|
TRUSTME( ctx.try_get_sort_constant_count(var_sort, var_sz) );
|
||||||
|
|
||||||
for(unsigned attempt=0; attempt<attempts; attempt++) {
|
for(unsigned attempt=0; attempt<attempts; attempt++) {
|
||||||
unsigned el1 = rand()%var_sz;
|
unsigned el1 = ran()%var_sz;
|
||||||
unsigned el2 = rand()%var_sz;
|
unsigned el2 = ran()%var_sz;
|
||||||
|
|
||||||
expr_ref_vector q_args(m);
|
expr_ref_vector q_args(m);
|
||||||
q_args.push_back(dl_util.mk_numeral(el1, var_sort));
|
q_args.push_back(dl_util.mk_numeral(el1, var_sort));
|
||||||
|
@ -218,6 +220,9 @@ void tst_dl_query() {
|
||||||
|
|
||||||
for(unsigned use_magic_sets=0; use_magic_sets<=1; use_magic_sets++) {
|
for(unsigned use_magic_sets=0; use_magic_sets<=1; use_magic_sets++) {
|
||||||
stopwatch watch;
|
stopwatch watch;
|
||||||
|
if (!(use_restarts == 1 && use_similar == 0 && use_magic_sets == 1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
watch.start();
|
watch.start();
|
||||||
std::cerr << "------- " << (use_restarts ? "With" : "Without") << " restarts -------\n";
|
std::cerr << "------- " << (use_restarts ? "With" : "Without") << " restarts -------\n";
|
||||||
std::cerr << "------- " << (use_similar ? "With" : "Without") << " similar compressor -------\n";
|
std::cerr << "------- " << (use_similar ? "With" : "Without") << " similar compressor -------\n";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue