Skip to content

Wire PivCo-Huffman into OpenZL as a codec#857

Open
terrelln wants to merge 7 commits into
facebook:devfrom
terrelln:export-D109893484
Open

Wire PivCo-Huffman into OpenZL as a codec#857
terrelln wants to merge 7 commits into
facebook:devfrom
terrelln:export-D109893484

Conversation

@terrelln

Copy link
Copy Markdown
Contributor

Summary:

  • Binds the PivCo-Huffman kernel into OpenZL as a codec and registers it.
  • Defines the header format, and wraps the kernel code added in prior diffs.
  • Spec is written into spec.md.
  • It is just hooked up as a private ZL_NODE_PIVCO_HUFFMAN, a stacked diff will add it to ZL_GRAPH_HUFFMAN.

Differential Revision: D109893484

terrelln and others added 7 commits June 30, 2026 11:07
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 codec and registers it.
* Defines the header format, and wraps the kernel code added in prior diffs.
* Spec is written into `spec.md`.
* It is just hooked up as a private `ZL_NODE_PIVCO_HUFFMAN`, a stacked diff will add it to `ZL_GRAPH_HUFFMAN`.

Differential Revision: D109893484
@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 D109893484.

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