Skip to content

Commit 9b6f9d1

Browse files
mdouzefacebook-github-bot
authored andcommitted
Work around GCC 12 miscompilation of AVX2 histogram (#5124)
Summary: GCC 12.4 (used in the conda faiss-gpu build) miscompiles the SIMD histogram_16 code path, causing test_16bin_bounded_bigrange to fail in the CUDA 12.6 nightly. Fall back to the scalar implementation when compiling with GCC 12. 🤖 This diff was automatically generated by myclaw_faiss_monitor Reviewed By: junjieqi Differential Revision: D101598734
1 parent 417c53e commit 9b6f9d1

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

.github/workflows/build-pull-request.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,21 @@ jobs:
276276
fetch-tags: true
277277
- name: Build and Package (conda)
278278
uses: ./.github/actions/build_conda
279+
linux-x86_64-GPU-conda:
280+
name: Linux x86_64 GPU (conda, CUDA 12.6)
281+
runs-on: 4-core-ubuntu-gpu-t4
282+
env:
283+
CUDA_ARCHS: "70-real;72-real;75-real;80;86-real"
284+
steps:
285+
- name: Checkout
286+
uses: actions/checkout@v4
287+
with:
288+
fetch-depth: 0
289+
fetch-tags: true
290+
- name: Build and Package (conda)
291+
uses: ./.github/actions/build_conda
292+
with:
293+
cuda: "12.6"
279294
linux-x86_64-svs:
280295
name: Linux x86_64 w/ SVS (cmake)
281296
needs: linux-x86_64-cmake

faiss/utils/partitioning.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,18 @@ void simd_histogram_16(
386386
uint16_t min,
387387
int shift,
388388
int* hist) {
389+
// GCC 12 miscompiles the AVX2 SIMD histogram — fall back to scalar.
390+
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ == 12
391+
simd_histogram_16_scalar(data, n, min, shift, hist);
392+
#else
389393
with_simd_level_256bit([&]<SIMDLevel SL>() {
390394
if constexpr (SL == SIMDLevel::NONE) {
391395
simd_histogram_16_scalar(data, n, min, shift, hist);
392396
} else {
393397
faiss::simd_histogram_16<SL>(data, n, min, shift, hist);
394398
}
395399
});
400+
#endif
396401
}
397402

398403
void PartitionStats::reset() {

tests/test_partitioning.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ using namespace faiss;
1414

1515
using AlignedTableUint16 = AlignedTable<uint16_t>;
1616

17-
// TODO: This test fails when Faiss is compiled with
18-
// GCC 13.2 from conda-forge with AVX2 enabled. This may be
19-
// a GCC bug that needs to be investigated further.
20-
// As of 16-AUG-2023 the Faiss conda packages are built
21-
// with GCC 11.2, so the published binaries are not affected.
17+
// GCC 12 miscompiles the AVX2 SIMD histogram. The conda packages
18+
// now use GCC 12.4, so we fall back to scalar in partitioning.cpp.
2219
TEST(TestPartitioning, TestPartitioningBigRange) {
2320
auto n = 1024;
2421
AlignedTableUint16 tab(n);

0 commit comments

Comments
 (0)