-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[Analyzer] Upgrade from platform specific to cross platform intrinsics #82486
Comments
Tagging subscribers to this area: @dotnet/area-system-runtime-intrinsics Issue DetailsWe've iteratively exposed support for various levels of hardware intrinsics since .NET Core 3.1. In .NET 7, we exposed the new "cross platform" hardware intrinsics which aim to help simplify the writing and maintenance of SIMD code meant to run across a variety of platforms. As such, we should provide a code fixer that identifies such platform specific calls and suggests the simple transformation to the equivalent cross platform calls. Category: Maintainability or Portability seem like the best fit. I could also see this being classified as Usage ExampleA simple example is given below. The full list of APIs recognized is of course more expansive but effectively correlates to a platform specific ISA such as - return Sse.Add(Sse.Multiply(left, right), addend);
+ return (left * right) + addend;
|
Code fixer looks good as proposed. This would handle most common operators ( Either category seems fine, but we have a slight preference for maintainability. - Sse.Add(Sse.Multiply(left, right), addend)
+ (left * right) + addend |
@buyaa-n, I'd like to start prototyping this. What's required before I start doing that? Do we need to determine which dotnet/roslyn-analyzers project this will be part of and "allocate" some diagnostic ID(s)? |
Might want to start with the getting started doc, some info might be a bit old, let me know if you have any questions. Could check other PRs that adding a new analyzer as an example
Libraries analyzers goes into Microsoft.NetCore.Analyzers project, for id just pick the next available ID for the category https://github.com/dotnet/roslyn-analyzers/blob/main/src/Utilities/Compiler/DiagnosticCategoryAndIdRanges.txt#L20. Looks last id used for |
If it's okay, I'd like to pitch in — I'm the developer of StockNemo, a chess engine in C# that heavily makes use of SIMD intrinsics available for its neural network inference. Maybe when operations like In some cases, this will work better than the regular operations. Let me know what you think. |
This isn't a "value-preserving optimization" so its not one we can offer by default. In particular, it will result in different results for "overflow" to +/-infinity and in slightly different results in a few other cases due to rounding once rather than twice.
I appreciate the offer. We're going to be looking at this closer to the Preview 5/6 timeframe and I'll ping again on the thread around that time. |
We've iteratively exposed support for various levels of hardware intrinsics since .NET Core 3.1. In .NET 7, we exposed the new "cross platform" hardware intrinsics which aim to help simplify the writing and maintenance of SIMD code meant to run across a variety of platforms.
As such, we should provide a code fixer that identifies such platform specific calls and suggests the simple transformation to the equivalent cross platform calls.
Category: Maintainability or Portability seem like the best fit. I could also see this being classified as Usage
Severity = suggestion
Example
A simple example is given below. The full list of APIs recognized is of course more expansive but effectively correlates to a platform specific ISA such as
Sse.Add
,Sse2.Add
,Avx.Add
,Avx2.Add
,AdvSimd.Add
, orPackedSimd.Add
correlating to a singular cross platform API, such asoperator +
:The text was updated successfully, but these errors were encountered: