File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 1414#if defined(__SSE4_2__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(_M_X64)
1515#define HIGH64 (x ) (static_cast <__uint64_t >(x>>64 ))
1616#define LOW64 (x ) (static_cast <__uint64_t >(x&((1 <<64 )-1 ))
17+ #else
18+ #include < immintrin.h>
1719#endif
1820
1921template <typename T>
@@ -119,7 +121,7 @@ class SimHash : public SimHashBase {
119121 auto x = this ->_value ^ obj._value ;
120122#if defined(__SSE4_2__) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2) || defined(_M_X64)
121123#ifdef DEBUG
122- std::cout << " use popcnt" << std::endl;
124+ std::cout << " distance by popcnt" << std::endl;
123125#endif
124126 switch (sizeof (T)){
125127 case 16 :
@@ -131,6 +133,9 @@ class SimHash : public SimHashBase {
131133 }
132134
133135#elif defined(__POPCNT__)
136+ #ifdef DEBUG
137+ std::cout << " distance by builtin popcount" << std::endl;
138+ #endif
134139 switch (sizeof (T)){
135140 case 16 :
136141 return __builtin_popcountll (x);
@@ -140,13 +145,38 @@ class SimHash : public SimHashBase {
140145 return __builtin_popcount (x);
141146 }
142147#else
148+ /* *
149+ #ifdef DEBUG
150+ std::cout << "use _mm_popcnt_u32" << std::endl;
151+ #endif
152+ switch(sizeof(T)){
153+ case 16:
154+ #if defined(__AVX512BW__) && defined(__AVX512DQ__)
155+ return _mm_popcnt_u128(x);
156+ #else
157+ break;
158+ #endif
159+ case 8:
160+ return _mm_popcnt_u64(x);
161+ default:
162+ return _mm_popcnt_u32((unsigned int)x);
163+ }
164+ #else
143165
166+ #ifndef __AVX512BW__
167+ #ifndef __AVX512DQ__
168+ */
169+ #ifdef DEBUG
170+ std::cout << " distance by counting" << std::endl;
171+ #endif
144172 unsigned ans = 0 ;
145173 while (x) {
146174 ans += 1 ;
147175 x &= x - 1 ;
148176 }
149177 return ans;
178+ // #endif
179+ // #endif
150180#endif
151181 };
152182
You can’t perform that action at this time.
0 commit comments