Counting Distance Calculations for IndexHNSWFlat L2-distance search #3260
AnshKetchum
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi All,
I am using faiss for a face recognition application. I would like to find out how many distance calculations are done by IndexHNSWFlat (with the default L2 distance metric) for different permutations of query sizes, threads and index size (i.e. number of vectors added via IndexHNSWFlat::add() call).
Without getting too deep into the faiss code base, here is my quick and dirty implementation.
I added 'unsigned long counter' in distance_simd.cpp and increment the counter in "
float fvec_L2sqr(const float* x, const float* y, size_t d) {}
".When I read out my counter (
fvec_l2sqr_distance_counter
) in my application, I get value which appears correct, but it seems to change for same query when I increase number of thread counts (via omp_set_num_threads() call). I think # of distance calculations for a given query in same database should not change with increasing number of threads. Does my way of counting each distance calculation appear thread-safe? If not, could someone please suggest thread-safe method of counting distance calculations for IndexHNSWFlag::search()?Thanks.
Beta Was this translation helpful? Give feedback.
All reactions