You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The AVX2 implementation of FAISS appears to use intrinsics that are GNU specific (or at least don't port to Windows via MSVC).
Platform
Windows 10.0.19045
MSVC 2022
Faiss version: git tag v1.7.4
Installed from: Attempting to compile
Faiss compilation options:
Probably doesn't much matter but using OpenBLAS compiled myself
CMake set(FAISS_OPT_LEVEL "avx2" CACHE INTERNAL "") and link with faiss_avx2 instead of faiss
Running on:
CPU
GPU
Interface:
C++
Python
Reproduction instructions
Get any BLAS implementation in order to satisfy the dependency requirements for building this library
Standard CMake dance (build directory, etc)
cmake -DFAISS_OPT_LEVEL=avx2 -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF .. (assuming the source directory is one level up from the build directory)
The definition of _mm_prefetch in MSVC (and actually in the Intel Intrinsics Guide suggesting GCC / clang are mistaken) takes a const char * as the first argument, not const void *. This base is peppered with calls directly passing float pointers.
__m128i_u and __m256i_u are not portable. However they are the exact same datatype as the non _u variants, just with some implied side effects so I'm guessing it is safe to define them away to their non _u variants #if defined(_MSC_VER) && !defined(__clang__).
By default Visual Studio implemented OpenMP 2.0, which doesn't allow signed indexes in for loops. The following code violates this
However, issue 3 can be worked around with some trickery, involving override CMake's FindMP module by setting OpenMP_CXX_FLAGS="-openmp:llvm". This turns on the "better" support (which is OpenMP 2.5 with a few 3.1 features including unsigned index types) for OpenMP in Visual Studio as noted here
The text was updated successfully, but these errors were encountered:
Any opinions on the way to approach this? I had simply cast all the prefetch calls blindly from float * to char *. I'm assuming that this function, taking a void * in the case of Linux, is not going to be doing anything special due to the fact that it is a float. It compiles and appears to function but if someone who knows better than me has a different approach let me know.
Also do you care if the iterator above is signed or unsigned? Does it have any implications? Because as I mentioned it can be either fixed in code or in build option (though the build option will create a dependency on LLVM libomp which I think at this point might be included in the MSVC runtime but I haven't looked carefully into that yet)
Summary
The AVX2 implementation of FAISS appears to use intrinsics that are GNU specific (or at least don't port to Windows via MSVC).
Platform
Windows 10.0.19045
MSVC 2022
Faiss version: git tag v1.7.4
Installed from: Attempting to compile
Faiss compilation options:
Probably doesn't much matter but using OpenBLAS compiled myself
CMake
set(FAISS_OPT_LEVEL "avx2" CACHE INTERNAL "")
and link with faiss_avx2 instead of faissRunning on:
Interface:
Reproduction instructions
cmake -DFAISS_OPT_LEVEL=avx2 -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF ..
(assuming the source directory is one level up from the build directory)cmake --build . --config Release --target faiss_avx2 ..
Fix instructions
This boils down to 3 distinct issues:
_mm_prefetch
in MSVC (and actually in the Intel Intrinsics Guide suggesting GCC / clang are mistaken) takes aconst char *
as the first argument, notconst void *
. This base is peppered with calls directly passing float pointers.__m128i_u
and__m256i_u
are not portable. However they are the exact same datatype as the non_u
variants, just with some implied side effects so I'm guessing it is safe to define them away to their non_u
variants#if defined(_MSC_VER) && !defined(__clang__)
.faiss/faiss/utils/distances_fused/simdlib_based.cpp
Lines 262 to 266 in d87888b
However, issue 3 can be worked around with some trickery, involving override CMake's FindMP module by setting
OpenMP_CXX_FLAGS="-openmp:llvm"
. This turns on the "better" support (which is OpenMP 2.5 with a few 3.1 features including unsigned index types) for OpenMP in Visual Studio as noted hereThe text was updated successfully, but these errors were encountered: