Skip to content

Commit 8556969

Browse files
committed
add warning if no output exists
1 parent 1a08f87 commit 8556969

File tree

3 files changed

+33
-3
lines changed

3 files changed

+33
-3
lines changed

godel-script/godel-frontend/src/engine.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,12 @@ void engine::run_souffle(const std::string& souffle_content,
400400
argv.push_back("--index-stats");
401401
}
402402

403+
// magic set, it's not suggested to use it on all the predicates
404+
// argv.push_back("--magic-transform=*");
405+
406+
// need latest version of souffle to make it more efficient
407+
// argv.push_back("--jobs=4");
408+
403409
// enable souffle auto schedule, for experimental use only
404410
// argv.push_back("--auto-schedule=souffle.prof.log");
405411

godel-script/godel-frontend/src/ir/ir_gen.cpp

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -538,11 +538,23 @@ void ir_gen::emit_schema_get_field() {
538538
);
539539
call->add_arg(lir::inst_value_t::variable("self"));
540540
call->add_arg(lir::inst_value_t::default_value());
541+
542+
// enable particular index
543+
// for z in pred(_, _, z, _, _)
544+
// it's better to use pred(x, y, z, _, _) to auto generate index in souffle
545+
int count = 0;
546+
bool reach_field = false;
541547
for(const auto& f : sc.second.ordered_fields) {
542-
call->add_arg(f==field?
543-
lir::inst_value_t::variable("ret?result"):
544-
lir::inst_value_t::default_value()
548+
if (f == field) {
549+
reach_field = true;
550+
}
551+
call->add_arg(f==field
552+
? lir::inst_value_t::variable("ret?result")
553+
: reach_field
554+
? lir::inst_value_t::default_value()
555+
: lir::inst_value_t::variable("?" + std::to_string(count))
545556
);
557+
++count;
546558
}
547559
rule_impl->get_block()->add_new_content(call);
548560
}
@@ -1102,6 +1114,16 @@ void ir_gen::report_ignored_DO_schema_data_constraint() {
11021114
err.warn_ignored_DO_schema(ignored_DO_schema);
11031115
}
11041116

1117+
void ir_gen::report_no_output_predicate() {
1118+
if (irc.souffle_output.size() || irc.annotated_output.size()) {
1119+
return;
1120+
}
1121+
err.warn(
1122+
"no output predicate is found, "
1123+
"execution will not generate any outputs or output files."
1124+
);
1125+
}
1126+
11051127
bool ir_gen::visit_number_literal(number_literal* node) {
11061128
value_stack.push_back({
11071129
data_kind::literal,
@@ -2488,6 +2510,7 @@ void ir_gen::generate(const cli::configure& config, ast_root* root) {
24882510
root->accept(this);
24892511

24902512
report_ignored_DO_schema_data_constraint();
2513+
report_no_output_predicate();
24912514
}
24922515

24932516
}

godel-script/godel-frontend/src/ir/ir_gen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ class ir_gen: public ast_visitor {
202202
private:
203203
std::unordered_set<std::string> ignored_DO_schema;
204204
void report_ignored_DO_schema_data_constraint();
205+
void report_no_output_predicate();
205206

206207
private:
207208
bool visit_number_literal(number_literal*) override;

0 commit comments

Comments
 (0)