Faster Positional-Population Counts for AVX2, AVX-512, and ASIMD
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.
- Publication:
-
arXiv e-prints
- Pub Date:
- December 2024
- DOI:
- arXiv:
- arXiv:2412.16370
- Bibcode:
- 2024arXiv241216370C
- Keywords:
-
- Computer Science - Data Structures and Algorithms
- E-Print:
- 23 pages, 11 figures. Associated source code can be found on line at https://github.com/clausecker/pospop and https://github.com/lemire/pospopcnt_avx512