From 245014110260b81e8117da7fb46e477ccabd61a3 Mon Sep 17 00:00:00 2001 From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de> Date: Tue, 26 Jul 2016 17:47:56 +0200 Subject: [PATCH] Use a bit more involved heuristic in iname duplication --- python/dune/perftool/pdelab/localoperator.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/python/dune/perftool/pdelab/localoperator.py b/python/dune/perftool/pdelab/localoperator.py index bbd7daf4..42a9d4e1 100644 --- a/python/dune/perftool/pdelab/localoperator.py +++ b/python/dune/perftool/pdelab/localoperator.py @@ -208,8 +208,19 @@ def generate_kernel(integrals): # TODO: Use a clever strategy here, instead of random transformation until the problem is resolved from loopy import needs_iname_duplication, get_iname_duplication_options, duplicate_inames while needs_iname_duplication(kernel): - inames, within = next(get_iname_duplication_options(kernel)) - kernel = duplicate_inames(kernel, inames, within) + # If there is a duplication that solves the problem with just one duplication, we pick that one + iname, within = (None, None) + for i, w in get_iname_duplication_options(kernel): + if not needs_iname_duplication(duplicate_inames(kernel, i, w)): + iname, within = (i, w) + + # Otherwise pick a random one. + if iname is None: + iname, within = next(get_iname_duplication_options(kernel)) + + # Do the transformation + print "Applying iname duplication to measure {}: iname {}; within {}".format(measure, iname, within) + kernel = duplicate_inames(kernel, iname, within) # Loopy might have introduced some temporary variables during preprocessing. As I want to have my own # temporary declaration code right now, I call the declaration preamble manually. -- GitLab