Open filipnavara opened 3 years ago
Thank you for opening this issue. I'll add it to the backlog. If you would like to contribute, you can submit a fix by editing the original article. Click on the Content Source link at the bottom of your original comment. To learn how to edit, see the Editing files in a repository article from GitHub.
Thanks again!
Ping @tannergooding
The SIMD types are supported on all platforms targeted by RyuJIT, including 32-bit x86 and ARM.
We do not support SIMD codegen on 32-bit ARM and you will get the software fallbacks or a PlatformNotSupportedException
(depending on whether the API is meant for general use or hardware specific use).
I believe we are also more limited in some aspects on 32-bit x86 Unix.
I'd suggest to update the docs to state the hardware accelerated SIMD support is available on all platforms where System.Numerics.Vector.IsHardwareAccelerated returns true. This will return true for all supported .NET 5+ and .NET Core versions. .NET Framework is an exception which may require a more specific mention.
I agree the doc could use rewording and could likely also give a reference to the newer hardware intrinsics feature (System.Runtime.Intrinsics.*
).
We do not support SIMD codegen on 32-bit ARM
Ah, I stand corrected. I only checked part of the source code and missed the condition in CMake for FEATURE_SIMD
.
I believe we are also more limited in some aspects on 32-bit x86 Unix.
The same CMake condition excludes x86 Unix completely:
if ((TARGETDETAILS_ARCH STREQUAL "x64") OR (TARGETDETAILS_ARCH STREQUAL "arm64") OR ((TARGETDETAILS_ARCH STREQUAL "x86") AND NOT (TARGETDETAILS_OS STREQUAL "unix")))
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_SIMD)
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE FEATURE_HW_INTRINSICS)
endif ()
My main concern was that it implied that the types would not be optimized on x86 at all. That was not true for quite some time. I am not sure how to reword it, preferably in a way that would not need to be edited again due to additional platforms (WASM) or VMs (MonoVM in .NET 6).
I think your suggestion on checking and depending on IsHardwareAccelerated
is sufficient here. If that API returns true
, then at least some of the methods are accelerated on the given platform (even on x64, there are a few overloads that can't be accelerated, but those may differ from those that can't be on say ARM64). If it returns false
, then no APIs are hardware accelerated.
Issue description
The docs about SIMD support (https://github.com/dotnet/docs/blob/master/docs/standard/simd.md) state the following:
The information is out of date. As of .NET Core 2.0 all backend code generators were migrated to RyuJIT backend (https://devblogs.microsoft.com/dotnet/the-ryujit-transition-is-complete/). The SIMD types are supported on all platforms targeted by RyuJIT, including 32-bit x86 and ARM.
Additionally, the SIMD types are also supported on Mono, and in MonoVM in .NET 6. This is independent implementation not related to RyuJIT. The support matrix for Mono and Xamarin based products is non-trivial though.
I'd suggest to update the docs to state the hardware accelerated SIMD support is available on all platforms where
System.Numerics.Vector.IsHardwareAccelerated
returnstrue
. This will return true for all supported .NET 5+ and .NET Core versions. .NET Framework is an exception which may require a more specific mention.Target framework
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.