(a: &[u8], b: &[u8])
| 22 | static DISPATCH: OnceLock<HammingFn> = OnceLock::new(); |
| 23 | |
| 24 | fn scalar(a: &[u8], b: &[u8]) -> u32 { |
| 25 | let chunks = a.len() / 8; |
| 26 | let rem = a.len() % 8; |
| 27 | let mut count = 0u32; |
| 28 | for i in 0..chunks { |
| 29 | let av = u64::from_ne_bytes(a[i * 8..i * 8 + 8].try_into().unwrap_or([0u8; 8])); |
| 30 | let bv = u64::from_ne_bytes(b[i * 8..i * 8 + 8].try_into().unwrap_or([0u8; 8])); |
| 31 | count += (av ^ bv).count_ones(); |
| 32 | } |
| 33 | let base = chunks * 8; |
| 34 | for i in 0..rem { |
| 35 | count += (a[base + i] ^ b[base + i]).count_ones(); |
| 36 | } |
| 37 | count |
| 38 | } |
| 39 | |
| 40 | #[cfg(target_arch = "x86_64")] |
| 41 | #[target_feature(enable = "avx512f,avx512vpopcntdq")] |
nothing calls this directly
no test coverage detected