Skip to content
Snippets Groups Projects
  • Martin Bauer's avatar
    Separated modules into subfolders with own setup.py · 1e02cdc7
    Martin Bauer authored
    This restructuring allows for easier separation of modules into
    separate repositories later. Also, now pip install with repo url can be
    used.
    
    The setup.py files have also been updated to correctly reference each
    other. Module versions are not extracted from git state
    1e02cdc7
generate.py 1.52 KiB
import sympy as sp
import numpy as np
from pystencils import Field, Assignment, create_kernel


def meassure():
    size = [30, 50, 3]
    arr = np.zeros(size)
    a = Field.create_from_numpy_array('a', arr, index_dimensions=1)
    b = Field.create_from_numpy_array('b', arr, index_dimensions=1)
    s = sp.Symbol("s")
    rhs = a[0, -1](0) + a[0, 1] + a[-1, 0] + a[1, 0]
    updateRule = Assignment(b[0, 0], s * rhs)
    print(updateRule)

    ast = create_kernel([updateRule])

    # benchmark = generate_benchmark(ast)
    # main = benchmark[0]
    # kernel = benchmark[1]
    # with open('src/main.cpp', 'w') as file:
    #     file.write(main)
    # with open('src/kernel.cpp', 'w') as file:
    #     file.write(kernel)

    func = ast.compile({'omega': 2/3})

    from pystencils.kerncraft_coupling.generate_benchmark import generate_benchmark
    from pystencils.kerncraft_coupling import BenchmarkAnalysis
    from pystencils.kerncraft_coupling.kerncraft_interface import PyStencilsKerncraftKernel, KerncraftParameters
    from kerncraft.machinemodel import MachineModel
    from kerncraft.models import ECMData


    machineFilePath = "../pystencils_tests/kerncraft_inputs/default_machine_file.yaml"
    machine = MachineModel(path_to_yaml=machineFilePath)


    benchmark = BenchmarkAnalysis(ast, machine)
    #TODO what do i want to do with benchmark?

    kernel = PyStencilsKerncraftKernel(ast)
    model = ECMData(kernel, machine, KerncraftParameters())
    model.analyze()
    model.report()


if __name__ == "__main__":
    meassure()