@@ -251,40 +251,8 @@ namespace hnswlib {
251
251
#endif
252
252
253
253
#if defined(USE_SSE) || defined(USE_AVX) || defined(USE_AVX512)
254
- static float
255
- InnerProductSIMD4Ext (const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
256
- DISTFUNC<float > simdfunc_;
257
- #if defined(USE_AVX)
258
- if (AVXCapable ())
259
- simdfunc_ = InnerProductSIMD4ExtAVX;
260
- else
261
- simdfunc_ = InnerProductSIMD4ExtSSE;
262
- #else
263
- simdfunc_ = InnerProductSIMD4ExtSSE;
264
- #endif
265
- return simdfunc_ (pVect1v, pVect2v, qty_ptr);
266
- }
267
-
268
- static float
269
- InnerProductSIMD16Ext (const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
270
- DISTFUNC<float > simdfunc_;
271
- #if defined(USE_AVX512)
272
- if (AVX512Capable ())
273
- simdfunc_ = InnerProductSIMD16ExtAVX512;
274
- else if (AVXCapable ())
275
- simdfunc_ = InnerProductSIMD16ExtAVX;
276
- else
277
- simdfunc_ = InnerProductSIMD16ExtSSE;
278
- #elif defined(USE_AVX)
279
- if (AVXCapable ())
280
- simdfunc_ = InnerProductSIMD16ExtAVX;
281
- else
282
- simdfunc_ = InnerProductSIMD16ExtSSE;
283
- #else
284
- simdfunc_ = InnerProductSIMD16ExtSSE;
285
- #endif
286
- return simdfunc_ (pVect1v, pVect2v, qty_ptr);
287
- }
254
+ DISTFUNC<float > InnerProductSIMD16Ext = InnerProductSIMD16ExtSSE;
255
+ DISTFUNC<float > InnerProductSIMD4Ext = InnerProductSIMD4ExtSSE;
288
256
289
257
static float
290
258
InnerProductSIMD16ExtResiduals (const void *pVect1v, const void *pVect2v, const void *qty_ptr) {
@@ -324,6 +292,19 @@ namespace hnswlib {
324
292
InnerProductSpace (size_t dim) {
325
293
fstdistfunc_ = InnerProduct;
326
294
#if defined(USE_AVX) || defined(USE_SSE) || defined(USE_AVX512)
295
+ #if defined(USE_AVX512)
296
+ if (AVX512Capable ())
297
+ InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX512;
298
+ else if (AVXCapable ())
299
+ InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX;
300
+ #endif
301
+ #if defined(USE_AVX)
302
+ if (AVXCapable ()) {
303
+ InnerProductSIMD16Ext = InnerProductSIMD16ExtAVX;
304
+ InnerProductSIMD4Ext = InnerProductSIMD4ExtAVX;
305
+ }
306
+ #endif
307
+
327
308
if (dim % 16 == 0 )
328
309
fstdistfunc_ = InnerProductSIMD16Ext;
329
310
else if (dim % 4 == 0 )
0 commit comments