From 549125c165119f82a6b508565fa87e5df0d55509 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Thu, 30 Jan 2014 10:14:16 -0600 Subject: [PATCH] Add constants_only parameter to get_iname_bounds, use where needed --- loopy/__init__.py | 2 +- loopy/codegen/loop.py | 2 +- loopy/isl_helpers.py | 6 ------ loopy/kernel/__init__.py | 18 +++++++++++------- loopy/preprocess.py | 2 +- 5 files changed, 14 insertions(+), 16 deletions(-) diff --git a/loopy/__init__.py b/loopy/__init__.py index 406dadc73..51925f9b6 100644 --- a/loopy/__init__.py +++ b/loopy/__init__.py @@ -360,7 +360,7 @@ def join_inames(kernel, inames, new_iname=None, tag=None, within=None): joint_aff = joint_aff + base_divisor*iname_aff - bounds = kernel.get_iname_bounds(iname) + bounds = kernel.get_iname_bounds(iname, constants_only=True) from loopy.isl_helpers import ( static_max_of_pw_aff, static_value_of_pw_aff) diff --git a/loopy/codegen/loop.py b/loopy/codegen/loop.py index 03074ea73..8ad4a08ca 100644 --- a/loopy/codegen/loop.py +++ b/loopy/codegen/loop.py @@ -116,7 +116,7 @@ def get_slab_decomposition(kernel, iname, sched_index, codegen_state): def generate_unroll_loop(kernel, sched_index, codegen_state): iname = kernel.schedule[sched_index].iname - bounds = kernel.get_iname_bounds(iname) + bounds = kernel.get_iname_bounds(iname, constants_only=True) from loopy.isl_helpers import ( static_max_of_pw_aff, static_value_of_pw_aff) diff --git a/loopy/isl_helpers.py b/loopy/isl_helpers.py index a0b94cce0..587b1be38 100644 --- a/loopy/isl_helpers.py +++ b/loopy/isl_helpers.py @@ -368,10 +368,4 @@ def boxify(cache_manager, domain, box_inames, context): return convexify(result) - - - - - - # vim: foldmethod=marker diff --git a/loopy/kernel/__init__.py b/loopy/kernel/__init__.py index eed39c6d7..58d8eb33b 100644 --- a/loopy/kernel/__init__.py +++ b/loopy/kernel/__init__.py @@ -716,9 +716,8 @@ class LoopKernel(Record): # {{{ bounds finding @memoize_method - def get_iname_bounds(self, iname): + def get_iname_bounds(self, iname, constants_only=False): domain = self.get_inames_domain(frozenset([iname])) - d_var_dict = domain.get_var_dict() assumptions = self.assumptions.project_out_except( set(domain.get_var_dict(dim_type.param)), [dim_type.param]) @@ -727,15 +726,20 @@ class LoopKernel(Record): dom_intersect_assumptions = aligned_assumptions & domain + if constants_only: + # Kill all variable dependencies + dom_intersect_assumptions = dom_intersect_assumptions.project_out_except( + [iname], [dim_type.param, dim_type.set]) + + iname_idx = dom_intersect_assumptions.get_var_dict()[iname][1] + lower_bound_pw_aff = ( self.cache_manager.dim_min( - dom_intersect_assumptions, - d_var_dict[iname][1]) + dom_intersect_assumptions, iname_idx) .coalesce()) upper_bound_pw_aff = ( self.cache_manager.dim_max( - dom_intersect_assumptions, - d_var_dict[iname][1]) + dom_intersect_assumptions, iname_idx) .coalesce()) class BoundsRecord(Record): @@ -754,7 +758,7 @@ class LoopKernel(Record): from loopy.isl_helpers import static_max_of_pw_aff from loopy.symbolic import aff_to_expr return int(aff_to_expr(static_max_of_pw_aff( - self.get_iname_bounds(iname).size, + self.get_iname_bounds(iname, constants_only=True).size, constants_only=True))) @memoize_method diff --git a/loopy/preprocess.py b/loopy/preprocess.py index 88efa0fbb..ec1e750d3 100644 --- a/loopy/preprocess.py +++ b/loopy/preprocess.py @@ -567,7 +567,7 @@ def duplicate_private_temporaries_for_ilp(kernel): if iname in ilp_iname_to_length: continue - bounds = kernel.get_iname_bounds(iname) + bounds = kernel.get_iname_bounds(iname, constants_only=True) ilp_iname_to_length[iname] = int(pw_aff_to_expr( static_max_of_pw_aff(bounds.size, constants_only=True))) -- GitLab