Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Arm64 support #4087

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HI @Binozo This doesn't appear to be Windows specific actually. Does it do the same thing for aarch64 as the above code for x86-64?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @junjieqi yes this is a utility that does the same thing as __lzcnt64. As __lzcnt64 is x64 specific I needed a custom implementation of that. The _M_ARM64 is defined if you build for windows arm64: https://learn.microsoft.com/en-us/cpp/build/reference/arch-arm64?view=msvc-170#remarks

unsigned long index;
int count = sizeof(uint64_t) * CHAR_BIT;
if (_BitScanReverse64(&index, x)) {
count = count - 1 - index;
}
return count;
#endif
}
#endif

Expand Down
Loading