diff --git a/backends/cbackend.py b/backends/cbackend.py index 9f1620da9ec320051c49f5027c4d4c3f15a770d5..ef24a39fb3b389f08ba62e6c2685de5122b25720 100644 --- a/backends/cbackend.py +++ b/backends/cbackend.py @@ -3,7 +3,7 @@ from sympy.utilities.codegen import CCodePrinter from pystencils.ast import Node -def printCCode(astNode): +def generateC(astNode): """ Prints the abstract syntax tree as C function """ @@ -11,7 +11,7 @@ def printCCode(astNode): return printer(astNode) -def printCudaCode(astNode): +def generateCUDA(astNode): printer = CBackend(cuda=True) return printer(astNode) @@ -60,7 +60,7 @@ class CBackend: self.sympyPrinter = CustomSympyPrinter() def __call__(self, node): - return self._print(node) + return str(self._print(node)) def _print(self, node): for cls in type(node).__mro__: diff --git a/cpu/__init__.py b/cpu/__init__.py index 71656ee6ca8c8bb6333267913939d39a55b1807a..039f12025743f687d26c7ff548a81ab97cbb4f03 100644 --- a/cpu/__init__.py +++ b/cpu/__init__.py @@ -1,3 +1,3 @@ from pystencils.cpu.kernelcreation import createKernel, addOpenMP from pystencils.cpu.cpujit import makePythonFunction -from pystencils.backends.cbackend import printCCode +from pystencils.backends.cbackend import generateC diff --git a/cpu/cpujit.py b/cpu/cpujit.py index af1d43471d37a6fa647c3e992605ef8f937aa39e..cd1f0b2eb1c1eb59a91ed48210bb66e7712439a2 100644 --- a/cpu/cpujit.py +++ b/cpu/cpujit.py @@ -2,7 +2,7 @@ import os import subprocess from ctypes import cdll, c_double, c_float, sizeof from tempfile import TemporaryDirectory -from pystencils.backends.cbackend import printCCode +from pystencils.backends.cbackend import generateC import numpy as np @@ -67,7 +67,7 @@ def compileAndLoad(kernelFunctionNode): print('#include <iostream>', file=sourceFile) print("#include <cmath>", file=sourceFile) print('extern "C" { ', file=sourceFile) - print(printCCode(kernelFunctionNode), file=sourceFile) + print(generateC(kernelFunctionNode), file=sourceFile) print('}', file=sourceFile) compilerCmd = [CONFIG['compiler']] + CONFIG['flags'].split()