Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions diskann/src/neighbor/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::{
marker::PhantomData,
};

#[cfg(target_arch = "x86_64")]
use diskann_wide::{SIMDMask, SIMDPartialOrd, SIMDVector};

use super::Neighbor;
Expand Down Expand Up @@ -226,6 +227,7 @@ impl<I: NeighborPriorityQueueIdType> NeighborPriorityQueue<I> {
/// 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<I>) -> usize {
diskann_wide::alias!(f32s = f32x8);
let target = f32s::splat(diskann_wide::ARCH, nbr.distance);
Expand Down Expand Up @@ -279,6 +281,22 @@ impl<I: NeighborPriorityQueueIdType> NeighborPriorityQueue<I> {
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<I>) -> 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<I> {
debug_assert!(index < self.size);
Expand Down
Loading