Skip to content

Commit

Permalink
Pre-evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
gopal-msr committed Nov 25, 2024
1 parent ddc8823 commit adbe2a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/distance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand All @@ -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)
{
Expand Down

0 comments on commit adbe2a8

Please sign in to comment.