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

add Windows ARM64EC support #392

Merged
merged 1 commit into from
Apr 8, 2024
Merged

add Windows ARM64EC support #392

merged 1 commit into from
Apr 8, 2024

Conversation

jblazquez
Copy link
Contributor

This PR solves compilation errors when building for the Windows ARM64EC ABI.

You can repro in an ARM64 Visual Studio Developer Command Prompt:

>cl /nologo /c /EHsc /std:c++17 /arm64EC simdutf.cpp

simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
simdutf.cpp : error C7303: AVX512 types (__m512) are not currently supported in ARM64EC code
...

When building for the ARM64EC ABI, the compiler defines the _M_X64 macro and not the _M_ARM64 macro, to make incremental porting existing X64 Windows code to ARM easier.

This means that the library was detecting ARM64EC as AMD64 and trying to compile in the Intel SIMD vector implementations instead of NEON. This actually works in simple cases when building existing code that uses Intel intrinsics up to SSE4.2, because Windows provides an emulated implementation of those SIMD instruction sets in the softintrin.lib library, but it doesn't work at all for AVX+ intrinsics. It's also less efficient than using NEON directly.

The change makes the CPU architecture detection aware of the ARM64EC ABI so it can correctly detect the code as being built for ARM64 and use the right intrinsics.

See also: simdjson/simdjson#2165

@lemire
Copy link
Member

lemire commented Apr 8, 2024

I am merging this but please consider helping us adding a build test in CI. It is very difficult to support platforms when we do not have tests.

@lemire lemire merged commit 90ef2e0 into simdutf:master Apr 8, 2024
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants