MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / neon

Function neon

nodedb-codec/src/vector_quant/hamming.rs:104–123  ·  view source on GitHub ↗
(a: &[u8], b: &[u8])

Source from the content-addressed store, hash-verified

102
103#[cfg(target_arch = "aarch64")]
104fn neon(a: &[u8], b: &[u8]) -> u32 {
105 use std::arch::aarch64::*;
106 let mut count = 0u32;
107 let chunks = a.len() / 16;
108 let rem = a.len() % 16;
109 unsafe {
110 for i in 0..chunks {
111 let va = vld1q_u8(a.as_ptr().add(i * 16));
112 let vb = vld1q_u8(b.as_ptr().add(i * 16));
113 let xored = veorq_u8(va, vb);
114 let popcnt = vcntq_u8(xored);
115 count += vaddvq_u8(popcnt) as u32;
116 }
117 }
118 let base = chunks * 16;
119 for i in 0..rem {
120 count += (a[base + i] ^ b[base + i]).count_ones();
121 }
122 count
123}
124
125fn resolve() -> HammingFn {
126 #[cfg(target_arch = "x86_64")]

Callers

nothing calls this directly

Calls 4

count_onesMethod · 0.80
lenMethod · 0.45
addMethod · 0.45
as_ptrMethod · 0.45

Tested by

no test coverage detected