Add `pystencils.make_python_function` used for KernelFunction.compile
KernelFunction.compile = None
is currently set by the
create_kernel
function of each respective backend as partial function
of <backend>.make_python_function
.
The code would be clearer with a unified make_python_function
.
KernelFunction.compile
can then be implemented as a call to this
function with the respective backend.
Merge request reports
Activity
Filter activity
added 1 commit
- 24222c87 - Add `pystencils.make_python_function` used for KernelFunction.compile
added 5 commits
-
24222c87...9b9a4b54 - 4 commits from branch
pycodegen:master
- 229e3950 - Add `pystencils.make_python_function` used for KernelFunction.compile
-
24222c87...9b9a4b54 - 4 commits from branch
added 1 commit
- cef0089c - Add `pystencils.make_python_function` used for KernelFunction.compile
added 1 commit
- 0a9b03b8 - Fix llvm by manually setting backend in KernelFunction
added 1 commit
- 64c0fb22 - Fix llvm by manually setting backend in KernelFunction
added 1 commit
- 34509925 - Fix llvm by manually setting backend in KernelFunction
Maybe we want to add a llvm test that's not a Jupyter Notebook:
# -*- coding: utf-8 -*- # # Copyright © 2019 Stephan Seitz <stephan.seitz@fau.de> # # Distributed under terms of the GPLv3 license. """ """ import llvmlite from pystencils.session import * def test_llvm(): size = (60, 70) # domain size u_arrays = [np.zeros(size), np.zeros(size), np.zeros(size)] u_fields = [ps.Field.create_from_numpy_array("u%s" % (name,), arr) for name, arr in zip(["0", "1", "2"], u_arrays)] for i, field in enumerate(u_fields): field.latex_name = "u^{(%d)}" % (i,) discretize = ps.fd.Discretization2ndOrder() def central2nd_time_derivative(fields): f_next, f_current, f_last = fields return (f_next[0, 0] - 2 * f_current[0, 0] + f_last[0, 0]) / discretize.dt**2 rhs = ps.fd.diffusion(u_fields[1], 1) wave_eq = sp.Eq(central2nd_time_derivative(u_fields), discretize(rhs)) wave_eq = sp.simplify(wave_eq) u_next_C = u_fields[-1][0, 0] update_rule = ps.Assignment(u_next_C, sp.solve(wave_eq, u_next_C)[0]) update_rule update_rule = update_rule.subs({discretize.dx: 0.1, discretize.dt: 0.05}) kernel = ps.create_kernel(update_rule, target='llvm') kernel.compile() def run_LLVM(timesteps=1): for t in range(timesteps): kernel(u0=u_arrays[0], u1=u_arrays[1], u2=u_arrays[2]) u_arrays[0], u_arrays[1], u_arrays[2] = u_arrays[1], u_arrays[2], u_arrays[0] return u_arrays[2] print('Yeah. LLVM does something without crashing') def main(): test_llvm() if __name__ == '__main__': main()
added 10 commits
-
34509925...305107fa - 8 commits from branch
pycodegen:master
- a7e61dc4 - Add `pystencils.make_python_function` used for KernelFunction.compile
- c15b21cc - Fix llvm by manually setting backend in KernelFunction
-
34509925...305107fa - 8 commits from branch
I think this change resolved this pull request. Can I close it?
Please register or sign in to reply