Skip to main content

all_avx2

Function all_avx2 

Source
pub unsafe fn all_avx2(bits: &[Block]) -> bool
Examples found in repository?
crates/competitive/src/data_structure/bitset.rs (line 212)
198    pub fn all(&self) -> bool {
199        let words = self.words();
200        let full_words = self.size >> 6;
201        #[cfg(target_arch = "x86_64")]
202        if self.size >> 9 >= SIMD_MIN_BLOCKS {
203            let full_blocks = self.size >> 9;
204            if words[0] != u64::MAX {
205                return false;
206            }
207            let full_blocks_are_set = if avx512_enabled() && is_x86_feature_detected!("avx512f") {
208                // SAFETY: blocks are 64-byte aligned and feature detection checked AVX-512F.
209                Some(unsafe { simd::all_avx512(&self.bits[..full_blocks]) })
210            } else if is_x86_feature_detected!("avx2") {
211                // SAFETY: 64-byte alignment also satisfies AVX2 and feature detection checked it.
212                Some(unsafe { simd::all_avx2(&self.bits[..full_blocks]) })
213            } else {
214                None
215            };
216            if let Some(full_blocks_are_set) = full_blocks_are_set {
217                return full_blocks_are_set
218                    && words[full_blocks * 8..full_words]
219                        .iter()
220                        .all(|&word| word == u64::MAX)
221                    && (self.size & 63 == 0
222                        || words[full_words] == u64::MAX >> (64 - (self.size & 63)));
223            }
224        }
225        if self.size & 63 == 0 {
226            return words.iter().all(|&word| word == u64::MAX);
227        }
228        words[..full_words].iter().all(|&word| word == u64::MAX)
229            && words[full_words] == u64::MAX >> (64 - (self.size & 63))
230    }