Skip to main content

Module rule_catalog

Module rule_catalog 

Source
Expand description

DFA rule catalog packing for batched megakernel dispatch.

Structs§

BatchRuleProgram
One compiled DFA-backed rule program consumed by the batch dispatcher.
BatchRuleRejection
One rule rejected from a megakernel batch while other rules still ran.
PackedRuleCatalog
Packed rule catalog uploaded to device storage buffers.
RuleCatalogPackingScratch
Caller-owned storage for packing rule catalogs without rebuilding host allocations on every refresh.
RuleMeta
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 dense state * 256 + byte table. The on-device packed table is byte-class compressed (see pack_rule_catalog_into); this constant is the source alphabet width the compressor folds DOWN from.
RULE_META_WORDS
Number of u32 words per rule metadata entry. The kernel reads these in order: transition_base, accept_base, state_count, class_map_base, num_classes. Bump in lockstep with RuleMeta and the dispatcher’s dfa_byte_scanner if 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_classes transition block for a dense state_count * 256 table to out, given the byte→class class_map from build_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_classes transition table (from compress_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 by try_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.