From 3e00ddfde542a740bf9ea0843c4c073445ff4c91 Mon Sep 17 00:00:00 2001 From: Martin Bauer <martin.bauer@fau.de> Date: Thu, 3 Nov 2016 16:56:38 +0100 Subject: [PATCH] demo notebook & fixes in gitlab-ci.yml --- backends/cbackend.py | 6 +++--- cpu/__init__.py | 2 +- cpu/cpujit.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/backends/cbackend.py b/backends/cbackend.py index 9f1620da9..ef24a39fb 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 71656ee6c..039f12025 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 af1d43471..cd1f0b2eb 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() -- GitLab