From fa73cbbb98ccab67d5d088b7030c32a49ef39ad9 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 12 Sep 2018 19:32:44 -0400 Subject: [PATCH 01/16] add predicate-based limiting of access-range to avoid OOB exceptions inside of conditionals --- loopy/check.py | 10 +++++++++ loopy/symbolic.py | 57 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index c31304d87..15dff6ccc 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -331,6 +331,16 @@ class _AccessCheckMapper(WalkMapper): shape_domain = shape_domain.intersect(slab) + insn = self.kernel.id_to_insn[self.insn_id] + if insn.predicates: + from loopy.symbolic import constraints_from_expr + for pred in insn.predicates: + if get_dependencies(pred) == get_dependencies(subscript): + constraints = constraints_from_expr( + self.domain.get_space(), pred) + for constraint in constraints: + access_range = access_range.add_constraint(constraint) + if not access_range.is_subset(shape_domain): raise LoopyError("'%s' in instruction '%s' " "accesses out-of-bounds array element" diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 8927cd6fb..25af1797e 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -1339,6 +1339,53 @@ class PwAffEvaluationMapper(EvaluationMapperBase, IdentityMapperMixin): return num.mod_val(denom) +class ConditionalMapper(PwAffEvaluationMapper): + def map_logical_not(self, expr): + constraints = self.rec(expr.child) + out = [] + for constraint in constraints: + negated = constraint.get_aff().neg() + if constraint.is_equality(): + out.append(isl.Constraint.equality_from_aff(negated)) + else: + # since we're flipping a >= need to account for the ='s + val = int(str(constraint.get_constant_val())) + if val > 0: + val = 1 + elif val < 0: + val = -1 + out.append(isl.Constraint.inequality_from_aff(negated + val)) + return out + + def map_logical_and(self, expr): + constraints = [y for ch in expr.children for y in self.rec(ch)] + return constraints + + map_logical_or = map_logical_and + + def map_comparison(self, expr): + left = self.rec(expr.left) + right = self.rec(expr.right) + _, aff = (left - right).get_pieces()[-1] + if expr.operator == "==": + return [isl.Constraint.equality_from_aff(aff)] + elif expr.operator == "!=": + # piecewise + return [isl.Constraint.inequality_from_aff(aff + 1), + isl.Constraint.inequality_from_aff(aff - 1)] + elif expr.operator == "<": + return [isl.Constraint.inequality_from_aff((aff + 1).neg())] + elif expr.operator == "<=": + return [isl.Constraint.inequality_from_aff((aff).neg())] + elif expr.operator == ">": + return [isl.Constraint.inequality_from_aff((aff - 1))] + elif expr.operator == ">=": + return [isl.Constraint.inequality_from_aff((aff))] + else: + raise ValueError("invalid comparison operator") + return left - right + + def aff_from_expr(space, expr, vars_to_zero=None): if vars_to_zero is None: vars_to_zero = frozenset() @@ -1416,14 +1463,10 @@ def simplify_using_aff(kernel, expr): # }}} -# {{{ expression/set <-> constraint conversion - -def eq_constraint_from_expr(space, expr): - return isl.Constraint.equality_from_aff(aff_from_expr(space, expr)) - +# {{{ expression/set <-> constraints conversion -def ineq_constraint_from_expr(space, expr): - return isl.Constraint.inequality_from_aff(aff_from_expr(space, expr)) +def constraints_from_expr(space, expr): + return ConditionalMapper(space, vars_to_zero=[None])(expr) def constraint_to_cond_expr(cns): -- GitLab From 403c4b6fd3b3e5cf08d168e878f406c016b34d1e Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 12 Sep 2018 19:32:50 -0400 Subject: [PATCH 02/16] test --- test/test_loopy.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/test/test_loopy.py b/test/test_loopy.py index accf9c1df..76f5bdbb8 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2908,6 +2908,51 @@ def test_dep_cycle_printing_and_error(): print(lp.generate_code(knl)[0]) +@pytest.mark.parametrize("op", ['>', '>=', '<', '<=', '==', '!=']) +def test_conditonal_access_range(ctx_factory, op): + ctx = ctx_factory() + queue = cl.CommandQueue(ctx) + + def get_condition(): + if op == '>': + return 'not (i > 7)' + elif op == '>=': + return 'not (i >= 8)' + elif op == '<': + return 'i < 8' + elif op == '<=': + return 'i <=7' + elif op == '==': + return ' or '.join(['i == {}'.format(i) for i in range(8)]) + elif op == '!=': + return ' and '.join(['i != {}'.format(i) for i in range(8, 10)]) + + condition = get_condition() + knl = lp.make_kernel( + "{[i]: 0 <= i < 10}", + """ + if {condition} + tmp[i] = tmp[i] + 1 + end + """.format(condition=condition), + [lp.GlobalArg('tmp', shape=(8,), dtype=np.int64)]) + + assert np.array_equal(knl(queue, tmp=np.arange(8))[1][0], np.arange(1, 9)) + + # and failure + knl = lp.make_kernel( + "{[i,j]: 0 <= i,j < 10}", + """ + if j < 8 + tmp[i] = tmp[i] + end + """, [lp.GlobalArg('tmp', shape=(8,), dtype=np.int32)]) + + from loopy.diagnostic import LoopyError + with pytest.raises(LoopyError): + knl(queue) + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab From b3231429d5200afcb048ca021dcb038e41927ed2 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 09:37:33 -0400 Subject: [PATCH 03/16] implement non-affine check & test --- loopy/check.py | 26 +++++++++++++++++++++----- test/test_loopy.py | 19 +++++++++++++++++-- 2 files changed, 38 insertions(+), 7 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index 15dff6ccc..facf127bf 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -332,16 +332,32 @@ class _AccessCheckMapper(WalkMapper): shape_domain = shape_domain.intersect(slab) insn = self.kernel.id_to_insn[self.insn_id] + possible_warns = [] if insn.predicates: from loopy.symbolic import constraints_from_expr for pred in insn.predicates: - if get_dependencies(pred) == get_dependencies(subscript): - constraints = constraints_from_expr( - self.domain.get_space(), pred) - for constraint in constraints: - access_range = access_range.add_constraint(constraint) + if get_dependencies(pred) == insn.within_inames: + try: + constraints = constraints_from_expr( + self.domain.get_space(), pred) + for constraint in constraints: + access_range = access_range.add_constraint( + constraint) + except isl.Error: + # non-affine predicate - store for warning if we fail + # this check + possible_warns += [pred] + pass if not access_range.is_subset(shape_domain): + if possible_warns: + from loopy.diagnostic import warn_with_kernel + warn_with_kernel( + self.kernel, "non_affine_predicates", + "Predicates: ({}) are are expressed in a " + "non-affine manner, and were not considered " + "for out-of-bounds array checking.".format( + ', '.join(str(x) for x in possible_warns))) raise LoopyError("'%s' in instruction '%s' " "accesses out-of-bounds array element" % (expr, self.insn_id)) diff --git a/test/test_loopy.py b/test/test_loopy.py index 76f5bdbb8..52a849df7 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2939,7 +2939,9 @@ def test_conditonal_access_range(ctx_factory, op): assert np.array_equal(knl(queue, tmp=np.arange(8))[1][0], np.arange(1, 9)) - # and failure + +def test_conditonal_access_range_failure(ctx_factory): + # predicate doesn't actually limit access_range knl = lp.make_kernel( "{[i,j]: 0 <= i,j < 10}", """ @@ -2950,7 +2952,20 @@ def test_conditonal_access_range(ctx_factory, op): from loopy.diagnostic import LoopyError with pytest.raises(LoopyError): - knl(queue) + lp.generate_code_v2(knl).device_code() + + # predicate non affine + knl = lp.make_kernel( + "{[i,j]: 0 <= i,j < 10}", + """ + if (i+3)*i < 15 + tmp[i] = tmp[i] + end + """, [lp.GlobalArg('tmp', shape=(2,), dtype=np.int32)]) + + from loopy.diagnostic import LoopyError + with pytest.raises(LoopyError): + lp.generate_code_v2(knl).device_code() if __name__ == "__main__": -- GitLab From ea74afba147241eb3501505f6e33f60db67af1d1 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 09:47:21 -0400 Subject: [PATCH 04/16] separate the incorrect space error from the non-affine error to avoid incorrect warning --- loopy/check.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index facf127bf..38267f58a 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -340,14 +340,18 @@ class _AccessCheckMapper(WalkMapper): try: constraints = constraints_from_expr( self.domain.get_space(), pred) - for constraint in constraints: - access_range = access_range.add_constraint( - constraint) except isl.Error: # non-affine predicate - store for warning if we fail # this check possible_warns += [pred] - pass + + for constraint in constraints: + try: + access_range = access_range.add_constraint( + constraint) + except isl.Error: + # space doesn't match -- not sure what to do + pass if not access_range.is_subset(shape_domain): if possible_warns: -- GitLab From 1086f6c24d5652cf0b5913cd89e3d4bac48ede05 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 10:08:12 -0400 Subject: [PATCH 05/16] fix --- loopy/check.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index 38267f58a..6d3d3cc14 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -340,19 +340,20 @@ class _AccessCheckMapper(WalkMapper): try: constraints = constraints_from_expr( self.domain.get_space(), pred) + + for constraint in constraints: + try: + access_range = access_range.add_constraint( + constraint) + except isl.Error: + # space doesn't match -- not sure what to do + pass + except isl.Error: # non-affine predicate - store for warning if we fail # this check possible_warns += [pred] - for constraint in constraints: - try: - access_range = access_range.add_constraint( - constraint) - except isl.Error: - # space doesn't match -- not sure what to do - pass - if not access_range.is_subset(shape_domain): if possible_warns: from loopy.diagnostic import warn_with_kernel -- GitLab From 3def4cdb8ff51eddbcfadb166c2407c737429b17 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 12:06:45 -0400 Subject: [PATCH 06/16] apply predicates to access range _before_ calling get_access_range so we ensure we have the same space --- loopy/check.py | 45 +++++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index 6d3d3cc14..3d981e34a 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -312,8 +312,28 @@ class _AccessCheckMapper(WalkMapper): expr.aggregate.name, expr, len(subscript), len(shape))) + # apply predicates + access_range = self.domain + insn = self.kernel.id_to_insn[self.insn_id] + possible_warns = [] + if insn.predicates: + from loopy.symbolic import constraints_from_expr + for pred in insn.predicates: + if insn.within_inames <= get_dependencies(pred): + try: + constraints = constraints_from_expr( + self.domain.space, pred) + for constraint in constraints: + access_range = access_range.add_constraint( + constraint) + + except isl.Error: + # non-affine predicate - store for warning if we fail + # this check + possible_warns += [pred] + try: - access_range = get_access_range(self.domain, subscript, + access_range = get_access_range(access_range, subscript, self.kernel.assumptions) except UnableToDetermineAccessRange: # Likely: index was non-affine, nothing we can do. @@ -331,29 +351,6 @@ class _AccessCheckMapper(WalkMapper): shape_domain = shape_domain.intersect(slab) - insn = self.kernel.id_to_insn[self.insn_id] - possible_warns = [] - if insn.predicates: - from loopy.symbolic import constraints_from_expr - for pred in insn.predicates: - if get_dependencies(pred) == insn.within_inames: - try: - constraints = constraints_from_expr( - self.domain.get_space(), pred) - - for constraint in constraints: - try: - access_range = access_range.add_constraint( - constraint) - except isl.Error: - # space doesn't match -- not sure what to do - pass - - except isl.Error: - # non-affine predicate - store for warning if we fail - # this check - possible_warns += [pred] - if not access_range.is_subset(shape_domain): if possible_warns: from loopy.diagnostic import warn_with_kernel -- GitLab From 0c1b360bbcb62c04480d622d76d6408a8ce73e1c Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 12:07:11 -0400 Subject: [PATCH 07/16] sp. --- test/test_loopy.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_loopy.py b/test/test_loopy.py index 52a849df7..95f29f5c6 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2909,7 +2909,7 @@ def test_dep_cycle_printing_and_error(): @pytest.mark.parametrize("op", ['>', '>=', '<', '<=', '==', '!=']) -def test_conditonal_access_range(ctx_factory, op): +def test_conditional_access_range(ctx_factory, op): ctx = ctx_factory() queue = cl.CommandQueue(ctx) @@ -2940,7 +2940,7 @@ def test_conditonal_access_range(ctx_factory, op): assert np.array_equal(knl(queue, tmp=np.arange(8))[1][0], np.arange(1, 9)) -def test_conditonal_access_range_failure(ctx_factory): +def test_conditional_access_range_failure(ctx_factory): # predicate doesn't actually limit access_range knl = lp.make_kernel( "{[i,j]: 0 <= i,j < 10}", -- GitLab From 1c2e95d6bdb57dcc77ac74f65674e331166e7298 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 12:07:59 -0400 Subject: [PATCH 08/16] more complicated example w/ parameters, previously broken w/ space conflict --- test/test_loopy.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/test_loopy.py b/test/test_loopy.py index 95f29f5c6..6a44b4e6c 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2940,6 +2940,26 @@ def test_conditional_access_range(ctx_factory, op): assert np.array_equal(knl(queue, tmp=np.arange(8))[1][0], np.arange(1, 9)) +def test_conditional_access_range_with_parameters(ctx_factory): + ctx = ctx_factory() + queue = cl.CommandQueue(ctx) + + knl = lp.make_kernel( + ["{[i]: 0 <= i < 10}", + "{[j]: 0 <= j < problem_size}"], + """ + if i < 8 and j < problem_size + tmp[j, i] = tmp[j, i] + 1 + end + """, + [lp.GlobalArg('tmp', shape=('problem_size', 8,), dtype=np.int64), + lp.ValueArg('problem_size', dtype=np.int64)]) + + assert np.array_equal(knl(queue, tmp=np.arange(80).reshape((10, 8)), + problem_size=10)[1][0], np.arange(1, 81).reshape( + (10, 8))) + + def test_conditional_access_range_failure(ctx_factory): # predicate doesn't actually limit access_range knl = lp.make_kernel( -- GitLab From ea99d4c4bfb340999c5a19683674650163a8588d Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 12:08:46 -0400 Subject: [PATCH 09/16] relax condition to any predicate on iname --- loopy/check.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/check.py b/loopy/check.py index 3d981e34a..9f7bc3616 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -319,7 +319,7 @@ class _AccessCheckMapper(WalkMapper): if insn.predicates: from loopy.symbolic import constraints_from_expr for pred in insn.predicates: - if insn.within_inames <= get_dependencies(pred): + if insn.within_inames & get_dependencies(pred): try: constraints = constraints_from_expr( self.domain.space, pred) -- GitLab From c974db197e31cec81ffb6fff109f08e3c0a2cfa2 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 12:27:55 -0400 Subject: [PATCH 10/16] catch unknown variables raised by conditional mapper --- loopy/check.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/loopy/check.py b/loopy/check.py index 9f7bc3616..001bc727f 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -276,6 +276,7 @@ class _AccessCheckMapper(WalkMapper): WalkMapper.map_subscript(self, expr) from pymbolic.primitives import Variable + from pymbolic.mapper.evaluator import UnknownVariableError assert isinstance(expr.aggregate, Variable) shape = None @@ -331,6 +332,9 @@ class _AccessCheckMapper(WalkMapper): # non-affine predicate - store for warning if we fail # this check possible_warns += [pred] + except UnknownVariableError: + # data dependent bounds + pass try: access_range = get_access_range(access_range, subscript, -- GitLab From f6a852e042b28e1ed5931d0f6351a42c76b362ee Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 13 Sep 2018 13:05:40 -0400 Subject: [PATCH 11/16] Allow each part of logical_and / logical_or predicate to succeed/fail separately Add test where half of logical and predicate is data-dependent (and will fail) but other half will succeed to test --- loopy/symbolic.py | 10 ++++++++-- test/test_loopy.py | 23 ++++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 25af1797e..8572f3bda 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -1358,7 +1358,14 @@ class ConditionalMapper(PwAffEvaluationMapper): return out def map_logical_and(self, expr): - constraints = [y for ch in expr.children for y in self.rec(ch)] + from pymbolic.mapper.evaluator import UnknownVariableError + constraints = [] + for child in expr.children: + try: + constraints += [c for c in self.rec(child)] + except UnknownVariableError: + # the child contained data-dependent conditionals -> can't apply + pass return constraints map_logical_or = map_logical_and @@ -1383,7 +1390,6 @@ class ConditionalMapper(PwAffEvaluationMapper): return [isl.Constraint.inequality_from_aff((aff))] else: raise ValueError("invalid comparison operator") - return left - right def aff_from_expr(space, expr, vars_to_zero=None): diff --git a/test/test_loopy.py b/test/test_loopy.py index 6a44b4e6c..6645ece1a 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2944,9 +2944,11 @@ def test_conditional_access_range_with_parameters(ctx_factory): ctx = ctx_factory() queue = cl.CommandQueue(ctx) + # test that conditional on parameter works, otherwise the tmp[j, i] will show + # as OOB knl = lp.make_kernel( ["{[i]: 0 <= i < 10}", - "{[j]: 0 <= j < problem_size}"], + "{[j]: 0 <= j < problem_size + 2}"], """ if i < 8 and j < problem_size tmp[j, i] = tmp[j, i] + 1 @@ -2959,6 +2961,25 @@ def test_conditional_access_range_with_parameters(ctx_factory): problem_size=10)[1][0], np.arange(1, 81).reshape( (10, 8))) + # test a conditional that's only _half_ data-dependent to ensure the other + # half works + knl = lp.make_kernel( + ["{[i]: 0 <= i < 10}", + "{[j]: 0 <= j < problem_size}"], + """ + if i < 8 and (j + offset) < problem_size + tmp[j, i] = tmp[j, i] + 1 + end + """, + [lp.GlobalArg('tmp', shape=('problem_size', 8,), dtype=np.int64), + lp.ValueArg('problem_size', dtype=np.int64), + lp.ValueArg('offset', dtype=np.int64)]) + + assert np.array_equal(knl(queue, tmp=np.arange(80).reshape((10, 8)), + problem_size=10, + offset=0)[1][0], np.arange(1, 81).reshape( + (10, 8))) + def test_conditional_access_range_failure(ctx_factory): # predicate doesn't actually limit access_range -- GitLab From 2d0ece0f02e97cfa82a73b1e0db88c4d89f12e21 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 14 Sep 2018 09:08:54 -0400 Subject: [PATCH 12/16] suppress isl stderr --- loopy/symbolic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 8572f3bda..7d617564b 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -1472,7 +1472,8 @@ def simplify_using_aff(kernel, expr): # {{{ expression/set <-> constraints conversion def constraints_from_expr(space, expr): - return ConditionalMapper(space, vars_to_zero=[None])(expr) + with isl.SuppressedWarnings(space.get_ctx): + return ConditionalMapper(space, vars_to_zero=[None])(expr) def constraint_to_cond_expr(cns): -- GitLab From 5d7f84fdd5f61ab11682d1deb7bb26a669fe753f Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 14 Sep 2018 09:16:40 -0400 Subject: [PATCH 13/16] whoops --- loopy/symbolic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 7d617564b..7bc006f9f 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -1472,7 +1472,7 @@ def simplify_using_aff(kernel, expr): # {{{ expression/set <-> constraints conversion def constraints_from_expr(space, expr): - with isl.SuppressedWarnings(space.get_ctx): + with isl.SuppressedWarnings(space.get_ctx()): return ConditionalMapper(space, vars_to_zero=[None])(expr) -- GitLab From 7a6db25b4f2ae29c739afdbf45279edc8240ba63 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 20 Nov 2018 20:53:49 -0500 Subject: [PATCH 14/16] suppress warnings --- loopy/check.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index 001bc727f..e735fb413 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -321,20 +321,21 @@ class _AccessCheckMapper(WalkMapper): from loopy.symbolic import constraints_from_expr for pred in insn.predicates: if insn.within_inames & get_dependencies(pred): - try: - constraints = constraints_from_expr( - self.domain.space, pred) - for constraint in constraints: - access_range = access_range.add_constraint( - constraint) - - except isl.Error: - # non-affine predicate - store for warning if we fail - # this check - possible_warns += [pred] - except UnknownVariableError: - # data dependent bounds - pass + with isl.SuppressedWarnings(self.domain.get_ctx()): + try: + constraints = constraints_from_expr( + self.domain.space, pred) + for constraint in constraints: + access_range = access_range.add_constraint( + constraint) + + except isl.Error: + # non-affine predicate - store for warning if we fail + # this check + possible_warns += [pred] + except UnknownVariableError: + # data dependent bounds + pass try: access_range = get_access_range(access_range, subscript, -- GitLab From d00fe4ec953b72d8b3fd35b21d42dae0c364309c Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 20 Nov 2018 20:58:26 -0500 Subject: [PATCH 15/16] warn->info --- loopy/check.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/loopy/check.py b/loopy/check.py index e735fb413..38539641a 100644 --- a/loopy/check.py +++ b/loopy/check.py @@ -358,10 +358,9 @@ class _AccessCheckMapper(WalkMapper): if not access_range.is_subset(shape_domain): if possible_warns: - from loopy.diagnostic import warn_with_kernel - warn_with_kernel( - self.kernel, "non_affine_predicates", - "Predicates: ({}) are are expressed in a " + import logging + logger = logging.getLogger(__name__) + logger.info("Predicates: ({}) are are expressed in a " "non-affine manner, and were not considered " "for out-of-bounds array checking.".format( ', '.join(str(x) for x in possible_warns))) -- GitLab From b3050b882434ee02fa3922dd572a2fdc09f06ac3 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 20 Nov 2018 21:07:37 -0500 Subject: [PATCH 16/16] make the conditional mapper it's own class (rather than inheriting from the PwAffMapper) --- loopy/symbolic.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/loopy/symbolic.py b/loopy/symbolic.py index 067e220fa..fbb5701ed 100644 --- a/loopy/symbolic.py +++ b/loopy/symbolic.py @@ -1339,7 +1339,11 @@ class PwAffEvaluationMapper(EvaluationMapperBase, IdentityMapperMixin): return num.mod_val(denom) -class ConditionalMapper(PwAffEvaluationMapper): +class ConditionalMapper(EvaluationMapperBase, IdentityMapperMixin): + def __init__(self, space, vars_to_zero): + self.pw_map = PwAffEvaluationMapper(space, vars_to_zero) + super(ConditionalMapper, self).__init__(self.pw_map.context.copy()) + def map_logical_not(self, expr): constraints = self.rec(expr.child) out = [] -- GitLab