pgvector.git / summary / log / commit / refs
commit fe697e878808383b3546db335ae47d61ffec57fa
Author: Jon Daniel <binarycleric@users.noreply.github.com>
Commit: GitHub <noreply@github.com>
Date: Wed Jun 18 23:09:43 2025 +0000
vectorize: optimize VectorSumCenter and HalfvecSumCenter (#860)
* vectorize: optimize VectorSumCenter and HalfvecSumCenter
The functions VectorSumCenter and HalfvecSumCenter were not being
vectorized by the compiler. A few slight changes will allow these
optimizations to take place and get a performance boost by utilizing
SIMD instructions.
This optimization helps improve performance of vector operations in IVF
index building and updating.
* Removing const, commenting that it is only vectoirzed on ARM
src/ivfutils.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/ivfutils.c b/src/ivfutils.c
index da241ee0..044fbabf 100644
--- a/src/ivfutils.c
+++ b/src/ivfutils.c
@@ -295,8 +295,10 @@ static void
VectorSumCenter(Pointer v, float *x)
{
Vector *vec = (Vector *) v;
+ int dim = vec->dim;
- for (int k = 0; k < vec->dim; k++)
+ /* Auto-vectorized */
+ for (int k = 0; k < dim; k++)
x[k] += vec->x[k];
}
@@ -304,8 +306,10 @@ static void
HalfvecSumCenter(Pointer v, float *x)
{
HalfVector *vec = (HalfVector *) v;
+ int dim = vec->dim;
- for (int k = 0; k < vec->dim; k++)
+ /* Auto-vectorized on aarch64 */
+ for (int k = 0; k < dim; k++)
x[k] += HalfToFloat4(vec->x[k]);
}
[parent: bf28ed8176cd]