Add explicit template specialization declarations for MSVC linking#4992
Open
alibeklfc wants to merge 2 commits intofacebookresearch:mainfrom
Open
Add explicit template specialization declarations for MSVC linking#4992alibeklfc wants to merge 2 commits intofacebookresearch:mainfrom
alibeklfc wants to merge 2 commits intofacebookresearch:mainfrom
Conversation
…kresearch#4989) Summary: Fix compiler warnings that appear during pip wheel builds on macOS (AppleClang) and Windows (MSVC). **macOS fixes (AppleClang):** 1. Replace deprecated `sprintf` calls with `snprintf` in all three simdlib headers: - `simdlib_emulated.h` (4 call sites) - `simdlib_avx2.h` (4 call sites) - `simdlib_avx512.h` (3 call sites) AppleClang marks `sprintf` as deprecated. The fix replaces `ptr += sprintf(ptr, fmt, val)` with `ptr += snprintf(ptr, (size_t)(res + sizeof(res) - ptr), fmt, val)`, where the second argument computes the remaining buffer space. This is safe and behavior-preserving: these are debug-only `tostring()` methods that format small integers/floats into 1000-2000 byte buffers, using at most ~256 bytes in the worst case (64 elements × ~4 chars). When output fits (which it always does), `snprintf` returns the same value as `sprintf`, so `ptr` advances identically. 2. Add missing `override` specifiers to fix `-Winconsistent-missing-override`: - `IVFFlatScanner::scan_codes()` in `IndexIVFFlat.h` - `RaBitQHeapHandler::begin()` and `end()` in `IndexRaBitQFastScan.h` - `IDSelectorModulo::is_member()` in `faiss_example_external_module.swig` These methods override virtual base class methods but lacked the `override` keyword. Adding it is purely declarative — no behavioral change, but enables compile-time checking if the base signature changes. **Windows fixes (MSVC):** 3. Guard `#pragma GCC diagnostic` blocks with `#if defined(__GNUC__) || defined(__clang__)` to silence MSVC C4068 "unknown pragma" warnings in: - `simdlib_emulated.h`, `simdlib_avx2.h`, `simdlib_avx512.h` - `IVFlib.cpp`, `PolysemousTraining.cpp` The pragmas only control warning suppression (for `-Wformat-nonliteral`) and have zero effect on code generation. GCC/Clang still see them and behave identically; MSVC skips them (it doesn't have that warning anyway). 4. Fix `%ld` printf format specifiers in `partitioning.cpp` to use `%zu` for `size_t` and `%" PRId64 "` for `int64_t` (MSVC C4477: `long` is 32-bit on Windows, so `%ld` is wrong for both types). These are debug-only `IFV printf` calls gated behind a verbose flag. 5. Fix `size_t` to `int` narrowing in `IndexIVFSpectralHash.cpp` (MSVC C4267): `std::make_unique<RandomRotationMatrix>(d_in, nbit_in)` where `d_in` is `size_t` but the constructor takes `int`. Added `static_cast<int>(d_in)`. Safe because `d_in` is vector dimensionality (typically 64-2048). 6. Fix pointer-to-`long` truncation in `distances_sse-inl.h` (MSVC C4311): Alignment check `(long)ptr & 15` truncates 64-bit pointers on Windows where `long` is 32-bit. Changed to `(uintptr_t)ptr` which is correct on all platforms. The alignment test logic is unchanged. Reviewed By: mnorris11 Differential Revision: D98197799
Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
Contributor
|
@alibeklfc has exported this pull request. If you are a Meta employee, you can view the originating Diff in D98232371. |
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 26, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 27, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 27, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 27, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 28, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 30, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Mar 31, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Apr 1, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Apr 1, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Apr 1, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
alibeklfc
added a commit
to alibeklfc/faiss
that referenced
this pull request
Apr 1, 2026
…acebookresearch#4992) Summary: Add explicit specialization declarations for all SIMD-templated distance functions in `distances.h`. C++ [temp.expl.spec]/7 requires that explicit specialization declarations appear before any translation unit that might implicitly instantiate the primary template. GCC/Clang are lenient about this ordering, but MSVC strictly enforces it — without these declarations, the linker emits LNK2001 (unresolved external symbol) for the specializations defined in the `_avx2` translation units. The macro `FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)` declares all 17 distance function specializations for a given `SIMDLevel`, and is expanded for `SIMDLevel::NONE` and `SIMDLevel::AVX2`. This is a no-op on GCC/Clang (declarations are redundant but harmless). Differential Revision: D98232371
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Add explicit specialization declarations for all SIMD-templated distance
functions in
distances.h.C++ [temp.expl.spec]/7 requires that explicit specialization declarations
appear before any translation unit that might implicitly instantiate the
primary template. GCC/Clang are lenient about this ordering, but MSVC
strictly enforces it — without these declarations, the linker emits
LNK2001 (unresolved external symbol) for the specializations defined in
the
_avx2translation units.The macro
FAISS_DECLARE_DISTANCES_SPECIALIZATIONS(SL)declares all 17distance function specializations for a given
SIMDLevel, and is expandedfor
SIMDLevel::NONEandSIMDLevel::AVX2.This is a no-op on GCC/Clang (declarations are redundant but harmless).
Differential Revision: D98232371