Commit ab68008f authored by Jan Hönig's avatar Jan Hönig
Browse files

Updated pystencils demo and tutorial notebooks.

Fixed toDot.

Remove unnecessary comments.
parent dd95c69d
......@@ -14,10 +14,10 @@ class DotPrinter(Printer):
self.dot = Digraph(**kwargs)
self.dot.quote_edge = lang.quote
def _print_KernelFunction(self, function):
self.dot.node(self._nodeToStrFunction(function), style='filled', fillcolor='#a056db', label="Function")
self._print(function.body)
self.dot.edge(self._nodeToStrFunction(function), self._nodeToStrFunction(function.body))
def _print_KernelFunction(self, func):
self.dot.node(repr(func), style='filled', fillcolor='#a056db', label=self._nodeToStrFunction(func))
self._print(func.body)
self.dot.edge(repr(func), self._nodeToStrFunction(func.body))
def _print_LoopOverCoordinate(self, loop):
self.dot.node(self._nodeToStrFunction(loop), style='filled', fillcolor='#3498db')
......@@ -62,6 +62,7 @@ def __shortened(node):
elif isinstance(node, KernelFunction):
params = [f.name for f in node.fieldsAccessed]
params += [p.name for p in node.parameters if not p.isFieldArgument]
print(params)
return "Func: %s (%s)" % (node.functionName, ",".join(params))
elif isinstance(node, SympyAssignment):
return repr(node.lhs)
......
import sympy as sp
from pystencils.astnodes import SympyAssignment, Block, LoopOverCoordinate, KernelFunction
from pystencils.transformations import resolveFieldAccesses, makeLoopOverDomain, typingFromSympyInspection, \
typeAllEquations, getOptimalLoopOrdering, parseBasePointerInfo, moveConstantsBeforeLoop, splitInnerLoop, insertCasts#, \
#desympy_ast, insert_casts
from pystencils.transformations import resolveFieldAccesses, \
typeAllEquations, moveConstantsBeforeLoop, insertCasts
from pystencils.data_types import TypedSymbol, BasicType, StructType
from pystencils.field import Field
import pystencils.astnodes as ast
from functools import partial
from pystencils.llvm.llvmjit import makePythonFunction
......@@ -32,38 +28,6 @@ def createKernel(listOfEquations, functionName="kernel", typeForSymbol=None, spl
:return: :class:`pystencils.ast.KernelFunction` node
"""
#if not typeForSymbol:
# typeForSymbol = typingFromSympyInspection(listOfEquations, "double")
#
#def typeSymbol(term):
# if isinstance(term, Field.Access) or isinstance(term, TypedSymbol):
# return term
# elif isinstance(term, sp.Symbol):
# return TypedSymbol(term.name, typeForSymbol[term.name])
# else:
# raise ValueError("Term has to be field access or symbol")
#
#fieldsRead, fieldsWritten, assignments = typeAllEquations(listOfEquations, typeForSymbol)
#allFields = fieldsRead.union(fieldsWritten)
#
#readOnlyFields = set([f.name for f in fieldsRead - fieldsWritten])
#
#body = ast.Block(assignments)
#loopOrder = getOptimalLoopOrdering(allFields)
#code = makeLoopOverDomain(body, functionName, iterationSlice=iterationSlice,
# ghostLayers=ghostLayers, loopOrder=loopOrder)
#
#if splitGroups:
# typedSplitGroups = [[typeSymbol(s) for s in splitGroup] for splitGroup in splitGroups]
# splitInnerLoop(code, typedSplitGroups)
#
#basePointerInfo = []
#for i in range(len(loopOrder)):
# basePointerInfo.append(['spatialInner%d' % i])
#basePointerInfos = {field.name: parseBasePointerInfo(basePointerInfo, loopOrder, field) for field in allFields}
#
#resolveFieldAccesses(code, readOnlyFields, fieldToBasePointerInfo=basePointerInfos)
#moveConstantsBeforeLoop(code)
from pystencils.cpu import createKernel
code = createKernel(listOfEquations, functionName, typeForSymbol, splitGroups, iterationSlice, ghostLayers)
code = insertCasts(code)
......
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