Skip to content

Commit f9b7b87

Browse files
committed
fix alignemnt test
1 parent 397ac3f commit f9b7b87

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/VecSim/spaces/IP_space.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ dist_func_t<float> Cosine_INT8_GetDistFunc(size_t dim, unsigned char *alignment,
242242
#ifdef OPT_AVX512_F_BW_VL_VNNI
243243
if (features.avx512f && features.avx512bw && features.avx512vl && features.avx512vnni) {
244244
// Align to vector memory size, including the norm at the end of the vector.
245-
if (dim % 32 + sizeof(float) == 0) // no point in aligning if we have an offsetting residual
245+
if ((dim + sizeof(float)) % 32 ==
246+
0) // no point in aligning if we have an offsetting residual
246247
*alignment = 32 * sizeof(int8_t); // align to 256 bits.
247248
return Choose_INT8_Cosine_implementation_AVX512F_BW_VL_VNNI(dim);
248249
}

tests/unit/test_spaces.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,8 @@ TEST_P(INT8SpacesOptimizationTest, INT8CosineTest) {
10001000
*(float *)(v2 + dim) = test_utils::compute_norm(v2, dim);
10011001
auto expected_alignment = [](size_t reg_bit_size, size_t dim) {
10021002
size_t elements_in_reg = reg_bit_size / sizeof(int8_t) / 8;
1003-
return (dim % elements_in_reg == 0) ? elements_in_reg * sizeof(int8_t) : 0;
1003+
return ((dim + sizeof(float)) % elements_in_reg == 0) ? elements_in_reg * sizeof(int8_t)
1004+
: 0;
10041005
};
10051006

10061007
dist_func_t<float> arch_opt_func;
@@ -1018,7 +1019,7 @@ TEST_P(INT8SpacesOptimizationTest, INT8CosineTest) {
10181019
optimization.avx512f = optimization.avx512bw = optimization.avx512vl =
10191020
optimization.avx512vnni = 0;
10201021

1021-
ASSERT_EQ(alignment, 2141);
1022+
// ASSERT_EQ(alignment, 2141)<< "alignemt for dim = " << dim;
10221023
}
10231024
#endif
10241025
unsigned char alignment = 0;

0 commit comments

Comments
 (0)