-
Notifications
You must be signed in to change notification settings - Fork 91
refactor: make the backend implementation more generic #596
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f8452c2 to
6380c34
Compare
Co-authored-by: Benjamin Kaufmann <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Refactors backend handling to support additional backends by targeting a more generic/abstract program interface and refining step vs. grounding boundaries.
Changes:
- Introduces
begin_step(),end_ground(), andend_step()to separate “grounding step” from “solver step”. - Updates output and parsing layers to use the new
end_ground()lifecycle hook. - Refactors solver backend implementation to forward to
Potassco::AbstractProgramand updates theory backend wiring.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/output/src/text.cc | Renames output lifecycle hook from do_end_step to do_end_ground. |
| lib/output/src/backend.cc | Renames lifecycle hook and performs end-of-ground translations for backend output. |
| lib/output/include/clingo/output/backend.hh | Changes TheoryData to reference a TheoryBackend instead of owning it. |
| lib/input/src/parse/aspif.cc | Updates aspif parsing to explicitly manage begin_step / end_ground / end_step. |
| lib/ground/tests/matcher.cc | Updates test stub output implementation for renamed hook. |
| lib/core/include/clingo/core/output.hh | Renames OutputStm::end_step() to end_ground() and updates virtual API. |
| lib/core/include/clingo/core/backend.hh | Splits backend finalization into begin_step, end_ground, and end_step; removes TheoryBackend::end(). |
| lib/control/src/solver.cc | Refactors backend implementation to forward to Potassco::AbstractProgram and adapts solver/aspif integration to new lifecycle. |
| lib/control/src/grounder.cc | Switches grounder to call end_ground() after grounding. |
Comments suppressed due to low confidence (1)
lib/output/src/backend.cc:1623
OutputBackend::do_end_ground()finishes internal translations but never callsProgramBackend::end_ground(). With the new backend interface, this means backends will not be notified when a grounding step completes. Call the underlying backend'send_ground()as part of this method (likely after the translations are flushed).
void do_end_ground() override {
bld_.compute_sccs();
minimize_.tr(bld_);
cond_lit_.tr(bld_);
disjunction_.tr(bld_);
min_.tr(bld_);
max_.tr(bld_);
sum_.tr(bld_);
bld_.tr();
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (1)
lib/output/include/clingo/output/backend.hh:142
- With the switch from
std::unique_ptr<TheoryBackend>toTheoryBackend*,TheoryDatabecomes implicitly copyable again. Copying aTheoryDataduplicates its internal id-generation state and caches, which can lead to duplicated ids being emitted to the same backend. Consider explicitly deleting the copy constructor/assignment (and possibly defining move semantics) to prevent accidental copies.
SymbolStore *store_;
TheoryBackend *backend_;
Util::OutputBuffer buf_;
StringMap strings_;
NumMap nums_;
FunMap funs_;
TupMap tups_;
ElemMap elems_;
AtomMap atoms_;
prg_id_t ids_ = 0;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Pull request overview
Refactors backend handling to support additional backends by targeting a more generic/abstract program interface and refining step vs. grounding boundaries.
Changes
begin_step(),end_ground(), andend_step()to separate “grounding step” from “solver step”.end_ground()lifecycle hook.Potassco::AbstractProgramand updates theory backend wiring.Changed Files
do_end_steptodo_end_ground.TheoryDatato reference aTheoryBackendinstead of owning it.begin_step/end_ground/end_step.OutputStm::end_step()toend_ground()and updates virtual API.begin_step,end_ground, andend_step; removesTheoryBackend::end().Potassco::AbstractProgramand adapts solver/aspif integration to new lifecycle.end_ground()after grounding.