Skip to main content

hashbrown/control/group/
mod.rs

1// TESTING NOTE:
2//
3// Because this module uses `cfg(..)` to select an implementation, it will not
4// be linted without being run on targets that actually load each of these
5// modules. Be sure to edit `ci/tools.sh` to add in the necessary cfgs if you
6// change these, so that your implementation gets properly linted.
7
8cfg_select! {
9    // Use the SSE2 implementation if possible: it allows us to scan 16 buckets
10    // at once instead of 8. We don't bother with AVX since it would require
11    // runtime dispatch and wouldn't gain us much anyways: the probability of
12    // finding a match drops off drastically after the first few buckets.
13    //
14    // I attempted an implementation on ARM using NEON instructions, but it
15    // turns out that most NEON instructions have multi-cycle latency, which in
16    // the end outweighs any gains over the generic implementation.
17    all(
18        target_feature = "sse2",
19        any(target_arch = "x86", target_arch = "x86_64"),
20    ) => {
21        mod sse2;
22        use sse2 as imp;
23    }
24    all(
25        target_arch = "aarch64",
26        target_feature = "neon",
27        // NEON intrinsics are currently broken on big-endian targets.
28        // See https://github.com/rust-lang/stdarch/issues/1484.
29        target_endian = "little",
30    ) => {
31        mod neon;
32        use neon as imp;
33    }
34    all(
35        feature = "nightly",
36        target_arch = "loongarch64",
37        target_feature = "lsx",
38        not(miri), // Miri does not support lsx
39    ) => {
40        mod lsx;
41        use lsx as imp;
42    }
43
44    _ => {
45        mod generic;
46        use generic as imp;
47    }
48}
49pub(crate) use self::imp::Group;
50pub(super) use self::imp::{BITMASK_ITER_MASK, BITMASK_STRIDE, BitMaskWord, NonZeroBitMaskWord};