From 677b9f2aade96306102da3976e5f4db8909821a7 Mon Sep 17 00:00:00 2001
From: Dominic Kempf <dominic.kempf@iwr.uni-heidelberg.de>
Date: Wed, 3 Jan 2018 07:54:26 -0500
Subject: [PATCH] Disable performance bug for non-production work

---
 .../perftool/loopy/transformations/disjointgroups.py   | 10 ++++++++--
 python/dune/perftool/options.py                        |  1 +
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/python/dune/perftool/loopy/transformations/disjointgroups.py b/python/dune/perftool/loopy/transformations/disjointgroups.py
index 2f0a64f0..1f22c67d 100644
--- a/python/dune/perftool/loopy/transformations/disjointgroups.py
+++ b/python/dune/perftool/loopy/transformations/disjointgroups.py
@@ -1,6 +1,12 @@
 """ A helper transformation that makes all groups conflicting """
 
+from dune.perftool.options import get_option
 
 def make_groups_conflicting(knl):
-    groups = frozenset().union(*tuple(i.groups for i in knl.instructions))
-    return knl.copy(instructions=[i.copy(conflicts_with_groups=groups - i.groups) for i in knl.instructions])
+    # As this transformation introduces a performance bug that basically
+    # kills our CI, we only apply it if really needed - meaning in production.
+    if get_option("assure_statement_ordering"):
+        groups = frozenset().union(*tuple(i.groups for i in knl.instructions))
+        return knl.copy(instructions=[i.copy(conflicts_with_groups=groups - i.groups) for i in knl.instructions])
+    else:
+        return knl
diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py
index 789f7b86..9ae717c5 100644
--- a/python/dune/perftool/options.py
+++ b/python/dune/perftool/options.py
@@ -64,6 +64,7 @@ class PerftoolOptionsArray(ImmutableRecord):
     architecture = PerftoolOption(default="haswell", helpstr="The architecture to optimize for. Possible values: haswell|knl")
     grid_offset = PerftoolOption(default=False, helpstr="Set to true if you want a yasp grid where the lower left corner is not in the origin.")
     simplify = PerftoolOption(default=True, helpstr="Whether to simplify expressions using sympy")
+    assure_statement_ordering = PerftoolOption(default=False, helpstr="Whether special care should be taken for a good statement ordering in sumfact kernels, runs into a loopy scheduler performance bug, but is necessary for production.")
 
     # Arguments that are mainly to be set by logic depending on other options
     max_vector_width = PerftoolOption(default=256, helpstr=None)
-- 
GitLab