Commit 0998f2e1 authored by Martin Bauer's avatar Martin Bauer
Browse files

Kerncraft interface: update to work with kerncraft 0.8.0

parent 920a47d5
Pipeline #15183 passed with stages
in 8 minutes and 41 seconds
......@@ -3,7 +3,7 @@ from tempfile import TemporaryDirectory
import sympy as sp
from collections import defaultdict
import kerncraft
import kerncraft.kernel
from kerncraft.kerncraft import KernelCode
from typing import Optional
from kerncraft.machinemodel import MachineModel
......@@ -16,7 +16,7 @@ from pystencils.utils import DotDict
import warnings
class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
class PyStencilsKerncraftKernel(KernelCode):
Implementation of kerncraft's kernel interface for pystencils CPU kernels.
Analyses a list of equations assuming they will be executed on a CPU
......@@ -42,6 +42,7 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
self.kernel_ast = ast
self.temporary_dir = TemporaryDirectory()
self._keep_intermediates = debug_print
# Loops
inner_loops = [l for l in filtered_tree_iteration(ast, LoopOverCoordinate, stop_type=SympyAssignment)
......@@ -127,14 +128,24 @@ class PyStencilsKerncraftKernel(kerncraft.kernel.KernelCode):
print("----------------------------- FLOPS -------------------------------")
def as_code(self, type_='iaca', openmp=False):
def as_code(self, type_='iaca', openmp=False, as_filename=False):
Generate and return compilable source code.
:param type: can be iaca or likwid.
:param openmp: if true, openmp code will be generated
type_: can be iaca or likwid.
openmp: if true, openmp code will be generated
return generate_benchmark(self.kernel_ast, likwid=type_ == 'likwid', openmp=openmp)
code = generate_benchmark(self.kernel_ast, likwid=type_ == 'likwid', openmp=openmp)
if as_filename:
fp, already_available = self._get_intermediate_file('kernel_{}.c'.format(type_),
if not already_available:
return code
class KerncraftParameters(DotDict):
......@@ -18,9 +18,12 @@ INPUT_FOLDER = os.path.join(SCRIPT_FOLDER, "kerncraft_inputs")
def test_compilation():
machine_file_path = os.path.join(INPUT_FOLDER, "default_machine_file.yaml")
machine = MachineModel(path_to_yaml=machine_file_path)
kernel_file_path = os.path.join(INPUT_FOLDER, "2d-5pt.c")
with open(kernel_file_path) as kernel_file:
reference_kernel = KernelCode(, machine=None, filename=kernel_file_path)
reference_kernel = KernelCode(, machine=machine, filename=kernel_file_path)
size = [30, 50, 3]
Supports Markdown
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