mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-01 10:11:20 +08:00
Improved halfvec performance with F16C support
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
#define TYPALIGN_INT 'i'
|
||||
#endif
|
||||
|
||||
#ifdef F16C_SUPPORT
|
||||
#include <immintrin.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check if half is NaN
|
||||
*/
|
||||
@@ -99,7 +103,9 @@ pq_sendhalf(StringInfo buf, half h)
|
||||
float
|
||||
HalfToFloat4(half num)
|
||||
{
|
||||
#ifdef FLT16_SUPPORT
|
||||
#if defined(F16C_SUPPORT)
|
||||
return _cvtsh_ss(num);
|
||||
#elif defined(FLT16_SUPPORT)
|
||||
return (float) num;
|
||||
#else
|
||||
/* TODO Improve performance */
|
||||
@@ -184,7 +190,9 @@ HalfToFloat4(half num)
|
||||
half
|
||||
Float4ToHalfUnchecked(float num)
|
||||
{
|
||||
#ifdef FLT16_SUPPORT
|
||||
#if defined(F16C_SUPPORT)
|
||||
return _cvtss_sh(num, 0);
|
||||
#elif defined(FLT16_SUPPORT)
|
||||
return (_Float16) num;
|
||||
#else
|
||||
/* TODO Improve performance */
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
#include "vector.h"
|
||||
|
||||
#ifdef __FLT16_MAX__
|
||||
#if defined(__F16C__)
|
||||
#define F16C_SUPPORT
|
||||
#elif defined(__FLT16_MAX__)
|
||||
#define FLT16_SUPPORT
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user