From d17aefa4e135d1db4fd33969b8e5f2a994c85ca3 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 20 Oct 2017 12:21:14 -0400 Subject: [PATCH 1/2] add test that fails to create kernel on current version --- test/test_loopy.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/test_loopy.py b/test/test_loopy.py index 397d4832b..066de6292 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -2034,6 +2034,37 @@ def test_if_else(ctx_factory): out_ref[4::6] = 11 out_ref[2::6] = 3 + knl = lp.make_kernel( + "{ [i,j]: 0<=i,j<50}", + """ + for i + if i < 25 + for j + if j % 2 == 0 + a[i, j] = 1 + else + a[i, j] = 0 + end + end + else + for j + if j % 2 == 0 + a[i, j] = 0 + else + a[i, j] = 1 + end + end + end + end + """ + ) + + evt, (out,) = knl(queue, out_host=True) + + out_ref = np.zeros((50, 50)) + out_ref[:25, 0::2] = 1 + out_ref[25:, 1::2] = 1 + assert np.array_equal(out_ref, out) -- GitLab From 79d80f69192b6410dc754748e93ec6aa194d7347 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 20 Oct 2017 12:22:12 -0400 Subject: [PATCH 2/2] only pop if predicates if we are within the same inames (i.e. this insn't the end of a for loop inside of an if --- loopy/kernel/creation.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/loopy/kernel/creation.py b/loopy/kernel/creation.py index c6618d62f..b1e7c3194 100644 --- a/loopy/kernel/creation.py +++ b/loopy/kernel/creation.py @@ -896,7 +896,8 @@ def parse_instructions(instructions, defines): obj = insn_options_stack.pop() #if this object is the end of an if statement if obj['predicates'] == if_predicates_stack[-1]["insn_predicates"] and\ - if_predicates_stack[-1]["insn_predicates"]: + if_predicates_stack[-1]["insn_predicates"] and\ + obj['within_inames'] == if_predicates_stack[-1]['within_inames']: if_predicates_stack.pop() continue -- GitLab