Faster Positional-Population Counts for AVX2, AVX-512, and ASIMD
Robert Clausecker, Daniel Lemire, Florian Schintke
TL;DR
This paper tackles the problem of efficiently computing positional population counts (pospopcnt) for arrays of $w$-bit words using SIMD. It extends Klarqvist et al. by introducing a refined Harley-Seal–style approach with simplified CSA networks, head/tail handling, and a fully bit-parallel accumulation that scales down to $w_{ ext{max}}$ and supports short inputs. The authors implement the method across AVX-512, AVX2, and ASIMD, demonstrating memory-bound performance even for input sizes as small as $4~\text{KiB}$ and outperforming prior work on several benchmarks. The work provides open-source implementations and a practical framework for porting to new architectures, with potential impact on bioinformatics, databases, and other domains requiring fast histogram-like computations over bit planes.
Abstract
The positional population count operation pospopcnt() counts for an array of w-bit words how often each of the w bits was set. Various applications in bioinformatics, database engineering, and digital processing exist. Building on earlier work by Klarqvist et al., we show how positional population counts can be rapidly computed using SIMD techniques with good performance from the first byte, approaching memory-bound speeds for input arrays of as little as 4 KiB. Improvements include an improved algorithm structure, better handling of unaligned and very short arrays, as well as faster bit-parallel accumulation of intermediate results. We provide a generic algorithm description as well as implementations for various SIMD instruction set extensions, including Intel AVX2, AVX-512, and ARM ASIMD, and discuss the adaption of our algorithm to other platforms.
