Skip to content

Commit 0a712cd

Browse files
committed
simpler
Signed-off-by: Robert Kruszewski <github@robertk.io>
1 parent d3c062d commit 0a712cd

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

vortex-buffer/benches/vortex_bitbuffer.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ fn slice_arrow_buffer(bencher: Bencher, length: usize) {
166166
#[divan::bench(args = INPUT_SIZE)]
167167
fn true_count_vortex_buffer(bencher: Bencher, length: usize) {
168168
let buffer = BitBuffer::from_iter((0..length).map(true_count_pattern));
169+
buffer.true_count();
170+
169171
bencher
170172
.with_inputs(|| &buffer)
171173
.bench_refs(|buffer| buffer.true_count())
@@ -176,6 +178,9 @@ fn true_count_arrow_buffer(bencher: Bencher, length: usize) {
176178
let buffer = Arrow(BooleanBuffer::from_iter(
177179
(0..length).map(true_count_pattern),
178180
));
181+
182+
buffer.0.count_set_bits();
183+
179184
bencher
180185
.with_inputs(|| &buffer)
181186
.bench_refs(|buffer| buffer.0.count_set_bits());

vortex-buffer/src/bit/count_ones.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,6 @@ fn mask_byte(byte: u8, bit_offset: usize, bit_len: usize) -> u8 {
7070
fn count_ones_aligned(bytes: &[u8]) -> usize {
7171
#[cfg(target_arch = "x86_64")]
7272
{
73-
// When the target feature is guaranteed at compile time, skip runtime detection.
74-
#[cfg(all(target_feature = "avx512f", target_feature = "avx512vpopcntdq"))]
75-
if bytes.len() >= 64 {
76-
// SAFETY: Compile-time target feature guarantees availability.
77-
return unsafe { count_ones_aligned_avx512(bytes) };
78-
}
79-
80-
#[cfg(all(
81-
not(all(target_feature = "avx512f", target_feature = "avx512vpopcntdq")),
82-
target_feature = "avx2"
83-
))]
84-
if bytes.len() >= 32 {
85-
// SAFETY: Compile-time target feature guarantees availability.
86-
return unsafe { count_ones_aligned_avx2(bytes) };
87-
}
88-
89-
// Fall back to runtime detection when features aren't compile-time guaranteed.
90-
#[cfg(not(all(target_feature = "avx512f", target_feature = "avx512vpopcntdq")))]
9173
if bytes.len() >= 64
9274
&& is_x86_feature_detected!("avx512f")
9375
&& is_x86_feature_detected!("avx512vpopcntdq")
@@ -96,7 +78,6 @@ fn count_ones_aligned(bytes: &[u8]) -> usize {
9678
return unsafe { count_ones_aligned_avx512(bytes) };
9779
}
9880

99-
#[cfg(not(target_feature = "avx2"))]
10081
if bytes.len() >= 32 && is_x86_feature_detected!("avx2") {
10182
// SAFETY: Runtime detection guarantees the required target features.
10283
return unsafe { count_ones_aligned_avx2(bytes) };

0 commit comments

Comments
 (0)