From 190802538aeba9b491b1c3ee693838feee5b51dc Mon Sep 17 00:00:00 2001 From: Andreas Huber Date: Fri, 21 Aug 2026 06:30:10 -0700 Subject: [PATCH] Declare the missing AVX2 extern template for L2 at d=160 The AVX2 `extern template` list in euclidean.h listed 200 twice and never listed 160, while avx2.cpp instantiates L2 at 160 like every other extent. With no declaration in the header, a consumer translation unit implicitly instantiates `L2Impl<160, ..., AVX2>` itself, at the consumer's own `-march`. Against the baseline `-march=x86-64` the library is built with, that local copy is a scalar loop (movss/subss/mulss/addss, 50 bytes) rather than the 508-byte AVX2 kernel that is sitting unused in libsvs_x86_objects.a -- so the AVX2 dispatch path silently runs unvectorized code at d=160, and differs between translation units, which is an ODR violation. inner_product.h and cosine.h already list all nine extents correctly; this brings euclidean.h in line with them and with avx2.cpp. Verified by compiling a consumer at -march=x86-64: `L2Impl<160, float, float, AVX2>` goes from a locally defined symbol to an undefined reference resolved from the archive, matching 128 and 200. Co-Authored-By: Claude Opus 5 --- include/svs/core/distance/euclidean.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/svs/core/distance/euclidean.h b/include/svs/core/distance/euclidean.h index b038a6fcc..08aed5d25 100644 --- a/include/svs/core/distance/euclidean.h +++ b/include/svs/core/distance/euclidean.h @@ -452,8 +452,8 @@ DISTANCE_L2_EXTERN_TEMPLATE(Dynamic, AVX_AVAILABILITY::AVX512); DISTANCE_L2_EXTERN_TEMPLATE(64, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(96, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(100, AVX_AVAILABILITY::AVX2); -DISTANCE_L2_EXTERN_TEMPLATE(200, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(128, AVX_AVAILABILITY::AVX2); +DISTANCE_L2_EXTERN_TEMPLATE(160, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(200, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(512, AVX_AVAILABILITY::AVX2); DISTANCE_L2_EXTERN_TEMPLATE(768, AVX_AVAILABILITY::AVX2);