Repository navigation
Conversation
Co-authored-by: ChatGPT <noreply@openai.com>
|
@whahnsr Thank you for this contribution. Although I can envision some vectorization being enabled by this partial unrolling of the loop, I found that it actually consistently slowed down compression on a Mac M2 using Apple Clang 17.0.0. Running the speed test (see the examples directory), throughput dropped from 1971 MB/s to 1736 MB/s. Because the speed test uses just a single block of data, which could skew things like branch prediction, I also ran It's clearly possible that we'd observe different performance behavior using other compilers and ISAs, but I'm quite reluctant to adopt a change that complicates the code without a clear and consistent performance benefit. I will say that we are quite aware that bit extraction is a bottleneck and have devised some fairly sophisticated solutions, including one based on fast divide-and-conquer binary matrix transposition (think of the bit planes as columns of a binary matrix that is stored as rows). As currently written, there are up to The code is ugly, though, and looks something like this for 3D blocks of 64-bit integers: Instead of storing the result in |
|
Thanks, Peter, for the careful benchmarking and detailed technical explanation. The regression on Apple M2, despite the improvement measured on my Intel/GCC system, makes a good case against adopting this change as-is, particularly given the added complexity. I appreciate the explanation of the binary matrix transposition approach. It's an interesting direction for future investigation. I'll close this PR for now. Thanks again for taking the time to evaluate it. |
Summary
Use four independent accumulators to construct bit planes in
encode_few_ints, reducing the serial accumulation dependency.
Each input bit occupies a distinct output position, preserving
the encoded bitstream.
Performance
Measured on an Intel Core i7-4770S (GCC 13.3, four OpenMP threads),
compressing a 256^3 float array at 8 bits/value.
Each measurement comprises 20 compressions; results are averages
of three measurements.
Profiling identified bit-plane extraction as the dominant hotspot,
accounting for 68% of sampled CPU cycles before optimization.
Validation
AI assistance
The optimization was developed with assistance from ChatGPT.
The author reviewed the change and performed the builds,
performance measurements, and correctness validation.