From 7e34e4649d669c4556ac7c0cc7da90c39e8d183c Mon Sep 17 00:00:00 2001
From: Marcel Koch <marcel.koch@uni-muenster.de>
Date: Mon, 9 Apr 2018 16:49:18 +0200
Subject: [PATCH] adds a slightly more complicated iname duplication

---
 .../perftool/loopy/transformations/duplicate.py  | 16 +++++++++++++++-
 test/blockstructured/stokes/stokes.mini          |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/python/dune/perftool/loopy/transformations/duplicate.py b/python/dune/perftool/loopy/transformations/duplicate.py
index eecdd9a8..8d4a3cc0 100644
--- a/python/dune/perftool/loopy/transformations/duplicate.py
+++ b/python/dune/perftool/loopy/transformations/duplicate.py
@@ -1,5 +1,5 @@
 """ Iname duplication strategies to make kernels schedulable """
-
+from dune.perftool.options import get_option
 from loopy import (has_schedulable_iname_nesting,
                    get_iname_duplication_options,
                    duplicate_inames,
@@ -18,4 +18,18 @@ def heuristic_duplication(kernel):
         if has_schedulable_iname_nesting(dup_kernel):
             return dup_kernel
 
+    if get_option('blockstructured'):
+        duplication_options = dict(get_iname_duplication_options(kernel))
+        suffixes = ['x','y','z']
+        for iname in duplication_options:
+            if iname[-1] in suffixes:
+                dup_kernel = kernel
+                base = iname[:-1]
+                for s in suffixes:
+                    if base+s in duplication_options:
+                        dup_kernel = duplicate_inames(dup_kernel, base+s, duplication_options[base+s])
+                        del duplication_options[base+s]
+                if has_schedulable_iname_nesting(dup_kernel):
+                    return dup_kernel
+
     raise NotImplementedError("Your kernel needs multiple iname duplications! No generic algorithm implemented for that yet! (#39)")
diff --git a/test/blockstructured/stokes/stokes.mini b/test/blockstructured/stokes/stokes.mini
index c44cc189..8f1ab6ab 100644
--- a/test/blockstructured/stokes/stokes.mini
+++ b/test/blockstructured/stokes/stokes.mini
@@ -1,7 +1,7 @@
 __name = blockstructured_stokes_{__exec_suffix}
 __exec_suffix = symdiff, numdiff | expand num
 
-cells = 20 20
+cells = 20 20z
 extension = 1. 1.
 
 [wrapper.vtkcompare]
-- 
GitLab