Skip to content

Add the SIMD table generator script (#858)#858

Open
terrelln wants to merge 8 commits into
facebook:devfrom
terrelln:export-D109893569
Open

Add the SIMD table generator script (#858)#858
terrelln wants to merge 8 commits into
facebook:devfrom
terrelln:export-D109893569

Conversation

@terrelln

@terrelln terrelln commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Summary:

Adds scripts/gen_pivco_huffman_tables.py, which renders the generated lookup-table headers consumed by the architecture-specific kernels (x86, neon, avx512). It is checked in ahead of the per-architecture kernels that include its output.

Reviewed By: kevinjzhang

Differential Revision: D109893569

@meta-cla meta-cla Bot added the cla signed label Jun 30, 2026
@meta-codesync

meta-codesync Bot commented Jun 30, 2026

Copy link
Copy Markdown

@terrelln has exported this pull request. If you are a Meta employee, you can view the originating Diff in D109893569.

terrelln and others added 8 commits July 16, 2026 07:50
Differential Revision: D109877948
Differential Revision: D109877947
Summary:
Adds byte-aligned bit reservation and pop primitives to the FF bitstream, needed by the upcoming PivCo-Huffman kernels:

- `ZS_BitCStreamFF_reserveAlignedBits` / `ZS_BitCStreamFF_commitReservedBits` on the write side.
- `ZS_BitDStreamFF_popAlignedBits` on the read side, plus a `begin` cursor in `ZS_BitDStreamFF` so the reader can compute byte offsets.
- `ZS_BitDStreamFF_finish` now returns the number of bytes consumed.
- Hardens `ZS_BitCStreamFF_init`/`_finish`/`_flush` against small buffers by avoiding pointer arithmetic that could underflow.

Differential Revision: D109878843
Summary:
Introduces the architecture-specific kernel interface for the PivCo-Huffman codec along with a portable, correctness-oriented generic implementation and the kernel test suite.

- `arch/common_pivco_arch.h`: shared `ZL_PIVCO_HUFFMAN_SLOP` contract.
- `arch/{encode,decode}_pivco_arch.h`: the `ZL_PivCoHuffmanEncode` / `ZL_PivCoHuffmanDecode` function-pointer tables and the `_select()` dispatchers.
- `arch/{encode,decode}_pivco_arch.c`: the portable `_generic` implementation of every kernel (partition/pack on encode, merge/flat-depth on decode). `_select()` currently returns `_generic`; the SIMD kernels register themselves in later commits.
- `test_pivco_huffman.cpp`: the `PivCoHuffmanArchTest` suite that checks every supported kernel against an independent reference, parameterized over the registered architectures.

Differential Revision: D109878842
Summary: Adds `micro_pivco_huffman.cpp` and wires it into the micro benchmark harness (`micro_bench.{cpp,h}`) to measure the PivCo-Huffman encode/decode kernels.

Differential Revision: D110077474
Summary:
Implements the PivCo-Huffman kernel on top of the architecture kernel interface.

- `common_pivco_kernel.{h,c}`: the shared coding tree (`ZL_PivCoHuffmanTree`), `ZL_PivCoHuffman_computeTableLog`, rank/split helpers, and the block-size constants shared by both directions.
- `encode_pivco_kernel.{h,c}`: `ZL_PivCoHuffman_encode` plus its scratch/bound sizing.
- `decode_pivco_kernel.{h,c}`: `ZL_PivCoHuffman_decode` plus its scratch sizing.
- `test_pivco_huffman.cpp`: the `PivCoHuffmanKernelTest` cases exercising round-trips, multi-block and custom block sizes, tree construction, and corruption rejection through the kernel interface.

Differential Revision: D109882916
Summary:
Binds the PivCo-Huffman kernel into OpenZL as a real codec and registers it.

- `{encode,decode}_pivco_binding.{h,c}` and `graph_pivco_huffman.h`: the encoder/decoder transform bindings and the codec's graph definition.
- `zl_pivco_huffman.h` / `PivCoHuffman.hpp` / `Codecs.hpp`: the public C and C++ codec API.
- `zl_graphs.h`, `zl_public_nodes.h`, `private_nodes.h`, `wire_format.h`, `{encoder,decoder}_registry.c`, `graph_registry.c`: register the new node/graph and assign its wire-format id.
- `spec.md`: the on-wire format specification.
- `tests/registry/components/PivCoHuffman.cpp` and `OpenZLComponents.h`: integration coverage in the component registry.

Differential Revision: D109893484
Summary:
Pull Request resolved: facebook#858

Adds `scripts/gen_pivco_huffman_tables.py`, which renders the generated lookup-table headers consumed by the architecture-specific kernels (x86, neon, avx512). It is checked in ahead of the per-architecture kernels that include its output.

Reviewed By: kevinjzhang

Differential Revision: D109893569
@terrelln
terrelln force-pushed the export-D109893569 branch from 64d7683 to 1789c3f Compare July 16, 2026 15:46
@meta-codesync meta-codesync Bot changed the title Add the SIMD table generator script Add the SIMD table generator script (#858) Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant