Improved halfvec performance with F16C support

This commit is contained in:
Andrew Kane
2024-04-07 18:53:50 -07:00
parent 98d4b1a364
commit d8719d59a3
2 changed files with 13 additions and 3 deletions

View File

@@ -22,6 +22,10 @@
#define TYPALIGN_INT 'i' #define TYPALIGN_INT 'i'
#endif #endif
#ifdef F16C_SUPPORT
#include <immintrin.h>
#endif
/* /*
* Check if half is NaN * Check if half is NaN
*/ */
@@ -99,7 +103,9 @@ pq_sendhalf(StringInfo buf, half h)
float float
HalfToFloat4(half num) HalfToFloat4(half num)
{ {
#ifdef FLT16_SUPPORT #if defined(F16C_SUPPORT)
return _cvtsh_ss(num);
#elif defined(FLT16_SUPPORT)
return (float) num; return (float) num;
#else #else
/* TODO Improve performance */ /* TODO Improve performance */
@@ -184,7 +190,9 @@ HalfToFloat4(half num)
half half
Float4ToHalfUnchecked(float num) Float4ToHalfUnchecked(float num)
{ {
#ifdef FLT16_SUPPORT #if defined(F16C_SUPPORT)
return _cvtss_sh(num, 0);
#elif defined(FLT16_SUPPORT)
return (_Float16) num; return (_Float16) num;
#else #else
/* TODO Improve performance */ /* TODO Improve performance */

View File

@@ -7,7 +7,9 @@
#include "vector.h" #include "vector.h"
#ifdef __FLT16_MAX__ #if defined(__F16C__)
#define F16C_SUPPORT
#elif defined(__FLT16_MAX__)
#define FLT16_SUPPORT #define FLT16_SUPPORT
#endif #endif