diff --git a/hnswlib/hnswlib.h b/hnswlib/hnswlib.h index 58eb7607..61029e90 100644 --- a/hnswlib/hnswlib.h +++ b/hnswlib/hnswlib.h @@ -16,20 +16,20 @@ #include #include #include "cpu_x86.h" -void cpu_x86::cpuid(int32_t out[4], int32_t eax, int32_t ecx) { +static void cpu_x86::cpuid(int32_t out[4], int32_t eax, int32_t ecx) { __cpuidex(out, eax, ecx); } -__int64 xgetbv(unsigned int x) { +static __int64 xgetbv(unsigned int x) { return _xgetbv(x); } #else #include #include #include -void cpuid(int32_t cpuInfo[4], int32_t eax, int32_t ecx) { +static void cpuid(int32_t cpuInfo[4], int32_t eax, int32_t ecx) { __cpuid_count(eax, ecx, cpuInfo[0], cpuInfo[1], cpuInfo[2], cpuInfo[3]); } -uint64_t xgetbv(unsigned int index) { +static uint64_t xgetbv(unsigned int index) { uint32_t eax, edx; __asm__ __volatile__("xgetbv" : "=a"(eax), "=d"(edx) : "c"(index)); return ((uint64_t)edx << 32) | eax; @@ -51,7 +51,7 @@ uint64_t xgetbv(unsigned int index) { // Adapted from https://github.com/Mysticial/FeatureDetector #define _XCR_XFEATURE_ENABLED_MASK 0 -bool AVXCapable() { +static bool AVXCapable() { int cpuInfo[4]; // CPU support @@ -78,7 +78,7 @@ bool AVXCapable() { return HW_AVX && avxSupported; } -bool AVX512Capable() { +static bool AVX512Capable() { if (!AVXCapable()) return false; int cpuInfo[4]; diff --git a/hnswlib/space_ip.h b/hnswlib/space_ip.h index b4266f78..d45a4c66 100644 --- a/hnswlib/space_ip.h +++ b/hnswlib/space_ip.h @@ -281,10 +281,10 @@ namespace hnswlib { #endif #if defined(USE_SSE) || defined(USE_AVX) || defined(USE_AVX512) - DISTFUNC InnerProductSIMD16Ext = InnerProductSIMD16ExtSSE; - DISTFUNC InnerProductSIMD4Ext = InnerProductSIMD4ExtSSE; - DISTFUNC InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtSSE; - DISTFUNC InnerProductDistanceSIMD4Ext = InnerProductDistanceSIMD4ExtSSE; + static DISTFUNC InnerProductSIMD16Ext = InnerProductSIMD16ExtSSE; + static DISTFUNC InnerProductSIMD4Ext = InnerProductSIMD4ExtSSE; + static DISTFUNC InnerProductDistanceSIMD16Ext = InnerProductDistanceSIMD16ExtSSE; + static DISTFUNC InnerProductDistanceSIMD4Ext = InnerProductDistanceSIMD4ExtSSE; static float InnerProductDistanceSIMD16ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) { diff --git a/hnswlib/space_l2.h b/hnswlib/space_l2.h index 44135370..355cc7b8 100644 --- a/hnswlib/space_l2.h +++ b/hnswlib/space_l2.h @@ -144,7 +144,7 @@ namespace hnswlib { #endif #if defined(USE_SSE) || defined(USE_AVX) || defined(USE_AVX512) - DISTFUNC L2SqrSIMD16Ext = L2SqrSIMD16ExtSSE; + static DISTFUNC L2SqrSIMD16Ext = L2SqrSIMD16ExtSSE; static float L2SqrSIMD16ExtResiduals(const void *pVect1v, const void *pVect2v, const void *qty_ptr) {