mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
Vectorizing vector_concat for improved performance (#861)
* Vectorizing vector_concat for improved performance On an ARM chip this should generate SIMD instructions to copy the two incoming vectors to the new vector as opposed to doing it all in software. * Moving declarations to above CheckDim * Removing const from dims * Formatting
This commit is contained in:
10
src/vector.c
10
src/vector.c
@@ -916,15 +916,19 @@ vector_concat(PG_FUNCTION_ARGS)
|
||||
Vector *b = PG_GETARG_VECTOR_P(1);
|
||||
Vector *result;
|
||||
int dim = a->dim + b->dim;
|
||||
int dim_a = a->dim;
|
||||
int dim_b = b->dim;
|
||||
|
||||
CheckDim(dim);
|
||||
result = InitVector(dim);
|
||||
|
||||
for (int i = 0; i < a->dim; i++)
|
||||
/* Auto-vectorized */
|
||||
for (int i = 0; i < dim_a; i++)
|
||||
result->x[i] = a->x[i];
|
||||
|
||||
for (int i = 0; i < b->dim; i++)
|
||||
result->x[i + a->dim] = b->x[i];
|
||||
/* Auto-vectorized */
|
||||
for (int i = 0; i < dim_b; i++)
|
||||
result->x[i + dim_a] = b->x[i];
|
||||
|
||||
PG_RETURN_POINTER(result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user