srdatalog.ir.codegen.cuda.pipeline_utils¶
Pipeline-shape utilities used by complete_runner.
Originally ported from src/srdatalog/codegen/target_jit/ jit_emit_helpers.nim — the legacy Filter / ConstantBind / InsertInto
emit procs (jit_filter, jit_constant_bind, jit_insert_into) used
to live here too. They’ve been retired alongside the rest of the
legacy ir/dialects/target/cuda/pipeline.py chain; the dialect now owns those
emits via dialects.relation.sorted_array.lowerings._lower_inner_chain
and _lower_insert_into.
What remains:
has_balanced_scan/get_balanced_scan_info— used to decide whether to emit a balanced-scan kernel variant.has_tiled_cartesian_eligible— runner uses this to decide whether to enable the tiled-Cartesian materialize path.assign_handle_positions/count_handles_in_pipeline— pipeline pre-pass + view-slot counting. Note:dialects.target.cuda. envelopehas its ownassign_handle_positionsfor the dialect path; this one stays for the runner-side prepass that mutatesmutable_pipebefore kernel emission.
Module Contents¶
Classes¶
Lightweight struct returned by get_balanced_scan_info. |
Functions¶
Assign |
|
Max |
|
Extract group var + per-source (rel, index, handle_idx) from the root BalancedScan. Returns an all-empty BalancedScanInfo when the root op isn’t a BalancedScan (matching Nim’s sentinel return). |
|
True if the pipeline’s first op is a BalancedScan (root level). |
|
Pipeline contains a 2-source CartesianJoin where each source binds exactly one variable — eligible for the atomic-free tiled/coalesced write optimization. |
API¶
- class srdatalog.ir.codegen.cuda.pipeline_utils.BalancedScanInfo[source]¶
Lightweight struct returned by get_balanced_scan_info.
- srdatalog.ir.codegen.cuda.pipeline_utils.assign_handle_positions(ops: list[srdatalog.ir.mir.types.MirNode]) None[source]¶
Assign
handle_startto every source-bearing node in pipeline order starting from 0. Mutatesopsin place. Mirrors Nim’s assignHandlePositions.
- srdatalog.ir.codegen.cuda.pipeline_utils.count_handles_in_pipeline(ops: list[srdatalog.ir.mir.types.MirNode]) int[source]¶
Max
handle_start + 1seen across the pipeline — the number of view slots the kernel’sviews[]array needs. Zero when no op carries a handle_start (caller should still allocate 1 slot in that case; this function faithfully returns 0 to match Nim).
- srdatalog.ir.codegen.cuda.pipeline_utils.get_balanced_scan_info(ops: list[srdatalog.ir.mir.types.MirNode]) srdatalog.ir.codegen.cuda.pipeline_utils.BalancedScanInfo[source]¶
Extract group var + per-source (rel, index, handle_idx) from the root BalancedScan. Returns an all-empty BalancedScanInfo when the root op isn’t a BalancedScan (matching Nim’s sentinel return).
- srdatalog.ir.codegen.cuda.pipeline_utils.has_balanced_scan(ops: list[srdatalog.ir.mir.types.MirNode]) bool[source]¶
True if the pipeline’s first op is a BalancedScan (root level).
- srdatalog.ir.codegen.cuda.pipeline_utils.has_tiled_cartesian_eligible(ops: list[srdatalog.ir.mir.types.MirNode]) bool[source]¶
Pipeline contains a 2-source CartesianJoin where each source binds exactly one variable — eligible for the atomic-free tiled/coalesced write optimization.