TL;DR
This paper introduces a high-performance Huffman encoder designed specifically for modern GPU architectures, overcoming traditional bottlenecks in parallel codebook construction and memory bandwidth utilization. By implementing a novel reduction-based encoding scheme and a fine-grained parallel codebook builder, the authors achieved throughputs exceeding 300 GB/s, outperforming state-of-the-art GPU encoders by up to 6.8x.
What Problem Does This Paper Address?
High-performance computing (HPC) simulations, like those for cosmology or weather modeling, generate petabytes of data that create massive storage and I/O bottlenecks. Data compression is the standard solution, and Huffman coding—a variable-length entropy encoding method—is a fundamental building block for many compression algorithms (like GZIP and SZ).
However, Huffman coding is notoriously difficult to parallelize on GPUs for two main reasons:
- Serial Codebook Construction: Traditionally, building the Huffman tree and codebook is a serial process. For modern HPC use cases that require large symbol sets (e.g., 65,536 symbols instead of the standard 256), this serial step becomes a major performance bottleneck.
- Irregular Memory Access: Because Huffman codes have variable lengths, concatenating them into a bitstream usually involves irregular memory writes. This prevents GPUs from using "memory coalescing," a technique essential for reaching peak memory bandwidth.
Methods
The authors propose a modularized GPU Huffman encoder consisting of four stages: histogramming, codebook generation, canonization, and encoding. Their primary innovations lie in stages 2 and 4:
- Parallel Codebook Construction: They implemented a parallel algorithm based on the PRAM (Parallel Random Access Machine) model, which directly generates codeword lengths and then the codes themselves. This approach utilizes fine-grained parallelism where each thread handles an individual symbol, significantly speeding up the process for large codebooks.
- Reduction-Based Encoding: To solve the memory bandwidth issue, they introduced a two-phase merging scheme:
- Reduce-Merge: Threads iteratively merge pairs of codewords. By merging multiple small codewords into a larger "word" before writing to memory, they reduce the number of active threads and increase the amount of data moved per thread, better saturating the GPU's bandwidth.
- Shuffle-Merge: A final step to pack the merged groups into a dense, continuous bitstream.
The authors utilized state-of-the-art CUDA APIs like Cooperative Groups to synchronize threads across the entire GPU grid without the overhead of multiple kernel launches.
Datasets
The encoder was evaluated on a diverse set of real-world datasets:
- Single-Byte:
enwik8andenwik9(Wikipedia dumps),nci(chemical structures),mr(medical images), andFlan_1565(sparse matrix). - Multi-Byte/HPC:
Nyx-Quant(quantization codes from a cosmological simulation) andgbbct1.seq(DNA sequences analyzed using k-mers).
Key Insights and Ideas
- Moving Beyond 256 Symbols: While classic Huffman coding often stops at 8-bit symbols, scientific data often requires 10-bit to 16-bit symbols. The authors showed that their parallel codebook construction becomes more beneficial as the number of symbols increases.
- The Bandwidth-Parallelism Trade-off: In Huffman encoding, mapping one thread to one symbol (1-to-1) is actually inefficient because it results in many threads moving very few bits. The "Reduce-Merge" strategy (shown below) effectively "batches" these movements to respect the GPU's memory architecture.
Key Results
- Throughput: On an NVIDIA V100 GPU, the encoder reached a peak throughput of 314.6 GB/s on the
Nyx-Quantdataset. - Speedups:
- vs. GPU Baselines: Up to 5.0x faster on RTX 5000 and 6.8x faster on V100 compared to
cuSZ, the previous state-of-the-art GPU Huffman encoder.
- vs. GPU Baselines: Up to 5.0x faster on RTX 5000 and 6.8x faster on V100 compared to
- vs. CPU Baselines: Up to 3.3x faster than a multi-threaded implementation running on two 28-core Intel Xeon Platinum CPUs.
- Codebook Efficiency: The parallel codebook construction was up to 45.5x faster than serial implementations for large symbol sets (8192 symbols).
Limitations and Future Work
- Low-Compression Data: The current "reduction factor" logic is optimized for high-compression scenarios. The authors noted that performance on data with low compression ratios (where codewords are longer) needs further tuning.
- Bank Conflicts: The "Shuffle-Merge" phase involves variable-length data that can lead to shared memory bank conflicts, which the authors plan to investigate and mitigate in future iterations.
- Histogram Scaling: The current optimal histogramming implementation is limited to roughly 8192 symbols; scaling this to even larger symbol sets remains a challenge.
Summary updated