From 293e3d0c73db61ce1bce48a5b17642a71e1dcff5 Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Thu, 17 Nov 2016 07:45:34 +0100 Subject: [PATCH] Started to implement LBM CPU benchmark --- cpu/kernelcreation.py | 6 ++++-- field.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cpu/kernelcreation.py b/cpu/kernelcreation.py index 9bfd1ea9e..cbea79d7d 100644 --- a/cpu/kernelcreation.py +++ b/cpu/kernelcreation.py @@ -62,12 +62,13 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl return code -def addOpenMP(astNode, schedule="static"): +def addOpenMP(astNode, schedule="static", numThreads=None): """ Parallelizes the outer loop with OpenMP :param astNode: abstract syntax tree created e.g. by :func:`createKernel` :param schedule: OpenMP scheduling policy e.g. 'static' or 'dynamic' + :param numThreads: explicitly specify number of threads """ assert type(astNode) is ast.KernelFunction body = astNode.body @@ -77,4 +78,5 @@ def addOpenMP(astNode, schedule="static"): outerLoops = [l for l in body.atoms(ast.LoopOverCoordinate) if l.isOutermostLoop] assert outerLoops, "No outer loop found" assert len(outerLoops) <= 1, "More than one outer loop found. Which one should be parallelized?" - outerLoops[0].prefixLines.append("#pragma omp for schedule(%s)" % (schedule,)) + threadsClause = "" if numThreads is None else " num_threads(%s)" % (numThreads,) + outerLoops[0].prefixLines.append("#pragma omp for schedule(%s)%s" % (schedule,threadsClause)) diff --git a/field.py b/field.py index 4c58d322d..12c9be76e 100644 --- a/field.py +++ b/field.py @@ -83,7 +83,7 @@ class Field: over dimension 0 """ if not layout: - layout = tuple(reversed(range(spatialDimensions))) + layout = tuple(range(spatialDimensions)) if len(layout) != spatialDimensions: raise ValueError("Layout") shapeSymbol = IndexedBase(TypedSymbol(Field.SHAPE_PREFIX + fieldName, Field.SHAPE_DTYPE), shape=(1,)) -- GitLab