diff --git a/diskann/src/neighbor/queue.rs b/diskann/src/neighbor/queue.rs index f4991574ec..4559fd639e 100644 --- a/diskann/src/neighbor/queue.rs +++ b/diskann/src/neighbor/queue.rs @@ -8,6 +8,7 @@ use std::{ marker::PhantomData, }; +#[cfg(target_arch = "x86_64")] use diskann_wide::{SIMDMask, SIMDPartialOrd, SIMDVector}; use super::Neighbor; @@ -226,6 +227,7 @@ impl NeighborPriorityQueue { /// Get the lower bound of the neighbor - the index of the first neighbor /// that has a distance greater than or equal to the target neighbor /// PERFORMANCE: This function is performance critical - please benchmark any changes + #[cfg(target_arch = "x86_64")] fn get_lower_bound(&mut self, nbr: &Neighbor) -> usize { diskann_wide::alias!(f32s = f32x8); let target = f32s::splat(diskann_wide::ARCH, nbr.distance); @@ -279,6 +281,22 @@ impl NeighborPriorityQueue { self.size } + /// Get the lower bound of the neighbor - the index of the first neighbor + /// that has a distance greater than or equal to the target neighbor + /// PERFORMANCE: This function is performance critical - please benchmark any changes + #[cfg(not(target_arch = "x86_64"))] + fn get_lower_bound(&mut self, nbr: &Neighbor) -> usize { + let target = nbr.distance; + + for (i, d) in self.distances.iter().take(self.size).enumerate() { + if *d >= target { + return i; + } + } + + self.size + } + /// Get the neighbor at index - SAFETY: index must be less than size fn get_unchecked(&self, index: usize) -> Neighbor { debug_assert!(index < self.size);