Skip to main content

count_ones_avx512

Function count_ones_avx512 

Source
pub unsafe fn count_ones_avx512(bits: &[Block]) -> u64
Examples found in repository?
crates/competitive/src/data_structure/bitset.rs (line 262)
253    pub fn count_ones(&self) -> u64 {
254        let words = self.words();
255        #[cfg(target_arch = "x86_64")]
256        if words.len() >= 8 {
257            if avx512_enabled()
258                && is_x86_feature_detected!("avx512f")
259                && is_x86_feature_detected!("avx512vpopcntdq")
260            {
261                // SAFETY: blocks are aligned and feature detection checked both requirements.
262                return unsafe { simd::count_ones_avx512(&self.bits) };
263            }
264            if is_x86_feature_detected!("avx2") {
265                // SAFETY: 64-byte alignment also satisfies AVX2 and feature detection checked it.
266                return unsafe { simd::count_ones_avx2(&self.bits) };
267            }
268        }
269        words.iter().map(|word| word.count_ones() as u64).sum()
270    }