Skip to content
Snippets Groups Projects
Commit 5ac94e9e authored by Andreas Klöckner's avatar Andreas Klöckner
Browse files

Try two strategies for finding base indices/lengths

parent f8fcbec2
No related branches found
No related tags found
No related merge requests found
...@@ -78,6 +78,10 @@ class AutomaticTestFailure(LoopyError): ...@@ -78,6 +78,10 @@ class AutomaticTestFailure(LoopyError):
pass pass
class StaticValueFindingError(LoopyError):
pass
class DependencyTypeInferenceFailure(TypeInferenceFailure): class DependencyTypeInferenceFailure(TypeInferenceFailure):
def __init__(self, message, symbol): def __init__(self, message, symbol):
TypeInferenceFailure.__init__(self, message) TypeInferenceFailure.__init__(self, message)
......
...@@ -196,7 +196,7 @@ def static_extremum_of_pw_aff(pw_aff, constants_only, set_method, what, context) ...@@ -196,7 +196,7 @@ def static_extremum_of_pw_aff(pw_aff, constants_only, set_method, what, context)
# }}} # }}}
raise ValueError("a static %s was not found for PwAff '%s'" raise StaticValueFindingError("a static %s was not found for PwAff '%s'"
% (what, pw_aff)) % (what, pw_aff))
......
...@@ -292,21 +292,49 @@ class SetOperationCacheManager: ...@@ -292,21 +292,49 @@ class SetOperationCacheManager:
lower_bound_pw_aff = self.dim_min(set, idx) lower_bound_pw_aff = self.dim_min(set, idx)
upper_bound_pw_aff = self.dim_max(set, idx) upper_bound_pw_aff = self.dim_max(set, idx)
from loopy.isl_helpers import static_max_of_pw_aff, static_value_of_pw_aff from loopy.diagnostic import StaticValueFindingError
from loopy.isl_helpers import (
static_max_of_pw_aff,
static_min_of_pw_aff,
static_value_of_pw_aff)
from loopy.symbolic import pw_aff_to_expr from loopy.symbolic import pw_aff_to_expr
# {{{ first: try to find static lower bound value
try:
base_index_aff = static_value_of_pw_aff(
lower_bound_pw_aff, constants_only=False,
context=context)
except StaticValueFindingError:
base_index_aff = None
if base_index_aff is not None:
base_index = pw_aff_to_expr(base_index_aff)
size = pw_aff_to_expr(static_max_of_pw_aff(
upper_bound_pw_aff - base_index_aff + 1, constants_only=False,
context=context))
return base_index, size
# }}}
# {{{ if that didn't work, try finding a lower bound
base_index_aff = static_min_of_pw_aff(
lower_bound_pw_aff, constants_only=False,
context=context)
base_index = pw_aff_to_expr(base_index_aff)
size = pw_aff_to_expr(static_max_of_pw_aff( size = pw_aff_to_expr(static_max_of_pw_aff(
upper_bound_pw_aff - lower_bound_pw_aff + 1, constants_only=False, upper_bound_pw_aff - base_index_aff + 1, constants_only=False,
context=context)) context=context))
try:
base_index = pw_aff_to_expr(
static_value_of_pw_aff(lower_bound_pw_aff, constants_only=False,
context=context))
except Exception as e:
raise type(e)("while finding lower bound of '%s': %s" % (iname, str(e)))
return base_index, size return base_index, size
# }}}
# }}} # }}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment