Skip to content
Snippets Groups Projects
Commit 293e3d0c authored by Martin Bauer's avatar Martin Bauer
Browse files

Started to implement LBM CPU benchmark

parent ca3402de
Branches
Tags
No related merge requests found
...@@ -62,12 +62,13 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl ...@@ -62,12 +62,13 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl
return code return code
def addOpenMP(astNode, schedule="static"): def addOpenMP(astNode, schedule="static", numThreads=None):
""" """
Parallelizes the outer loop with OpenMP Parallelizes the outer loop with OpenMP
:param astNode: abstract syntax tree created e.g. by :func:`createKernel` :param astNode: abstract syntax tree created e.g. by :func:`createKernel`
:param schedule: OpenMP scheduling policy e.g. 'static' or 'dynamic' :param schedule: OpenMP scheduling policy e.g. 'static' or 'dynamic'
:param numThreads: explicitly specify number of threads
""" """
assert type(astNode) is ast.KernelFunction assert type(astNode) is ast.KernelFunction
body = astNode.body body = astNode.body
...@@ -77,4 +78,5 @@ def addOpenMP(astNode, schedule="static"): ...@@ -77,4 +78,5 @@ def addOpenMP(astNode, schedule="static"):
outerLoops = [l for l in body.atoms(ast.LoopOverCoordinate) if l.isOutermostLoop] outerLoops = [l for l in body.atoms(ast.LoopOverCoordinate) if l.isOutermostLoop]
assert outerLoops, "No outer loop found" assert outerLoops, "No outer loop found"
assert len(outerLoops) <= 1, "More than one outer loop found. Which one should be parallelized?" 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))
...@@ -83,7 +83,7 @@ class Field: ...@@ -83,7 +83,7 @@ class Field:
over dimension 0 over dimension 0
""" """
if not layout: if not layout:
layout = tuple(reversed(range(spatialDimensions))) layout = tuple(range(spatialDimensions))
if len(layout) != spatialDimensions: if len(layout) != spatialDimensions:
raise ValueError("Layout") raise ValueError("Layout")
shapeSymbol = IndexedBase(TypedSymbol(Field.SHAPE_PREFIX + fieldName, Field.SHAPE_DTYPE), shape=(1,)) shapeSymbol = IndexedBase(TypedSymbol(Field.SHAPE_PREFIX + fieldName, Field.SHAPE_DTYPE), shape=(1,))
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment