Skip to content

Commit 3b3bf5e

Browse files
conanhujinmingfacebook-github-bot
authored andcommitted
bugfix: add a macro guard for avx512 operation (facebookresearch#4539)
Summary: ### What to fix There is a small bug in the faiss/utils/rabitq_simd.h that some avx512 only supported operation is not guarded by a corresponding macro. As a result, the compile will fail if the arch does not support avx512. ### What I did I add the macro guard. ### What I checked I have compiled locally. This should be an easy fix. Pull Request resolved: facebookresearch#4539 Reviewed By: mnorris11 Differential Revision: D80734590 Pulled By: junjieqi fbshipit-source-id: 603b94f29931576330eee1a8d1dcb73164df47f2
1 parent e5de66e commit 3b3bf5e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

faiss/utils/rabitq_simd.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ namespace faiss {
2626
*
2727
* @return Lookup table as __m512i register
2828
*/
29+
#if defined(__AVX512F__)
2930
inline __m512i get_lookup_512() {
3031
return _mm512_set_epi8(
3132
/* f */ 4,
@@ -93,7 +94,8 @@ inline __m512i get_lookup_512() {
9394
/* 1 */ 1,
9495
/* 0 */ 0);
9596
}
96-
97+
#endif
98+
#if defined(__AVX2__)
9799
/**
98100
* Returns the lookup table for AVX2 popcount operations.
99101
* This table is used for lookup-based popcount implementation.
@@ -135,7 +137,9 @@ inline __m256i get_lookup_256() {
135137
/* e */ 3,
136138
/* f */ 4);
137139
}
140+
#endif
138141

142+
#if defined(__AVX512F__)
139143
/**
140144
* Performs lookup-based popcount on AVX512 registers.
141145
*
@@ -152,7 +156,8 @@ inline __m512i popcount_lookup_avx512(__m512i v_and) {
152156
const __m512i popcnt2 = _mm512_shuffle_epi8(lookup, hi);
153157
return _mm512_add_epi8(popcnt1, popcnt2);
154158
}
155-
159+
#endif
160+
#if defined(__AVX2__)
156161
/**
157162
* Performs lookup-based popcount on AVX2 registers.
158163
*
@@ -170,6 +175,7 @@ inline __m256i popcount_lookup_avx2(__m256i v_and) {
170175
return _mm256_add_epi8(popcnt1, popcnt2);
171176
}
172177
#endif
178+
#endif
173179

174180
#if defined(__AVX512F__) && defined(__AVX512VPOPCNTDQ__)
175181

0 commit comments

Comments
 (0)