From adbe2a866bb4a6ceece94aeb3b63166fc7c5512d Mon Sep 17 00:00:00 2001 From: Gopal Srinivasa Date: Tue, 26 Nov 2024 01:00:19 +0530 Subject: [PATCH] Pre-evaluation --- src/distance.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/distance.cpp b/src/distance.cpp index 213c8f320..542bf534a 100644 --- a/src/distance.cpp +++ b/src/distance.cpp @@ -201,6 +201,7 @@ float DistanceL2Float::compare(const float *__restrict a, const float *__restric #ifdef USE_AVX2 // assume size is divisible by 8 uint16_t niters = (uint16_t)(size / 8); + uint32_t half = niters / 2, three_fourths = (niters * 3) / 4, seven_eights = (niters * 7) / 8; __m256 sum = _mm256_setzero_ps(); for (uint16_t j = 0; j < niters; j++) { @@ -219,7 +220,7 @@ float DistanceL2Float::compare(const float *__restrict a, const float *__restric sum = _mm256_fmadd_ps(tmp_vec, tmp_vec, sum); - if (j == (niters/2) || j == (3* niters/4) || j == (7* niters/8) ) + if (j == half || j == three_fourths || j == seven_eights ) { if (_mm256_reduce_add_ps(sum) > threshold) {