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

Renamed ForSeqCursor to ForCursor #31

Merged
merged 3 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion src/common/codegen_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def expr_visitor(proc, expr):
return proc

for stmt in body:
if isinstance(stmt, ForSeqCursor):
if isinstance(stmt, ForCursor):
proc = bind_builtins_args(proc, stmt.body(), precision)
elif isinstance(stmt, IfCursor):
proc = bind_builtins_args(proc, stmt.body(), precision)
Expand Down
34 changes: 17 additions & 17 deletions src/common/composed_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def expr_list_to_string(expr_list, subst):


def get_enclosing_scope(cursor, scope_type):
if not scope_type in (ForSeqCursor, IfCursor):
raise BLAS_SchedulingError("scope type must be ForSeqCursor or IfCursor")
if not scope_type in (ForCursor, IfCursor):
raise BLAS_SchedulingError("scope type must be ForCursor or IfCursor")

cursor = cursor.parent()
while not isinstance(cursor, (scope_type, InvalidCursor)):
Expand All @@ -72,7 +72,7 @@ def get_enclosing_scope(cursor, scope_type):


def get_enclosing_loop(cursor):
return get_enclosing_scope(cursor, ForSeqCursor)
return get_enclosing_scope(cursor, ForCursor)


def get_enclosing_if(cursor):
Expand All @@ -90,7 +90,7 @@ def get_statement(cursor):
def is_already_divided(loop_cursor, div_factor):
return (
len(loop_cursor.body()) == 1
and isinstance(loop_cursor.body()[0], ForSeqCursor)
and isinstance(loop_cursor.body()[0], ForCursor)
and isinstance(loop_cursor.body()[0].hi(), LiteralCursor)
and loop_cursor.body()[0].hi().value() == div_factor
)
Expand Down Expand Up @@ -161,9 +161,9 @@ def parallelize_and_lift_alloc(proc, alloc_cursor, n_lifts=1):

@dataclass
class auto_divide_loop_cursors:
outer_loop_cursor: ForSeqCursor
inner_loop_cursor: ForSeqCursor
tail_loop_cursor: ForSeqCursor
outer_loop_cursor: ForCursor
inner_loop_cursor: ForCursor
tail_loop_cursor: ForCursor


def auto_divide_loop(proc, loop_cursor, div_const, tail="guard", perfect=False):
Expand Down Expand Up @@ -223,9 +223,9 @@ def vectorize_to_loops(proc, loop_cursor, vec_width, memory_type, precision):
lhs(i + delta) = (e_0(i + delta), e_1(i + delta), ..., e_n(i + delta));
"""

if not isinstance(loop_cursor, ForSeqCursor):
if not isinstance(loop_cursor, ForCursor):
raise BLAS_SchedulingError(
"vectorize_to_loops loop_cursor must be a ForSeqCursor"
"vectorize_to_loops loop_cursor must be a ForCursor"
)

loop_cursor = proc.forward(loop_cursor)
Expand Down Expand Up @@ -265,7 +265,7 @@ def fission_stmts(proc, body, depth=1):
forwarded_stmt = proc.forward(stmt)
if isinstance(forwarded_stmt, IfCursor):
proc = fission_stmts(proc, forwarded_stmt.body(), depth + 1)
elif isinstance(forwarded_stmt, ForSeqCursor):
elif isinstance(forwarded_stmt, ForCursor):
raise BLAS_SchedulingError("This is an inner loop vectorizer")
forwarded_stmt = body_list[-1]
stmts.append(forwarded_stmt)
Expand Down Expand Up @@ -387,7 +387,7 @@ def vectorize_stmt(proc, stmt, depth=1):
if isinstance(forwarded_stmt, IfCursor):
continue
inner_loop = get_enclosing_loop(forwarded_stmt)
if isinstance(inner_loop, ForSeqCursor):
if isinstance(inner_loop, ForCursor):
assert len(inner_loop.body()) == 1
proc = vectorize_stmt(proc, inner_loop.body()[0])

Expand All @@ -411,8 +411,8 @@ def interleave_execution(proc, loop_cursor, interleave_factor):
S3
... x interleave_factor
"""
if not isinstance(loop_cursor, ForSeqCursor):
raise BLAS_SchedulingError("vectorize loop_cursor must be a ForSeqCursor")
if not isinstance(loop_cursor, ForCursor):
raise BLAS_SchedulingError("vectorize loop_cursor must be a ForCursor")

if interleave_factor == 1:
return proc
Expand Down Expand Up @@ -535,8 +535,8 @@ def parallelize_reduction(
Returns: (proc, allocation cursors)
"""
# Check arguments pre-condition
if not isinstance(loop_cursor, ForSeqCursor):
raise BLAS_SchedulingError("vectorize loop_cursor must be a ForSeqCursor")
if not isinstance(loop_cursor, ForCursor):
raise BLAS_SchedulingError("vectorize loop_cursor must be a ForCursor")

if not isinstance(parallel_factor, int):
raise BLAS_SchedulingError("parallel_factor must be an integer")
Expand Down Expand Up @@ -657,8 +657,8 @@ def vectorize(
vectorize_tail=True,
):
# Check pre-conditions
if not isinstance(loop_cursor, ForSeqCursor):
raise BLAS_SchedulingError("Expected loop_cursor to be a ForSeqCursor")
if not isinstance(loop_cursor, ForCursor):
raise BLAS_SchedulingError("Expected loop_cursor to be a ForCursor")

if not isinstance(vec_width, int) and vec_width > 1:
raise BLAS_SchedulingError("Expected vec_width to be an integer > 1")
Expand Down
4 changes: 2 additions & 2 deletions src/common/introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_statemnts_helper(body):
if isinstance(stmt, IfCursor):
yield from get_statemnts_helper(stmt.body())
yield from get_statemnts_helper(stmt.orelse())
elif isinstance(stmt, ForSeqCursor):
elif isinstance(stmt, ForCursor):
yield from get_statemnts_helper(stmt.body())

return get_statemnts_helper(proc.body())
Expand Down Expand Up @@ -58,7 +58,7 @@ def get_stmt_dependencies(stmt):
elif isinstance(stmt, IfCursor):
yield from get_expr_dependencies(stmt.cond())
yield from get_stmt_dependencies(stmt.body())
elif isinstance(stmt, ForSeqCursor):
elif isinstance(stmt, ForCursor):
yield from get_expr_dependencies(stmt.hi())
yield from get_stmt_dependencies(stmt.body())
elif isinstance(stmt, AllocCursor):
Expand Down
14 changes: 7 additions & 7 deletions src/gemmini/exo_gemmini_matmul.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def sink_if(p, if_cursor):
s1
"""
while True:
if not isinstance(if_cursor.body()[0], pc.ForSeqCursor):
if not isinstance(if_cursor.body()[0], pc.ForCursor):
break
else:
p = lift_scope(p, if_cursor.body()[0])
Expand All @@ -157,7 +157,7 @@ def add_guard(p, c):
c = p.forward(c)
while True:
c = c.parent()
if not isinstance(c, pc.ForSeqCursor):
if not isinstance(c, pc.ForCursor):
break
try:
hi = c.hi().value()
Expand Down Expand Up @@ -185,7 +185,7 @@ def remove_redundant_loops(p, c, num=0):
cur_depth = 0
while True:
c = c.parent()
if not isinstance(c, pc.ForSeqCursor):
if not isinstance(c, pc.ForCursor):
break
try:
if cur_depth >= num:
Expand Down Expand Up @@ -221,7 +221,7 @@ def find_child_loop(loop_c, name):
count += 1
child_loop = loop_c.body()[0]
if (
isinstance(child_loop, pc.ForSeqCursor)
isinstance(child_loop, pc.ForCursor)
and child_loop.name() == name
):
return child_loop, count
Expand Down Expand Up @@ -254,7 +254,7 @@ def fuse_two_loops(p, c):
except:
return p, False

if isinstance(c, pc.ForSeqCursor) and isinstance(next_c, pc.ForSeqCursor):
if isinstance(c, pc.ForCursor) and isinstance(next_c, pc.ForCursor):
if c.name() == next_c.name() and c.hi().value() == next_c.hi().value():
p = fuse(p, c, next_c, unsafe_disable_check=True)
return p, True
Expand All @@ -273,7 +273,7 @@ def fuse_all_loops(p, cursor):
recursively calls fuse_two_loops to all the loops
"""
while True:
if isinstance(cursor, pc.ForSeqCursor):
if isinstance(cursor, pc.ForCursor):
p = fuse_all_loops(p, cursor.body()[0])

# Fuse in current scope
Expand Down Expand Up @@ -307,7 +307,7 @@ def autolift_alloc(p, alloc_c, dep_set=None, max_size=0):
accum_size = 1
while True:
try:
if not isinstance(loop_c, pc.ForSeqCursor):
if not isinstance(loop_c, pc.ForCursor):
break
if dep_set == None or loop_c.name() in dep_set:
if accum_size < max_size:
Expand Down
Loading