Skip to content
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

Abstract interpretation based analysis #578

Open
wants to merge 64 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
6b006c0
Abstract interpretation based analysis rewrite
yamaguchi1024 Jan 6, 2025
c6d1470
Support scalar value propagation
yamaguchi1024 Jun 25, 2024
f5d0bdc
Add support for configs
yamaguchi1024 Jan 6, 2025
2903424
fix a bug
yamaguchi1024 Jun 26, 2024
db1a1ff
make LoopIR_dataflow return statements as well
yamaguchi1024 Jul 3, 2024
f2e8d02
slowly converting analysis
yamaguchi1024 Jan 6, 2025
aa24ba7
WIP, add Call and WindowStmt to dataflow ir
yamaguchi1024 Jul 5, 2024
e0041d8
fix the fixpoint
yamaguchi1024 Jul 22, 2024
8e30955
support windowexpr to some capacity
yamaguchi1024 Jul 22, 2024
022a91d
Properly implement fixpoint for DataflowIR.Call
yamaguchi1024 Jan 6, 2025
96e81d3
Check_Bounds
yamaguchi1024 Jul 23, 2024
132d945
Check_IsIdempotent
yamaguchi1024 Jul 23, 2024
0fbdcc8
support Check_ExprBound
yamaguchi1024 Jul 23, 2024
a5a7764
Check_BufferReduceOnly
yamaguchi1024 Jul 23, 2024
f52e307
Check_Access_In_Window
yamaguchi1024 Jul 23, 2024
02a53b2
Check_ExprEqvInContext
yamaguchi1024 Jul 23, 2024
58bd6fc
Check_IsDeadAfter
yamaguchi1024 Jul 23, 2024
81bcd9e
Check_CodeIsDead
yamaguchi1024 Jul 23, 2024
e508308
everything other than Check_DeleteConfigWrite can be value insensitive
yamaguchi1024 Jul 23, 2024
bb3dc75
Add golden output to dataflow tests
yamaguchi1024 Jul 23, 2024
7274ec3
delete unused Check_CodeIsDead
yamaguchi1024 Jul 24, 2024
b97a28a
delete config passes all tests
yamaguchi1024 Jul 25, 2024
334b543
small fix
yamaguchi1024 Jul 25, 2024
c1e943d
fix bugs
yamaguchi1024 Jul 26, 2024
2792f53
Define custom absval instead of using aexprs
yamaguchi1024 Aug 13, 2024
58a3074
Write the lowering to aexpr
yamaguchi1024 Aug 15, 2024
69f4ff9
small fix
yamaguchi1024 Aug 15, 2024
c5a1b7c
tmp
yamaguchi1024 Aug 15, 2024
9544002
Use more of the existing infra
yamaguchi1024 Aug 15, 2024
19f1662
revert adding top to aexpr
yamaguchi1024 Aug 15, 2024
91bf5d1
clean up
yamaguchi1024 Aug 15, 2024
6784e4f
clean up
yamaguchi1024 Aug 16, 2024
88e5225
add rewrite_expr test
yamaguchi1024 Aug 16, 2024
3443428
runtime
yamaguchi1024 Aug 17, 2024
079f852
delete simplify
yamaguchi1024 Aug 18, 2024
cffead2
skip Check_ExtendEqv if no configuration exists
yamaguchi1024 Aug 18, 2024
5f9a024
clean up and add tests
yamaguchi1024 Aug 18, 2024
a497850
Add builtin tests
yamaguchi1024 Aug 18, 2024
b0aae34
delete outdated code and add boolean binop tests
yamaguchi1024 Aug 18, 2024
ecdbafd
Fix Gilbert's catch on the value query
yamaguchi1024 Aug 20, 2024
966a622
Revert "Fix Gilbert's catch on the value query"
yamaguchi1024 Aug 20, 2024
7322f40
cleanup
yamaguchi1024 Aug 20, 2024
90ad88c
rename test_new_eff to test_analysis
yamaguchi1024 Aug 20, 2024
3ee8b28
Add more tests
yamaguchi1024 Aug 20, 2024
ed1284c
SSA dataflow IR
yamaguchi1024 Aug 26, 2024
9e008e7
ssa done modulo bugs
yamaguchi1024 Aug 26, 2024
93e99ea
fix printing
yamaguchi1024 Aug 26, 2024
0812b0e
fix a small bug
yamaguchi1024 Aug 28, 2024
0a4bb07
tmp
yamaguchi1024 Sep 19, 2024
1536b91
wip
yamaguchi1024 Jan 6, 2025
5f12ca1
refactoring
yamaguchi1024 Jan 6, 2025
44c84bc
merge
yamaguchi1024 Sep 28, 2024
f2fe6b6
clean up a bit
yamaguchi1024 Sep 29, 2024
1233387
whatever progress
yamaguchi1024 Jan 6, 2025
cd7ed77
fix basic import errors
yamaguchi1024 Jan 6, 2025
547a973
fix
yamaguchi1024 Jan 6, 2025
20fb4b9
Fix several tests
yamaguchi1024 Jan 14, 2025
a7b0352
Finished refactoring until substitution. Will look into widening tomo…
yamaguchi1024 Jan 29, 2025
903ab79
refactoring substitution seems working for now
yamaguchi1024 Jan 31, 2025
b3e47f7
widening kinda works
yamaguchi1024 Feb 2, 2025
5eb5f85
fix the crossing intersection value issue
yamaguchi1024 Feb 4, 2025
71442c6
fix the loop lo bug
yamaguchi1024 Feb 4, 2025
2bc7035
widening limitation
yamaguchi1024 Feb 4, 2025
8f2fb80
fix regine_regions for paths
yamaguchi1024 Feb 4, 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
11 changes: 10 additions & 1 deletion src/exo/API.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
from .frontend.parse_fragment import parse_fragment
from .frontend.pattern_match import match_pattern
from .core.prelude import *
from .rewrite.new_eff import Check_Aliasing
from .rewrite.analysis import Check_Aliasing
from .rewrite.dataflow import dataflow_analysis

# Moved to new file
from .core.proc_eqv import decl_new_proc, derive_proc, assert_eqv_proc, check_eqv_proc
Expand Down Expand Up @@ -368,3 +369,11 @@ def is_eq(self, proc: "Procedure"):

def _root(self):
return IC.Cursor.create(self._loopir_proc)

def dataflow(self, s=[]):
stmts = [s] if isinstance(s, C.StmtCursor) else s
loopir_stmts = []
for s in stmts:
loopir_stmts.append(s._impl._node)

return dataflow_analysis(self._loopir_proc, loopir_stmts)
2 changes: 1 addition & 1 deletion src/exo/backend/parallel_analysis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ..core.LoopIR import LoopIR, LoopIR_Rewrite

from ..rewrite.new_eff import Check_ParallelizeLoop
from ..rewrite.analysis import Check_ParallelizeLoop


class ParallelAnalysis(LoopIR_Rewrite):
Expand Down
7 changes: 7 additions & 0 deletions src/exo/core/LoopIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,13 @@ def get_reads_of_stmts(stmts):
return gr.reads


def get_readconfigs_expr(exprs):
gr = GetReadConfigs()
for e in exprs:
gr.do_e(e)
return gr.readconfigs


def get_readconfigs(stmts):
gr = GetReadConfigs()
for stmt in stmts:
Expand Down
11 changes: 7 additions & 4 deletions src/exo/frontend/typecheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ def check_single_stmt(self, stmt):
# Check that field is in config
if not stmt.config.has_field(stmt.field):
self.err(
stmt.field,
f"expected '{stmt.field}' to be a field "
stmt,
f"expected '{stmt.field}' to be a field "
f"in config '{stmt.config.name()}'",
)
return []

ftyp = stmt.config.lookup_type(stmt.field)
rhs = self.check_e(
Expand Down Expand Up @@ -593,11 +594,13 @@ def check_e(self, e, is_index=False):
elif isinstance(e, UAST.ReadConfig):
if not e.config.has_field(e.field):
self.err(
e.field,
e,
f"'{e.field}' has to be a field in config '{e.config.name()}'",
)
ftyp = T.err
else:
ftyp = e.config.lookup_type(e.field)

ftyp = e.config.lookup_type(e.field)
return LoopIR.ReadConfig(e.config, e.field, ftyp, e.srcinfo)
else:
assert False, "not a LoopIR in check_e"
Expand Down
31 changes: 26 additions & 5 deletions src/exo/rewrite/LoopIR_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
get_writes_of_stmts,
is_const_zero,
)
from .new_eff import (
from .analysis import (
SchedulingError,
Check_ReorderStmts,
Check_ReorderLoops,
Expand Down Expand Up @@ -1042,12 +1042,16 @@ def DoCallSwap(call_cursor, new_subproc):

s_new = call_s.update(f=new_subproc)
ir = call_cursor.get_root()
mod_cfg = Check_ExtendEqv(ir, [call_s], [s_new], configkeys)
ir, fwd = call_cursor._child_node("f")._replace(new_subproc)
new_ir, fwd = call_cursor._child_node("f")._replace(new_subproc)

Check_Aliasing(ir)
if len(configkeys) != 0:
configkeys = Check_ExtendEqv(
ir, new_ir, [call_cursor._node], [fwd(call_cursor)._node], configkeys
)

return ir, fwd, mod_cfg
Check_Aliasing(new_ir)

return new_ir, fwd, configkeys


def DoInlineWindow(window_cursor):
Expand Down Expand Up @@ -1236,6 +1240,13 @@ def match_parent(c1, c2):

def DoRewriteExpr(expr_cursor, new_expr):
proc = expr_cursor.get_root()

if (
not expr_cursor._node.type.is_indexable()
and not expr_cursor._node.type.is_bool()
):
raise SchedulingError("Cannot rewrite non-index expressions")

s = get_enclosing_stmt_cursor(expr_cursor)._node
Check_ExprEqvInContext(proc, expr_cursor._node, [s], new_expr, [s])
return expr_cursor._replace(new_expr)
Expand Down Expand Up @@ -2778,10 +2789,20 @@ def err_handler(_, msg):
return ir, fwd


def DoDeleteConfig(proc_cursor, config_cursor):
eq_mod_config = Check_DeleteConfigWrite(
proc_cursor._node, [config_cursor.prev()._node, config_cursor._node]
)
p, fwd = config_cursor._delete()
return p, fwd, eq_mod_config


"""
def DoDeleteConfig(proc_cursor, config_cursor):
eq_mod_config = Check_DeleteConfigWrite(proc_cursor._node, [config_cursor._node])
p, fwd = config_cursor._delete()
return p, fwd, eq_mod_config
"""


def DoDeletePass(proc):
Expand Down
2 changes: 1 addition & 1 deletion src/exo/rewrite/LoopIR_unification.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
)
from .LoopIR_scheduling import SchedulingError
from ..core.prelude import *
from .new_eff import Check_Aliasing
from .analysis import Check_Aliasing
import exo.core.internal_cursors as ic


Expand Down
Loading
Loading