From 5940f863fa091ab8744c9fcbefb4c96ccfc1edda Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Fri, 9 Feb 2018 20:41:36 -0600 Subject: [PATCH] Add test for variable ordering check --- loopy/check.py | 19 ++++++++++++++++++- loopy/diagnostic.py | 4 ++++ test/test_loopy.py | 15 +++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/loopy/check.py b/loopy/check.py index d8994b22d..2fa9874b1 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -250,6 +250,8 @@ def check_for_data_dependent_parallel_bounds(kernel): % (i, par, ", ".join(par_inames))) +# {{{ check access bounds + class _AccessCheckMapper(WalkMapper): def __init__(self, kernel, domain, insn_id): self.kernel = kernel @@ -340,6 +342,10 @@ def check_bounds(kernel): insn.with_transformed_expressions(run_acm) +# }}} + + +# {{{ check write destinations def check_write_destinations(kernel): for insn in kernel.instructions: @@ -363,6 +369,10 @@ def check_write_destinations(kernel): or wvar in kernel.arg_dict) and wvar not in kernel.all_params(): raise LoopyError +# }}} + + +# {{{ check_has_schedulable_iname_nesting def check_has_schedulable_iname_nesting(kernel): from loopy.transform.iname import (has_schedulable_iname_nesting, @@ -379,6 +389,10 @@ def check_has_schedulable_iname_nesting(kernel): "to get hints about which iname to duplicate. Here are some " "options:\n%s" % opt_str) +# }}} + + +# {{{ check_variable_access_ordered class IndirectDependencyEdgeFinder(object): def __init__(self, kernel): @@ -499,7 +513,8 @@ def check_variable_access_ordered(kernel): other_id=other_id, var=name)) if kernel.options.enforce_variable_access_ordered: - raise LoopyError(msg) + from loopy.diagnostic import VariableAccessNotOrdered + raise VariableAccessNotOrdered(msg) else: from loopy.diagnostic import warn_with_kernel warn_with_kernel( @@ -507,6 +522,8 @@ def check_variable_access_ordered(kernel): # }}} +# }}} + def pre_schedule_checks(kernel): try: diff --git a/loopy/diagnostic.py b/loopy/diagnostic.py index 4868f70af..c2b78f4d7 100644 --- a/loopy/diagnostic.py +++ b/loopy/diagnostic.py @@ -115,6 +115,10 @@ class LoopyTypeError(LoopyError): class ExpressionNotAffineError(LoopyError): pass + +class VariableAccessNotOrdered(LoopyError): + pass + # }}} diff --git a/test/test_loopy.py b/test/test_loopy.py index b876cdb55..931436959 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2791,6 +2791,21 @@ def test_add_prefetch_works_in_lhs_index(): assert "a1_map" not in get_dependencies(insn.assignees) +def test_check_for_variable_access_ordering(): + knl = lp.make_kernel( + "{[i]: 0<=i 1: exec(sys.argv[1]) -- GitLab