srdatalog.ir.codegen.cuda.batchfile¶
JIT batch-file generation.
Ported from generate_batch_files_no_template.py on python-api-notemplate.
Drives a mir_types.Program through the runner-struct skeleton: per
ExecutePipeline, emit a JitRunner_<rule_name> struct wrapping the
kernel_count / kernel_materialize / phase-decomposed setup functions.
Much of the original is a scaffold — _generate_body returns the literal
string "unimplemented ", and generate_pipeline threads codegen state
but dispatches to commented-out handlers for the first op. This port
preserves that posture verbatim; filling in the actual C++ body for
ColumnJoin / CartesianJoin / Scan / Negation / Aggregate / Filter /
ConstantBind / BalancedScan roots is follow-up work to match what
jit_kernel.nim emits today.
Also fixes one bug in the original: mhk’s generate_runner duplicated
the setup() forward declaration twice in the phase-method block; the
port drops the duplicate.
Module Contents¶
Functions¶
Top-level batchfile generator. Consumes our |
|
Emit the kernel body for one pipeline. Dispatches on the first op’s
shape to set up the outer iteration, then delegates the rest to
|
|
Batch-file prelude: static C++ includes plus the schema-driven
|
|
Emit |
Data¶
API¶
- srdatalog.ir.codegen.cuda.batchfile.PRELUDE = <Multiline-String>¶
- srdatalog.ir.codegen.cuda.batchfile.generate_batchfile(program: srdatalog.ir.mir.types.Program, schema: srdatalog.ir.codegen.cuda.schema.SchemaDefinition, name: str) str[source]¶
Top-level batchfile generator. Consumes our
mir_types.Program(produced bycompile_to_mir) plus the schema + program name. Emits the prelude followed by oneJitRunner_...per pipeline.
- srdatalog.ir.codegen.cuda.batchfile.generate_pipeline(pipeline: srdatalog.ir.mir.types.ExecutePipeline, ctx: srdatalog.ir.codegen.cuda.helpers.CodeGenContext) str[source]¶
Emit the kernel body for one pipeline. Dispatches on the first op’s shape to set up the outer iteration, then delegates the rest to
_generate_body.Matches mhk’s original: this is mostly state mutation + a few comments; the actual per-op handlers are still commented-out TODOs.
- srdatalog.ir.codegen.cuda.batchfile.generate_prelude(schema: srdatalog.ir.codegen.cuda.schema.SchemaDefinition, name: str) str[source]¶
Batch-file prelude: static C++ includes plus the schema-driven
usingaliases and device-DB typedefs.
- srdatalog.ir.codegen.cuda.batchfile.generate_runner(pipeline: srdatalog.ir.mir.types.ExecutePipeline, program_name: str) tuple[str, str][source]¶
Emit
struct JitRunner_<rule_name> { ... }for one pipeline.Returns
(full, skeleton).fullis the complete struct;skeletonis reserved for a future header-only forward-decl variant (empty for now, matching mhk’s scaffolding).