From 03747fc2c34499f0cadba8adefaddf483c46f556 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Thu, 14 Nov 2019 21:07:35 -0600 Subject: [PATCH 1/2] add only connected hardware inames --- loopy/codegen/bounds.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/loopy/codegen/bounds.py b/loopy/codegen/bounds.py index c946e09a0..0104f70e6 100644 --- a/loopy/codegen/bounds.py +++ b/loopy/codegen/bounds.py @@ -58,9 +58,12 @@ def get_approximate_convex_bounds_checks(domain, check_inames, implemented_domai def get_usable_inames_for_conditional(kernel, sched_index): from loopy.schedule import ( find_active_inames_at, get_insn_ids_for_block_at, has_barrier_within) + from loopy.schedule import CallKernel, ReturnFromKernel, EnterLoop from loopy.kernel.data import (ConcurrentTag, LocalIndexTagBase, IlpBaseTag) + assert isinstance(kernel.schedule[sched_index], EnterLoop) + result = find_active_inames_at(kernel, sched_index) crosses_barrier = has_barrier_within(kernel, sched_index) @@ -68,7 +71,6 @@ def get_usable_inames_for_conditional(kernel, sched_index): within_subkernel = False for sched_item_index, sched_item in enumerate(kernel.schedule[:sched_index+1]): - from loopy.schedule import CallKernel, ReturnFromKernel if isinstance(sched_item, CallKernel): within_subkernel = True subkernel_index = sched_item_index @@ -87,6 +89,8 @@ def get_usable_inames_for_conditional(kernel, sched_index): for insn in insn_ids_for_subkernel for iname in kernel.insn_inames(insn)) + sched_item = kernel.schedule[sched_index] + for iname in inames_for_subkernel: # Parallel inames are defined within a subkernel, BUT: # @@ -101,11 +105,12 @@ def get_usable_inames_for_conditional(kernel, sched_index): and crosses_barrier) and not kernel.iname_tags_of_type(iname, IlpBaseTag) ): - result.add(iname) + if any(kernel.insn_inames(insn) >= frozenset([sched_item.iname, + iname]) for insn in insn_ids_for_subkernel): + result.add(iname) return frozenset(result) # }}} - # vim: foldmethod=marker -- GitLab From 7d67f86b37c66c1f30aa11b9e9680b9bb3442be0 Mon Sep 17 00:00:00 2001 From: Kaushik Kulkarni Date: Thu, 14 Nov 2019 23:06:24 -0600 Subject: [PATCH 2/2] changes after review --- loopy/codegen/bounds.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/loopy/codegen/bounds.py b/loopy/codegen/bounds.py index 0104f70e6..cc107423e 100644 --- a/loopy/codegen/bounds.py +++ b/loopy/codegen/bounds.py @@ -105,8 +105,11 @@ def get_usable_inames_for_conditional(kernel, sched_index): and crosses_barrier) and not kernel.iname_tags_of_type(iname, IlpBaseTag) ): - if any(kernel.insn_inames(insn) >= frozenset([sched_item.iname, - iname]) for insn in insn_ids_for_subkernel): + # in the case of multiple inames with a concurrent tag in the + # subkernel, pick only the ones that are interacting with the loop + # at 'sched_index' + if (kernel.iname_to_insns()[sched_item.iname] + & kernel.iname_to_insns()[iname]): result.add(iname) return frozenset(result) -- GitLab