Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
cdfba77
Add partitioning of rules by shared EClassesToSearch for optimized ru…
jonathanvdc Nov 8, 2025
7c70f35
Refine type casting for EClassesToSearch in EClassSearcher rule colle…
jonathanvdc Nov 8, 2025
de9013a
Refactor type handling in EClassSearcher for improved rule processing
jonathanvdc Nov 8, 2025
0d196ff
Refactor command searcher construction logic
jonathanvdc Nov 8, 2025
9079bf4
Introduce SimplifiedAddCommandInstantiator to reduce closure allocations
jonathanvdc Nov 8, 2025
1131915
Add CommandQueue.highestDependencyForNodes method to efficiently comp…
jonathanvdc Nov 8, 2025
f286344
Temporarily disable search-loop interchange optimization in SearchAnd…
jonathanvdc Nov 8, 2025
c1e0661
Optimize CommandQueue.optimizeAdds
jonathanvdc Nov 8, 2025
9e1bc7f
Eliminate legacy Command simplification logic
jonathanvdc Nov 8, 2025
286df58
Restore parallelization across rules
jonathanvdc Nov 8, 2025
60b84b3
Replace Command class hierarchy with CommandSchedule
jonathanvdc Nov 9, 2025
14e1095
Fix additions method to handle empty batchZero case
jonathanvdc Nov 9, 2025
e7043f2
Add unit tests for CommandScheduleBuilder functionality
jonathanvdc Nov 9, 2025
cd28047
Add tests for addSimplifiedReal method in CommandScheduleBuilder
jonathanvdc Nov 9, 2025
1fec937
Add test for addSimplifiedReal method to ensure batch layering stabil…
jonathanvdc Nov 9, 2025
ff50e1a
Refactor addSimplifiedReal method documentation for clarity and consi…
jonathanvdc Nov 9, 2025
91aaa34
Rename test method for addSimplifiedReal to improve clarity
jonathanvdc Nov 9, 2025
fbe7d1d
Define custom IntRef for cross-version compatibility
jonathanvdc Nov 9, 2025
2daf835
Replace IntRef instantiation with new keyword for consistency
jonathanvdc Nov 9, 2025
448ff74
Use new keyword for IdentityHashMap instantiation for consistency
jonathanvdc Nov 9, 2025
66bf25a
Refactor import statements in EGraphWithMetadata for consistency
jonathanvdc Nov 9, 2025
90eaf58
Use Function interface for computeIfAbsent in ConcurrentCommandSchedu…
jonathanvdc Nov 9, 2025
bfcadf6
Refactor import statements in EGraphWithRoot
jonathanvdc Nov 9, 2025
2501ab0
Refactor import statements in EGraphWithRecordedApplications and EGra…
jonathanvdc Nov 9, 2025
a2a94d8
Refactor import statements in ApplierOps
jonathanvdc Nov 9, 2025
500718e
Make IntRef class final
jonathanvdc Nov 9, 2025
a015f0e
Refactor processBlock to process stripes instead of contiguous blocks
jonathanvdc Nov 9, 2025
ba8a360
Enable search loop interchange
jonathanvdc Nov 9, 2025
2d6239d
Enhance users method to handle nodes without slots
jonathanvdc Nov 9, 2025
a82ee38
Refactor compute method to implement worklist algorithm for node proc…
jonathanvdc Nov 9, 2025
b2516fe
Implement readiness-driven worklist for node processing in AnalysisUp…
jonathanvdc Nov 9, 2025
800a4cd
Remove unnecessary parameter from processPending method in AnalysisUp…
jonathanvdc Nov 9, 2025
c42c29c
Remove unnecessary argument from processPending call in AnalysisMetadata
jonathanvdc Nov 9, 2025
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
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package foresight.eqsat.examples.arithWithLang

import foresight.eqsat.{EClassCall, MixedTree, Slot}
import foresight.eqsat.commands.Command
import foresight.eqsat.commands.CommandScheduleBuilder
import foresight.eqsat.extraction.ExtractionAnalysis
import foresight.eqsat.lang.Language
import foresight.eqsat.immutable.{EGraphLike, EGraphWithMetadata, EGraph}
import foresight.eqsat.immutable.{EGraph, EGraphLike, EGraphWithMetadata}
import foresight.eqsat.rewriting.Applier
import foresight.eqsat.rewriting.patterns.PatternMatch

Expand All @@ -26,7 +26,7 @@ object ApplierOps {
destination: PatternVar): Applier[ArithIR, PatternMatch[ArithIR], EGraphWithMetadata[ArithIR, EGraphT]] = {

new Applier[ArithIR, PatternMatch[ArithIR], EGraphWithMetadata[ArithIR, EGraphT]] {
override def apply(m: PatternMatch[ArithIR], egraph: EGraphWithMetadata[ArithIR, EGraphT]): Command[ArithIR] = {
override def apply(m: PatternMatch[ArithIR], egraph: EGraphWithMetadata[ArithIR, EGraphT], builder: CommandScheduleBuilder[ArithIR]): Unit = {
val extractedTree = ExtractionAnalysis.smallest[ArithIR].extractor(m(source.variable), egraph)
val extractedExpr = L.fromTree[EClassCall](extractedTree)

Expand All @@ -47,7 +47,7 @@ object ApplierOps {

val substituted = subst(extractedExpr)
val newMatch = m.copy(varMapping = m.varMapping + (destination.variable -> L.toTree[EClassCall](substituted)))
applier.apply(newMatch, egraph)
applier.apply(newMatch, egraph, builder)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package foresight.eqsat.examples.arith

import foresight.eqsat.commands.Command
import foresight.eqsat.commands.CommandScheduleBuilder
import foresight.eqsat.extraction.ExtractionAnalysis
import foresight.eqsat.readonly.{EGraphWithMetadata, EGraph}
import foresight.eqsat.readonly.{EGraph, EGraphWithMetadata}
import foresight.eqsat.rewriting.Applier
import foresight.eqsat.rewriting.patterns.{Pattern, PatternMatch}
import foresight.eqsat._
Expand All @@ -24,7 +24,7 @@ object ApplierOps {
destination: Pattern.Var): Applier[ArithIR, PatternMatch[ArithIR], EGraphWithMetadata[ArithIR, EGraphT]] = {

new Applier[ArithIR, PatternMatch[ArithIR], EGraphWithMetadata[ArithIR, EGraphT]] {
override def apply(m: PatternMatch[ArithIR], egraph: EGraphWithMetadata[ArithIR, EGraphT]): Command[ArithIR] = {
override def apply(m: PatternMatch[ArithIR], egraph: EGraphWithMetadata[ArithIR, EGraphT], builder: CommandScheduleBuilder[ArithIR]): Unit = {
val extracted = ExtractionAnalysis.smallest[ArithIR].extractor[EGraphT](m(source), egraph)

def subst(tree: Tree[ArithIR]): MixedTree[ArithIR, EClassCall] = {
Expand All @@ -37,7 +37,7 @@ object ApplierOps {

val substituted = subst(extracted)
val newMatch = m.copy(varMapping = m.varMapping + (destination -> substituted))
applier.apply(newMatch, egraph)
applier.apply(newMatch, egraph, builder)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

package foresight.eqsat.examples.liar

import foresight.eqsat.commands.Command
import foresight.eqsat.commands.CommandScheduleBuilder
import foresight.eqsat.extraction.ExtractionAnalysis
import foresight.eqsat.immutable.{EGraphLike, EGraphWithMetadata, EGraph}
import foresight.eqsat.immutable.{EGraph, EGraphLike, EGraphWithMetadata}
import foresight.eqsat.rewriting.Applier
import foresight.eqsat.rewriting.patterns.{Pattern, PatternApplier, PatternMatch}
import foresight.eqsat._
Expand All @@ -25,7 +25,7 @@ object ApplierOps {
destination: Pattern.Var): Applier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]] = {

new Applier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]] {
override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT]): Command[ArrayIR] = {
override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT], builder: CommandScheduleBuilder[ArrayIR]): Unit = {
val extracted = ExtractionAnalysis.smallest[ArrayIR].extractor[EGraphT](m(source), egraph)

def typeOf(tree: MixedTree[ArrayIR, EClassCall]): MixedTree[Type, EClassCall] = {
Expand All @@ -45,7 +45,7 @@ object ApplierOps {

val substituted = subst(extracted)
val newMatch = m.copy(varMapping = m.varMapping + (destination -> substituted))
applier.apply(newMatch, egraph)
applier.apply(newMatch, egraph, builder)
}
}
}
Expand All @@ -62,10 +62,12 @@ object ApplierOps {
*/
def typeChecked: Applier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]] = {
new Applier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]] {
override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT]): Command[ArrayIR] = {
override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT], builder: CommandScheduleBuilder[ArrayIR]): Unit = {
val tree = applier.instantiate(m)
inferType(tree.mapAtoms(_.asInstanceOf[EClassCall]), egraph)
Command.equivalenceSimplified(EClassSymbol.real(m.root), tree, egraph)
val realTree = tree.mapAtoms(_.asInstanceOf[EClassCall])
inferType(realTree, egraph)
val c = builder.addSimplifiedReal(realTree, egraph)
builder.unionSimplified(EClassSymbol.real(m.root), c, egraph)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package foresight.eqsat.examples.liar

import foresight.eqsat.commands.Command
import foresight.eqsat.parallel.ParallelMap
import foresight.eqsat.commands.CommandScheduleBuilder
import foresight.eqsat.rewriting.SearcherContinuation.Continuation
import foresight.eqsat.rewriting.patterns.{CompiledPattern, Pattern, PatternMatch}
import foresight.eqsat.rewriting.{Applier, ReversibleApplier, ReversibleSearcher, Searcher, SearcherContinuation}
import foresight.eqsat.rewriting.{Applier, ReversibleApplier, Searcher, SearcherContinuation}
import foresight.eqsat.MixedTree
import foresight.eqsat.immutable.{EGraph, EGraphLike, EGraphWithMetadata}

Expand Down Expand Up @@ -54,16 +53,16 @@ object TypeRequirements {
}

final case class ApplierWithRequirements[EGraphT <: EGraphLike[ArrayIR, EGraphT] with EGraph[ArrayIR]](applier: Applier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]],
types: Map[Pattern.Var, MixedTree[ArrayIR, Pattern.Var]])
types: Map[Pattern.Var, MixedTree[ArrayIR, Pattern.Var]])
extends ReversibleApplier[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]] {

// Precompile the patterns.
private val compiledPatterns = types.map {
case (v, t) => v -> t.compiled[EGraph[ArrayIR]]
}

override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT]): Command[ArrayIR] = {
applier.flatMap((m2: PatternMatch[ArrayIR], egraph2: EGraphWithMetadata[ArrayIR, EGraphT]) => checkMatch(m2, compiledPatterns, egraph2)).apply(m, egraph)
override def apply(m: PatternMatch[ArrayIR], egraph: EGraphWithMetadata[ArrayIR, EGraphT], builder: CommandScheduleBuilder[ArrayIR]): Unit = {
applier.flatMap((m2: PatternMatch[ArrayIR], egraph2: EGraphWithMetadata[ArrayIR, EGraphT]) => checkMatch(m2, compiledPatterns, egraph2)).apply(m, egraph, builder)
}

override def tryReverse: Option[Searcher[ArrayIR, PatternMatch[ArrayIR], EGraphWithMetadata[ArrayIR, EGraphT]]] = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package foresight.eqsat.examples.sdql

import foresight.eqsat.commands.Command
import foresight.eqsat.commands.CommandScheduleBuilder
import foresight.eqsat.extraction.ExtractionAnalysis
import foresight.eqsat.rewriting.Applier
import foresight.eqsat.rewriting.patterns.{Pattern, PatternMatch}
import foresight.eqsat.immutable.{EGraphLike, EGraphWithMetadata, EGraph}
import foresight.eqsat.immutable.{EGraph, EGraphLike, EGraphWithMetadata}
import foresight.eqsat._

object ApplierOps {
Expand All @@ -24,7 +24,7 @@ object ApplierOps {
destination: Pattern.Var): Applier[SdqlIR, PatternMatch[SdqlIR], EGraphWithMetadata[SdqlIR, EGraphT]] = {

new Applier[SdqlIR, PatternMatch[SdqlIR], EGraphWithMetadata[SdqlIR, EGraphT]] {
override def apply(m: PatternMatch[SdqlIR], egraph: EGraphWithMetadata[SdqlIR, EGraphT]): Command[SdqlIR] = {
override def apply(m: PatternMatch[SdqlIR], egraph: EGraphWithMetadata[SdqlIR, EGraphT], builder: CommandScheduleBuilder[SdqlIR]): Unit = {
val extracted = ExtractionAnalysis.smallest[SdqlIR].extractor[EGraphT](m(source), egraph)

def subst(tree: Tree[SdqlIR]): MixedTree[SdqlIR, EClassCall] = {
Expand All @@ -37,7 +37,7 @@ object ApplierOps {

val substituted = subst(extracted)
val newMatch = m.copy(varMapping = m.varMapping + (destination -> substituted))
applier.apply(newMatch, egraph)
applier.apply(newMatch, egraph, builder)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion foresight/src/main/scala/foresight/eqsat/EClassCall.scala
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ sealed trait EClassSymbol {
* val realCall = v.reify(Map(v -> call)) // returns call
* }}}
*/
final def reify(reification: collection.Map[EClassSymbol.Virtual, EClassCall]): EClassCall = this match {
final def reify(reification: EClassSymbol.Virtual => EClassCall): EClassCall = this match {
case call: EClassCall => call
case virtual: EClassSymbol.Virtual => reification(virtual)
}
Expand Down
6 changes: 3 additions & 3 deletions foresight/src/main/scala/foresight/eqsat/ENode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ final class ENode[+NodeT] private (
result
}

override def reify(reification: collection.Map[EClassSymbol.Virtual, EClassCall]): ENode[NodeT] = this
override def reify(reification: EClassSymbol.Virtual => EClassCall): ENode[NodeT] = this
}

/**
Expand Down Expand Up @@ -504,7 +504,7 @@ sealed trait ENodeSymbol[+NodeT] {
* @param reification Mapping from virtual e-class symbols to concrete [[EClassCall]]s.
* @return An [[ENode]] with all arguments fully resolved.
*/
def reify(reification: collection.Map[EClassSymbol.Virtual, EClassCall]): ENode[NodeT]
def reify(reification: EClassSymbol.Virtual => EClassCall): ENode[NodeT]

/**
* Creates a copy of this symbol with the given arguments.
Expand Down Expand Up @@ -583,7 +583,7 @@ object ENodeSymbol {
* val node: ENode[MyOp] = symbol.reify(Map(v1 -> call1))
* }}}
*/
override def reify(reification: collection.Map[EClassSymbol.Virtual, EClassCall]): ENode[NodeT] = {
override def reify(reification: EClassSymbol.Virtual => EClassCall): ENode[NodeT] = {
val reifiedArgs = args.map(_.reify(reification))
ENode(nodeType, definitions, uses, reifiedArgs)
}
Expand Down
148 changes: 0 additions & 148 deletions foresight/src/main/scala/foresight/eqsat/commands/AddManyCommand.scala

This file was deleted.

Loading