Use the accelerated Count on AVX-512 CPUs

The AVX-512 level fell through to the generic loop. _count only needs
POPCNT, which every AVX-512 CPU has.

Fixes #46
This commit is contained in:
dualfroz committed 2026-10-02 16:28:14 +02:00
1 parent 47698fd8b9
commit d648d30d86
2 files changed
+15 -1

No files matched your search

+14
View File
@@ -419,6 +419,20 @@ func TestCount(t *testing.T) {
assert.Equal(t, 9, b.CountTo(128))
}
func TestCountWithHardware(t *testing.T) {
defer func(level int) { hardware = level }(hardware)
var b Bitmap
for i := uint32(0); i < 10000; i += 3 {
b.Set(i)
}
for _, level := range []int{isUnsupported, isAccelerated, isAVX512} {
hardware = level
assert.Equal(t, 3334, b.Count(), "hardware=%d", level)
}
}
func TestGrow(t *testing.T) {
bitmap := make(Bitmap, 1, 5)
bitmap[0] = 42