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

Remove deprecated par loops from reorder and split #184

Merged
merged 1 commit into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
26 changes: 14 additions & 12 deletions src/exo/LoopIR_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __init__(self, proc, loop_stmt):
super().__init__(proc)

def map_s(self, s):
s_type = type(s)
if s is self.stmt:
Check_ReorderLoops(self.orig_proc, self.stmt)

Expand All @@ -190,8 +191,8 @@ def do_bind(x, hi, eff):
# blah
inner_eff = do_bind(s.iter, s.hi, body_eff)
outer_eff = do_bind(s.body[0].iter, s.body[0].hi, inner_eff)
return [LoopIR.ForAll(s.body[0].iter, s.body[0].hi,
[LoopIR.ForAll(s.iter, s.hi,
return [s_type(s.body[0].iter, s.body[0].hi,
[s_type(s.iter, s.hi,
body,
inner_eff, s.srcinfo)],
outer_eff, s.body[0].srcinfo)]
Expand Down Expand Up @@ -248,6 +249,7 @@ def cut_tail_sub(self, srcinfo):
return self._cut_tail_sub

def map_s(self, s):
s_type = type(s)
if s is self.split_loop:
# short-hands for sanity
def boolop(op,lhs,rhs):
Expand Down Expand Up @@ -288,8 +290,8 @@ def do_bind(x, hi, eff):
# pred for inner loop is: 0 <= lo <= lo_rng
inner_eff = do_bind(self.lo_i, lo_rng, body_eff)

return [LoopIR.ForAll(self.hi_i, hi_rng,
[LoopIR.ForAll(self.lo_i, lo_rng,
return [s_type(self.hi_i, hi_rng,
[s_type(self.lo_i, lo_rng,
body,
inner_eff, s.srcinfo)],
s.eff, s.srcinfo)]
Expand Down Expand Up @@ -325,27 +327,27 @@ def do_bind(x, hi, eff):
tail_eff = do_bind(self.cut_i, Ntail, tail_eff)

if self._tail_strategy == 'cut_and_guard':
body = [LoopIR.ForAll(self.cut_i, Ntail,
body = [s_type(self.cut_i, Ntail,
tail_body,
tail_eff, s.srcinfo)]
body_eff= get_effect_of_stmts(body)
cond = boolop(">", Ntail, LoopIR.Const(0, T.int, s.srcinfo))
body_eff= eff_filter(lift_to_eff_expr(cond), body_eff)

loops = [LoopIR.ForAll(self.hi_i, Ncut,
[LoopIR.ForAll(self.lo_i, Q,
loops = [s_type(self.hi_i, Ncut,
[s_type(self.lo_i, Q,
main_body,
lo_eff, s.srcinfo)],
hi_eff, s.srcinfo),
LoopIR.If(cond, body, [], body_eff, s.srcinfo)]

else:
loops = [LoopIR.ForAll(self.hi_i, Ncut,
[LoopIR.ForAll(self.lo_i, Q,
loops = [s_type(self.hi_i, Ncut,
[s_type(self.lo_i, Q,
main_body,
lo_eff, s.srcinfo)],
hi_eff, s.srcinfo),
LoopIR.ForAll(self.cut_i, Ntail,
s_type(self.cut_i, Ntail,
tail_body,
tail_eff, s.srcinfo)]

Expand All @@ -372,8 +374,8 @@ def do_bind(x, hi, eff):
# pred for inner loop is: 0 <= lo <= lo_rng
inner_eff = do_bind(self.lo_i, lo_rng, body_eff)

return [LoopIR.ForAll(self.hi_i, hi_rng,
[LoopIR.ForAll(self.lo_i, lo_rng,
return [s_type(self.hi_i, hi_rng,
[s_type(self.lo_i, lo_rng,
body,
inner_eff, s.srcinfo)],
s.eff, s.srcinfo)]
Expand Down
4 changes: 2 additions & 2 deletions tests/golden/test_new_eff/test_alloc_success.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def foo(N: size, x: R[N, N] @ DRAM):
for j in par(0, N):
for i in par(0, N):
for j in seq(0, N):
for i in seq(0, N):
tmp: R @ DRAM
tmp = x[i, j] * 2.0
x[i, j] = tmp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def foo(N: size, x: R[N, N] @ DRAM):
for j in par(0, N):
for i in par(0, N):
for j in seq(0, N):
for i in seq(0, N):
if 0 < i and i < N - 1 and (0 < j and j < N - 1):
x[i, j] += -1.0 / 4.0 * (x[i - 1, j] + x[i + 1, j] +
x[i, j - 1] + x[i, j + 1])
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
def foo(N: size, x: R[N, N] @ DRAM):
for j in par(0, N):
for i in par(0, N):
for j in seq(0, N):
for i in seq(0, N):
if i > 0 and j > 0:
x[i, j] += -1.0 / 3.0 * (x[i - 1, j] + x[i - 1, j - 1] +
x[i, j - 1])
4 changes: 2 additions & 2 deletions tests/golden/test_new_eff/test_reorder_loops_success.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
def foo(N: size, x: R[N, N] @ DRAM):
for j in par(0, N):
for i in par(0, N):
for j in seq(0, N):
for i in seq(0, N):
x[i, j] = x[i, j] * 2.0