Commit 697d8cdf authored by Martin Bauer's avatar Martin Bauer
Browse files

waLBerla code gen: better handling of ghost layers

- support for kernels that run over walberla ghost layers
parent cf9f3415
......@@ -156,13 +156,14 @@ class KernelFunction(Node):
def __repr__(self):
return '<{0} {1}>'.format(self.dtype, self.name)
def __init__(self, body, functionName="kernel"):
def __init__(self, body, ghostLayers=None, functionName="kernel"):
super(KernelFunction, self).__init__()
self._body = body
body.parent = self
self._parameters = None
self.functionName = functionName
self._body.parent = self
self.ghostLayers = ghostLayers
# these variables are assumed to be global, so no automatic parameter is generated for them
self.globalVariables = set()
......
......@@ -120,7 +120,7 @@ def createIndexedKernel(listOfEquations, indexFields, functionName="kernel", typ
loopBody.append(assignment)
functionBody = Block([loopNode])
ast = KernelFunction(functionBody, functionName)
ast = KernelFunction(functionBody, functionName=functionName)
fixedCoordinateMapping = {f.name: coordinateTypedSymbols for f in nonIndexFields}
resolveFieldAccesses(ast, set(['indexField']), fieldToFixedCoordinates=fixedCoordinateMapping)
......
......@@ -35,7 +35,7 @@ def createCUDAKernel(listOfEquations, functionName="kernel", typeForSymbol=None,
block = Block(assignments)
block = indexing.guard(block, commonShape)
ast = KernelFunction(block, functionName)
ast = KernelFunction(block, functionName=functionName, ghostLayers=ghostLayers)
ast.globalVariables.update(indexing.indexVariables)
coordMapping = indexing.coordinates
......@@ -95,7 +95,7 @@ def createdIndexedCUDAKernel(listOfEquations, indexFields, functionName="kernel"
functionBody = Block(coordinateSymbolAssignments + assignments)
functionBody = indexing.guard(functionBody, getCommonShape(indexFields))
ast = KernelFunction(functionBody, functionName)
ast = KernelFunction(functionBody, functionName=functionName)
ast.globalVariables.update(indexing.indexVariables)
coordMapping = indexing.coordinates
......
......@@ -101,7 +101,7 @@ def makeLoopOverDomain(body, functionName, iterationSlice=None, ghostLayers=None
assignment = ast.SympyAssignment(ast.LoopOverCoordinate.getLoopCounterSymbol(loopCoordinate),
sp.sympify(sliceComponent))
currentBody.insertFront(assignment)
return ast.KernelFunction(currentBody, functionName)
return ast.KernelFunction(currentBody, ghostLayers=ghostLayers, functionName=functionName)
def createIntermediateBasePointer(fieldAccess, coordinates, previousPtr):
......
import ctypes
import sympy as sp
import numpy as np
# import llvmlite.ir as ir
from sympy.core.cache import cacheit
from pystencils.cache import memorycache
class TypedSymbol(sp.Symbol):
......@@ -115,7 +115,6 @@ def toCtypes(dataType):
else:
return toCtypes.map[dataType.numpyDtype]
toCtypes.map = {
np.dtype(np.int8): ctypes.c_int8,
np.dtype(np.int16): ctypes.c_int16,
......@@ -132,33 +131,10 @@ toCtypes.map = {
}
#def to_llvmlite_type(data_type):
# """
# Transforms a given type into ctypes
# :param data_type: Subclass of Type
# :return: llvmlite type object
# """
# if isinstance(data_type, PointerType):
# return to_llvmlite_type.map[data_type.baseType].as_pointer()
# else:
# return to_llvmlite_type.map[data_type.numpyDType]
#
#to_llvmlite_type.map = {
# np.dtype(np.int8): ir.IntType(8),
# np.dtype(np.int16): ir.IntType(16),
# np.dtype(np.int32): ir.IntType(32),
# np.dtype(np.int64): ir.IntType(64),
#
# # TODO llvmlite doesn't seem to differentiate between Int types
# np.dtype(np.uint8): ir.IntType(8),
# np.dtype(np.uint16): ir.IntType(16),
# np.dtype(np.uint32): ir.IntType(32),
# np.dtype(np.uint64): ir.IntType(64),
#
# np.dtype(np.float32): ir.FloatType(),
# np.dtype(np.float64): ir.DoubleType(),
# # TODO const, restrict, void
#}
def getTypeOfExpression(expr):
if isinstance(expr, TypedSymbol):
return expr.dtype
class Type(sp.Basic):
......
Markdown is supported
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