Skip to content

Commit 4c315a9

Browse files
Binozofacebook-github-bot
authored andcommitted
Windows Arm64 support (#4087)
Summary: Hey there 👋 currently I am working on a project using faiss using [FaissMask](https://github.com/andyalm/faissmask) (.NET Bindings). As I am developing on a windows arm64 machine I needed a way to compile faiss for windows arm. I ran the tests in FaissMask and my little hack seemed valid. Here is a little script to compile it yourself: ```bash #!/bin/bash # Execute in git bash # and cmake (https://cmake.org/download/) BRANCH="feat/windows-arm64-support" GITHUB_ACCOUNT=Binozo git clone --depth=1 --recursive --branch $BRANCH https://github.com/$GITHUB_ACCOUNT/faiss.git cd faiss cmake -Wno-dev -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DFAISS_ENABLE_C_API=ON -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DBLA_VENDOR=Intel10_64_dyn "-DMKL_LIBRARIES=C:\Users\<USER>\CLionProjects\OpenBLAS\cmake-build-release\lib\Release\openblas.lib" -B build -S . cmake --build build --config Release --target faiss faiss_c ``` (Make sure you compiled `OpenBLAS` for windows arm64 before and adjust `C:\Users\<USER>\CLionProjects\OpenBLAS\cmake-build-release\lib\Release\openblas.lib` if needed) Pull Request resolved: #4087 Reviewed By: asadoughi Differential Revision: D67297875 Pulled By: junjieqi fbshipit-source-id: c00f70e5f7fedd5f9fb86fee9258e5ef53b59ce7
1 parent 89e93e2 commit 4c315a9

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

faiss/impl/platform_macros.h

+10
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
// redefine the GCC intrinsics with Windows equivalents
4040

4141
#include <intrin.h>
42+
#include <limits.h>
4243

4344
#ifndef __clang__
4445
inline int __builtin_ctzll(uint64_t x) {
@@ -59,7 +60,16 @@ inline int __builtin_ctz(unsigned long x) {
5960

6061
#ifndef __clang__
6162
inline int __builtin_clzll(uint64_t x) {
63+
#if defined(_M_X64) || defined(__x86_64__)
6264
return (int)__lzcnt64(x);
65+
#elif defined(_M_ARM64)
66+
unsigned long index;
67+
int count = sizeof(uint64_t) * CHAR_BIT;
68+
if (_BitScanReverse64(&index, x)) {
69+
count = count - 1 - index;
70+
}
71+
return count;
72+
#endif
6373
}
6474
#endif
6575

0 commit comments

Comments
 (0)