Expand description
DFA rule catalog packing for batched megakernel dispatch.
Structs§
- Batch
Rule Program - One compiled DFA-backed rule program consumed by the batch dispatcher.
- Batch
Rule Rejection - One rule rejected from a megakernel batch while other rules still ran.
- Packed
Rule Catalog - Packed rule catalog uploaded to device storage buffers.
- Rule
Catalog Packing Scratch - Caller-owned storage for packing rule catalogs without rebuilding host allocations on every refresh.
- Rule
Meta - Packed metadata for one byte-class-compressed DFA rule entry.
Constants§
- ALPHABET_
SIZE - Dense byte alphabet used by the DFA transition table as the INPUT
(
BatchRuleProgram) representation: every rule still arrives as a densestate * 256 + bytetable. The on-device packed table is byte-class compressed (seepack_rule_catalog_into); this constant is the source alphabet width the compressor folds DOWN from. - RULE_
META_ WORDS - Number of
u32words per rule metadata entry. The kernel reads these in order:transition_base,accept_base,state_count,class_map_base,num_classes. Bump in lockstep withRuleMetaand the dispatcher’sdfa_byte_scannerif the per-rule metadata grows.
Functions§
- accepted_
rule_ fingerprints - Fingerprints for the valid dense catalog entries.
- accepted_
rule_ fingerprints_ and_ rejections_ into - Fill caller-owned storage with fingerprints and rejection details for valid dense catalog entries.
- accepted_
rule_ fingerprints_ into - Fill caller-owned storage with fingerprints for valid dense catalog entries.
- build_
byte_ class_ map_ for_ table - Build the LOSSLESS byte→class map for one dense DFA into
out(resized to 256) and return the class count. - compress_
dense_ transitions_ into - Append the compressed
state_count * num_classestransition block for a densestate_count * 256table toout, given the byte→classclass_mapfrombuild_byte_class_map_for_table. - pack_
rule_ catalog - Pack valid DFA rules into compact shared device tables.
- pack_
rule_ catalog_ into - Pack valid DFA rules into caller-owned storage.
- try_
pack_ u16_ transitions_ into - Pack a byte-class-compressed
state_count * num_classestransition table (fromcompress_dense_transitions_into) into u16 targets stored two per u32 word: the LOW half holds the even flat index, the HIGH half the odd index. This halves the device transition footprint and narrows every transition-table read. Row deduplication does not provide this bound. - unpack_
u16_ transition - Unpack the
flat_index-th u16 transition target from a table packed bytry_pack_u16_transitions_into. The exact CPU mirror of the kernel’s unpack (word = packed[idx/2]; (word >> ((idx & 1) * 16)) & 0xFFFF), so the round-trip can be proven lossless without a GPU.