Skip to content

Commit

Permalink
Windows Arm64 support (#4087)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Binozo authored and facebook-github-bot committed Jan 15, 2025
1 parent 89e93e2 commit 4c315a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions faiss/impl/platform_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
// redefine the GCC intrinsics with Windows equivalents

#include <intrin.h>
#include <limits.h>

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

#ifndef __clang__
inline int __builtin_clzll(uint64_t x) {
#if defined(_M_X64) || defined(__x86_64__)
return (int)__lzcnt64(x);
#elif defined(_M_ARM64)
unsigned long index;
int count = sizeof(uint64_t) * CHAR_BIT;
if (_BitScanReverse64(&index, x)) {
count = count - 1 - index;
}
return count;
#endif
}
#endif

Expand Down

0 comments on commit 4c315a9

Please sign in to comment.