Skip to content

Commit ce9685c

Browse files
author
Tony Kuo
committed
cleanup
1 parent b801080 commit ce9685c

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

hnswlib/hnswlib.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ bool AVXCapable() {
8484
uint64_t xcrFeatureMask = xgetbv(_XCR_XFEATURE_ENABLED_MASK);
8585
avxSupported = (xcrFeatureMask & 0x6) == 0x6;
8686
}
87-
return avxSupported;
87+
return HW_AVX && avxSupported;
8888
}
8989

9090
bool AVX512Capable() {
@@ -96,8 +96,8 @@ bool AVX512Capable() {
9696
cpuid(cpuInfo, 0, 0);
9797
int nIds = cpuInfo[0];
9898

99-
bool HW_AVX512F = false; // AVX512 Foundation
100-
if (nIds >= 0x00000007) {
99+
bool HW_AVX512F = false;
100+
if (nIds >= 0x00000007) { // AVX512 Foundation
101101
cpuid(cpuInfo, 0x00000007, 0);
102102
HW_AVX512F = (cpuInfo[1] & ((int)1 << 16)) != 0;
103103
}
@@ -108,13 +108,12 @@ bool AVX512Capable() {
108108
bool osUsesXSAVE_XRSTORE = (cpuInfo[2] & (1 << 27)) != 0;
109109
bool cpuAVXSuport = (cpuInfo[2] & (1 << 28)) != 0;
110110

111-
bool avxSupported = false;
112111
bool avx512Supported = false;
113112
if (osUsesXSAVE_XRSTORE && cpuAVXSuport) {
114113
uint64_t xcrFeatureMask = xgetbv(_XCR_XFEATURE_ENABLED_MASK);
115114
avx512Supported = (xcrFeatureMask & 0xe6) == 0xe6;
116115
}
117-
return avx512Supported;
116+
return HW_AVX512F && avx512Supported;
118117
}
119118

120119
namespace hnswlib {

0 commit comments

Comments
 (0)