srdatalog.ir.codegen.cuda.orchestrator¶
JIT orchestrator — step_N() method bodies.
Port of src/srdatalog/codegen/target_jit/jit_orchestrator.nim. Named
orchestrator_jit to avoid colliding with the existing legacy
codegen/orchestrator.py (mhk’s python-api-notemplate design, which
this module replaces for byte-match purposes).
Top-level entry:
gen_step_body(plan, db_type_name, is_recursive, step_num, count_only_rels)
= the full template <typename DB>\n static void step_N(...)
function, including fixpoint loop for recursive steps and
straight-line sequence for non-recursive.
Internal structure (mirrors Nim procs):
gen_index_spec_type(rel, ver, cols) — IndexSpecT<R, integer_sequence<int,...>, V>
version_string(ver) — MIR version -> C++ const
extract_source_info(src_spec) — (rel, ver, idx) from any source node
build_dest_stream_map(exec_ops) — dest rel -> [stream indices]
all_dests_independent(dest_streams) — every dest written by ≤1 stream
is_count_only_pipeline(instr, cors) — dest in count-only set
gen_instruction_code(instr, indent, iter_var, dest_stream_map, count_only_rels)
— BIG dispatcher
collect_canonical_specs(instrs) — canonical index per rel
gen_fixpoint_body(plan, db, indent, cors) — recursive path
gen_non_recursive_block(plan, db, indent, cors) — non-recursive path
Scope: baseline. WS / BG / dedup / fan-out variants of ExecutePipeline emission use the same dispatcher paths Nim does (the feature flags are read off the ExecutePipeline node itself, not the context), so the generated C++ is correct for those rules too — the difference is that our kernel-side emit doesn’t yet produce the matching WS / BG kernel bodies. The orchestrator half is self-contained.
Module Contents¶
Functions¶
dest rel → list of stream indices (one per pipeline) that write to it. |
|
First (rel, cols) per relation appearing in ComputeDelta /
ComputeDeltaIndex / MergeIndex ops. Used for |
|
Pull |
|
Recursive path: fixpoint loop with convergence check + maintenance ops + post-fixpoint reconstruct for each canonical rel. |
|
|
|
Emit imperative C++ for one fixpoint-level MIR instruction. |
|
Non-recursive path. Handles Block / FixpointPlan / ExecutePipeline / PostStratumReconstructInternCols. |
|
Matches Nim’s |
|
Convert MIR version name to C++ constant. Nim accepts both
forms ( |
API¶
- srdatalog.ir.codegen.cuda.orchestrator.all_dests_independent(dest_streams: dict[str, list[int]]) bool[source]¶
- srdatalog.ir.codegen.cuda.orchestrator.build_dest_stream_map(exec_ops: list[srdatalog.ir.mir.types.ExecutePipeline]) dict[str, list[int]][source]¶
dest rel → list of stream indices (one per pipeline) that write to it.
- srdatalog.ir.codegen.cuda.orchestrator.collect_canonical_specs(instrs: list[srdatalog.ir.mir.types.MirNode]) list[tuple[str, list[int]]][source]¶
First (rel, cols) per relation appearing in ComputeDelta / ComputeDeltaIndex / MergeIndex ops. Used for
using R_canonical_spec_tdeclarations and the fixpoint convergence check.
- srdatalog.ir.codegen.cuda.orchestrator.extract_source_info(src_spec: srdatalog.ir.mir.types.MirNode) tuple[str, str, list[int]][source]¶
Pull
(rel_name, version-as-C++-code, index)from any source node.
- srdatalog.ir.codegen.cuda.orchestrator.gen_fixpoint_body(plan: srdatalog.ir.mir.types.FixpointPlan, db_type_name: str, indent: str, count_only_rels: set[str] | None = None) str[source]¶
Recursive path: fixpoint loop with convergence check + maintenance ops + post-fixpoint reconstruct for each canonical rel.
- srdatalog.ir.codegen.cuda.orchestrator.gen_index_spec_type(rel_name: str, version: str, cols: list[int]) str[source]¶
SRDatalog::mir::IndexSpecT<Rel, std::integer_sequence<int, ...>, VER>
- srdatalog.ir.codegen.cuda.orchestrator.gen_instruction_code(instr: srdatalog.ir.mir.types.MirNode, indent: str, iter_var: str, dest_stream_map: dict[str, list[int]], count_only_rels: set[str] | None = None) str[source]¶
Emit imperative C++ for one fixpoint-level MIR instruction.
- srdatalog.ir.codegen.cuda.orchestrator.gen_non_recursive_block(plan: srdatalog.ir.mir.types.MirNode, db_type_name: str, indent: str, count_only_rels: set[str] | None = None) str[source]¶
Non-recursive path. Handles Block / FixpointPlan / ExecutePipeline / PostStratumReconstructInternCols.
- srdatalog.ir.codegen.cuda.orchestrator.gen_step_body(plan: srdatalog.ir.mir.types.MirNode, db_type_name: str, is_recursive: bool, step_num: int, count_only_rels: set[str] | None = None) str[source]¶
Matches Nim’s
genStepBody. Returns the fulltemplate <typename DB> static void step_N(...) { ... }function. What the fixture-dumping tool captures for each (node, is_recursive) pair in the MIR program.