From 3c74d1c38a9d2984d14306e42879c33ca65591d9 Mon Sep 17 00:00:00 2001
From: Martin Bauer <martin.bauer@fau.de>
Date: Mon, 28 Nov 2016 17:42:20 +0100
Subject: [PATCH] Bugfixes in benchmark & boundary handling convenience class

---
 ast.py        |  1 -
 cpu/cpujit.py |  8 ++++++++
 slicing.py    | 35 +++++++++++++++++++++++++++++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/ast.py b/ast.py
index 81907cdf2..5d36c1e0d 100644
--- a/ast.py
+++ b/ast.py
@@ -80,7 +80,6 @@ class KernelFunction(Node):
         # these variables are assumed to be global, so no automatic parameter is generated for them
         self.globalVariables = set()
 
-
     @property
     def symbolsDefined(self):
         return set()
diff --git a/cpu/cpujit.py b/cpu/cpujit.py
index aff1a512d..f7ff6cf0c 100644
--- a/cpu/cpujit.py
+++ b/cpu/cpujit.py
@@ -19,6 +19,14 @@ CONFIG_INTEL = {
         'LM_PROJECT': 'iwia',
     }
 }
+CONFIG_INTEL_SUPERMUC = {
+    'compiler': '/lrz/sys/intel/studio2017_u1/compilers_and_libraries_2017.1.132/linux/bin/intel64/icpc',
+    'flags': '-Ofast -DNDEBUG -fPIC -shared -march=native -fopenmp -Wl,'
+             '-rpath=/lrz/sys/intel/studio2016_u4/compilers_and_libraries_2016.4.258/linux/mkl/lib/intel64',
+    'env': {
+        'INTEL_LICENSE_FILE': '/lrz/sys/intel/licenses',
+    }
+}
 CONFIG_CLANG = {
     'compiler': 'clang++',
     'flags': '-Ofast -DNDEBUG -fPIC -shared -march=native -fopenmp',
diff --git a/slicing.py b/slicing.py
index c9b45a659..ad792f6f4 100644
--- a/slicing.py
+++ b/slicing.py
@@ -1,5 +1,6 @@
 import sympy as sp
 
+
 class SliceMaker(object):
     def __getitem__(self, item):
         return item
@@ -43,3 +44,37 @@ def normalizeSlice(slices, sizes):
         result.append(slice(newStart, newStop, s.step if s.step is not None else 1))
 
     return tuple(result)
+
+
+def sliceFromDirection(directionName, dim, normalOffset=0, tangentialOffset=0):
+    """
+    Create a slice from a direction named by compass scheme:
+        i.e. 'N' for north returns same as makeSlice[:, -1]
+        the naming is:
+            - x: W, E (west, east)
+            - y: S, N (south, north)
+            - z: B, T (bottom, top)
+    Also combinations are allowed like north-east 'NE'
+
+    :param directionName: name of direction as explained above
+    :param dim: dimension of the returned slice (should be 2 or 3)
+    :param normalOffset: the offset in 'normal' direction: e.g. sliceFromDirection('N',2, normalOffset=2)
+                         would return makeSlice[:, -3]
+    :param tangentialOffset: offset in the other directions: e.g. sliceFromDirection('N',2, tangentialOffset=2)
+                         would return makeSlice[2:-2, -1]
+    """
+    if tangentialOffset == 0:
+        result = [slice(None, None, None)] * dim
+    else:
+        result = [slice(tangentialOffset, -tangentialOffset, None)] * dim
+
+    normalSliceHigh, normalSliceLow = -1-normalOffset, normalOffset
+
+    for dimIdx, (lowName, highName) in enumerate([('W', 'E'), ('S', 'N'), ('B', 'T')]):
+        if lowName in directionName:
+            assert highName not in directionName, "Invalid direction name"
+            result[dimIdx] = normalSliceLow
+        if highName in directionName:
+            assert lowName not in directionName, "Invalid direction name"
+            result[dimIdx] = normalSliceHigh
+    return tuple(result)
-- 
GitLab