Compare commits

...

4 Commits

Author SHA1 Message Date
Andrew Kane
665b3dfa1c Skip if FMA available [skip ci] 2024-04-14 14:17:10 -07:00
Andrew Kane
ce597f770d Updated changelog [skip ci] 2024-04-13 20:23:33 -07:00
Andrew Kane
1234fffcb0 Fixed CI 2024-04-13 20:17:33 -07:00
Andrew Kane
e70a47c154 Added CPU dispatching for vector distance functions 2024-04-13 20:12:47 -07:00
2 changed files with 10 additions and 2 deletions

View File

@@ -7,6 +7,7 @@
- Added `jaccard_distance` function - Added `jaccard_distance` function
- Added `quantize_binary` function - Added `quantize_binary` function
- Added `subvector` function - Added `subvector` function
- Added CPU dispatching for distance functions on Linux x86-64
- Updated comparison operators to support vectors with different dimensions - Updated comparison operators to support vectors with different dimensions
## 0.6.2 (2024-03-18) ## 0.6.2 (2024-03-18)

View File

@@ -33,6 +33,13 @@
#define STATE_DIMS(x) (ARR_DIMS(x)[0] - 1) #define STATE_DIMS(x) (ARR_DIMS(x)[0] - 1)
#define CreateStateDatums(dim) palloc(sizeof(Datum) * (dim + 1)) #define CreateStateDatums(dim) palloc(sizeof(Datum) * (dim + 1))
/* target_clones requires glibc */
#if defined(__x86_64__) && defined(__gnu_linux__) && defined(__has_attribute) && __has_attribute(target_clones) && !defined(__FMA__)
#define VECTOR_DISPATCH __attribute__((target_clones("default", "fma")))
#else
#define VECTOR_DISPATCH
#endif
PG_MODULE_MAGIC; PG_MODULE_MAGIC;
/* /*
@@ -557,7 +564,7 @@ halfvec_to_vector(PG_FUNCTION_ARGS)
PG_RETURN_POINTER(result); PG_RETURN_POINTER(result);
} }
static float VECTOR_DISPATCH static float
VectorL2SquaredDistance(int dim, float *ax, float *bx) VectorL2SquaredDistance(int dim, float *ax, float *bx)
{ {
float distance = 0.0; float distance = 0.0;
@@ -604,7 +611,7 @@ vector_l2_squared_distance(PG_FUNCTION_ARGS)
PG_RETURN_FLOAT8((double) VectorL2SquaredDistance(a->dim, a->x, b->x)); PG_RETURN_FLOAT8((double) VectorL2SquaredDistance(a->dim, a->x, b->x));
} }
static float VECTOR_DISPATCH static float
VectorInnerProduct(int dim, float *ax, float *bx) VectorInnerProduct(int dim, float *ax, float *bx)
{ {
float distance = 0.0; float distance = 0.0;