Improved performance of bit distance functions - #519

Co-authored-by: Nathan Bossart <nathan@postgresql.org>
Co-authored-by: "Jonathan S. Katz" <jkatz@users.noreply.github.com>
This commit is contained in:
Andrew Kane
2024-04-18 13:45:00 -07:00
parent 0b938f8328
commit fb3c964ac2
8 changed files with 289 additions and 27 deletions

23
src/bitutils.h Normal file
View File

@@ -0,0 +1,23 @@
#ifndef BITUTILS_H
#define BITUTILS_H
/* Only enable for more recent compilers */
#if defined(__x86_64__) && defined(__GNUC__) && __GNUC__ >= 8
#define BIT_DISPATCH
#elif defined(__x86_64__) && defined(__clang_major__) && __clang_major__ >= 7
#define BIT_DISPATCH
#elif defined(_M_AMD64) && defined(_MSC_VER) && _MSC_VER >= 1920
#define BIT_DISPATCH
#endif
/* target_clones requires glibc */
#if defined(BIT_DISPATCH) && defined(__gnu_linux__)
#define USE_TARGET_CLONES
#endif
extern uint64 (*BitHammingDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 distance);
extern double (*BitJaccardDistance) (uint32 bytes, unsigned char *ax, unsigned char *bx, uint64 ab, uint64 aa, uint64 bb);
void BitvecInit(void);
#endif