From 9aafa10a4cb32721db8e66d5a1da3a0bcd3a0abf Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Tue, 9 Jul 2013 00:03:58 -0400 Subject: [PATCH] Propagate iname deps by domain bounds --- loopy/kernel/tools.py | 14 +++++++++++--- test/test_loopy.py | 30 ++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/loopy/kernel/tools.py b/loopy/kernel/tools.py index 72baba59d..61d62a29c 100644 --- a/loopy/kernel/tools.py +++ b/loopy/kernel/tools.py @@ -156,9 +156,6 @@ def find_all_insn_inames(kernel): # {{{ domain-based propagation - # Add all inames occurring in parameters of domains that my current - # inames refer to. - inames_old = insn_id_to_inames[insn.id] inames_new = set(insn_id_to_inames[insn.id]) @@ -166,9 +163,20 @@ def find_all_insn_inames(kernel): home_domain = kernel.domains[kernel.get_home_domain_index(iname)] for par in home_domain.get_var_names(dim_type.param): + # Add all inames occurring in parameters of domains that my + # current inames refer to. + if par in kernel.all_inames(): inames_new.add(par) + # If something writes the bounds of a loop in which I'm + # sitting, I had better be in the inames that the writer is + # in. + + if par in kernel.temporary_variables: + for writer_id in writer_map.get(par, []): + inames_new.update(insn_id_to_inames[writer_id]) + if inames_new != inames_old: did_something = True insn_id_to_inames[insn.id] = frozenset(inames_new) diff --git a/test/test_loopy.py b/test/test_loopy.py index 111c59686..e1a05380d 100644 --- a/test/test_loopy.py +++ b/test/test_loopy.py @@ -1197,6 +1197,36 @@ def test_c_instruction(ctx_factory): print lp.CompiledKernel(ctx, knl).get_highlighted_code() +def test_dependent_domain_insn_iname_finding(ctx_factory): + ctx = ctx_factory() + + knl = lp.make_kernel(ctx.devices[0], [ + "{[isrc_box]: 0<=isrc_box src_ibox = source_boxes[isrc_box] + <> isrc_start = box_source_starts[src_ibox] + <> isrc_end = isrc_start+box_source_counts_nonchild[src_ibox] + <> strength = strengths[isrc] {id=set_strength} + """, + [ + lp.GlobalArg("box_source_starts,box_source_counts_nonchild", + None, shape=None), + "..."]) + + print knl + assert "isrc_box" in knl.insn_inames("set_strength") + + print lp.CompiledKernel(ctx, knl).get_highlighted_code( + dict( + source_boxes=np.int32, + box_source_starts=np.int32, + box_source_counts_nonchild=np.int32, + strengths=np.float64, + )) + + if __name__ == "__main__": if len(sys.argv) > 1: exec(sys.argv[1]) -- GitLab