Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/EGraphs/saturation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ function eqsat_search!(

@debug "SEARCHING"
for (rule_idx, rule) in enumerate(theory)
prev_matches = n_matches
@timeit report.to string(rule_idx) begin
prev_matches = n_matches
# don't apply banned rules
Expand All @@ -90,24 +89,23 @@ function eqsat_search!(
ids_left = cached_ids(g, rule.left)
for i in ids_left
cansearch(scheduler, rule_idx, i) || continue
n_matches += rule.ematcher_left!(g, rule_idx, i, rule.stack, ematch_buffer)
inform!(scheduler, rule_idx, i, n_matches)
eclass_matches = rule.ematcher_left!(g, rule_idx, i, rule.stack, ematch_buffer)
n_matches += eclass_matches
inform!(scheduler, rule_idx, i, eclass_matches)
end

if is_bidirectional(rule)
ids_right = cached_ids(g, rule.right)
for i in ids_right
cansearch(scheduler, rule_idx, i) || continue
n_matches += rule.ematcher_right!(g, rule_idx, i, rule.stack, ematch_buffer)
inform!(scheduler, rule_idx, i, n_matches)
eclass_matches = rule.ematcher_right!(g, rule_idx, i, rule.stack, ematch_buffer)
n_matches += eclass_matches
inform!(scheduler, rule_idx, i, eclass_matches)
end
end

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For bidirectional rules, the LHS and RHS may both match the same eclass. In this case inform! would be called twice for the same rule index and the same eclass in the same iteration. None of the implemented schedulers uses this, but it could be unexpected for people implementing their own scheduler.


n_matches - prev_matches > 0 && @debug "Rule $rule_idx: $rule produced $(n_matches - prev_matches) matches"
# if n_matches - prev_matches > 2 && rule_idx == 2
# @debug buffer_readable(g, old_len)
# end
inform!(scheduler, rule_idx, n_matches)
inform!(scheduler, rule_idx, n_matches - prev_matches)
end
end

Expand Down