4 ms·
Every CPU and GPU now has popcount [1] instruction. You can thank US three letter agencies for that [2]. [1] https://en.wikipedia.org/wiki/Hamming_weight#Pro
by thesz 3y ago
Every CPU and GPU now has popcount [1] instruction. You can thank US three letter agencies for that [2].
[1] https://en.wikipedia.org/wiki/Hamming_weight#Processor_support
[2] https://vaibhavsagar.com/blog/2019/09/08/popcount/
Multiplication then is just bitwise AND and a popcount.