Lambdas
Implement a simple codegen.Lambda
code object that encapsulates a single pystencils expression, is annotated with its free symbols as parameters, can be printed out as C++ code, and evaluated on-the-fly.
Use Cases
There are several cases where we need to be able to both print out as code and/or evaluate singular backend AST expressions that accompany a kernel produced by the code generator:
- The
GpuThreadsRange
holds up to three expressions describing the size of the GPU launch grid required by a kernel. These have to be evaluated by the JIT compiler within pystencils, and must be printed out when integrating the kernel into a C++ framework (waLBerla, pystencils-sfg in general). - The code generator should in the future be able to communicate assumptions about parameter values to the runtime system using kernel preconditions. A kernel precondition is a single backend-AST expression that evaluates to a boolean, annotated with an error message. The runtime system - either the pystencils-internal JIT, or waLBerla, etc. - should evaluate preconditions to check if kernel arguments are valid. This shall be used for e.g. pointer alignment checks, relative field size and layout checks, ...