Intrinsics support for WidenFourAsciiBytesToUtf16AndWriteToBuffer#38597
Intrinsics support for WidenFourAsciiBytesToUtf16AndWriteToBuffer#38597pgovind merged 1 commit intodotnet:masterfrom
Conversation
|
Tagging subscribers to this area: @tannergooding |
There was a problem hiding this comment.
Does the use of ToScalar here produce acceptable codegen? In the SSE2 code paths, analyzing the x86 codegen revealed that ConvertToUInt64 produced better codegen than ToScalar. I don't know if the arm64 JIT has a similar behavior.
There was a problem hiding this comment.
I believe we have fixed most of these cases and improved the codegen for things like ToScalar. If not, we should as that is preferable for readability.
There was a problem hiding this comment.
Yes, ToScalar() is optimized for arm64.
|
Control flow LGTM, but I don't know enough about advsimd intrinsics to give this a proper review. @tannergooding, thoughts? |
There was a problem hiding this comment.
@GrabYourPitchforks, instead of maintaining this Shims.cs file, we could just include the *.PlatformNotSupported.cs variants of the relevant ISAs: https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/AdvSimd.PlatformNotSupported.cs
Thoughts? (Note we still need the Shims file for Vector64/Vector128/Vector256, but it would avoid needing to update for all of the ISAs)
There was a problem hiding this comment.
I'm curious about this. Whenever you select "Go to definition" in Visual Studio, it takes you to the AdvSimd.PlatformNotSupported.cs file. Why do we have the same APIs throwing PNSE in two different files?
Edit: Santi explained the difference. Please ignore this comment.
There was a problem hiding this comment.
When I tried doing this, VS complained about not understanding the [Intrinsic] attribute. I didn't bother investigating why, but I did see some commented out code in this file with similar [Intrinsic] attributes. Maybe that's the reason @GrabYourPitchforks didn't include the whole file?
There was a problem hiding this comment.
I have no problem with including the PNSE file as long as we're not introducing public API. We'd need to define a dummy [Intrinsic] attribute in the consuming project, but that's very straightforward.
There was a problem hiding this comment.
Ah, that would be an issue. The types in the PNSE file are public, not internal.
There was a problem hiding this comment.
I wonder if we should have ifdefs around these, just like how we have ifdefs around some of the new code analysis attributes. It might help code sharing between libraries that target netstandard2.0.
(Really that's an issue for a separate PR, but I wonder if this PR is a forcing function for it.)
There was a problem hiding this comment.
It actually sounds like we need one for some of the other OOB libraries as well. It might be good to just have an official shim library.
System.Text.Encodings.Web is using ifdefs today, but multitargets netstandard2.0, netcoreapp3.1, and net5; so the ifdefs are going to get a bit crazier
There was a problem hiding this comment.
For System.Text.Encodings.Web, I resorted to copying this file and extending it as needed. But would be great to have a package for frictionless intrinsics API usage.
src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Text/ASCIIUtility.cs
Outdated
Show resolved
Hide resolved
...ies/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/AdvSimd.PlatformNotSupported.cs
Outdated
Show resolved
Hide resolved
|
Thanks for the stamp Tanner. FWIW, here are the micro benchmarks I ran on my machine (Yeeesh, that took an unreasonable amount of time to set up): D:\repos\performance\src\tools\ResultsComparer>dotnet run --base "........\before_arm64" --diff "........\after_arm64" --threshold 0.01% No Slower results for the provided threshold = 0.01% and noise filter = 0.3ns.
|
| public static T GetElement<T>(this Vector128<T> vector, int index) where T : struct => throw new PlatformNotSupportedException(); | ||
| public static T ToScalar<T>(this Vector64<T> vector) where T : struct => throw new PlatformNotSupportedException(); | ||
| public static unsafe Vector128<ulong> CreateScalar(ulong value) => throw new PlatformNotSupportedException(); | ||
| public static T ToScalar<T>(this Vector128<T> vector) where T : struct => throw new PlatformNotSupportedException(); |
There was a problem hiding this comment.
I don't see the usage of these APIs inside ASCIIUtility.cs. Any reason why this is added?
There was a problem hiding this comment.
Hmm, it looks like they sneaked in while I was doing an interactive add. I need them for my next PR, so I think I'll leave them in, unless someone disagrees :)
| Returns="$(DocumentationFile)"/> | ||
|
|
||
| <PropertyGroup> | ||
| <DefineConstants Condition="'$(IsPrerelease)' != 'false' and '$(TargetFramework)' != '$(NetCoreAppCurrent)'">$(DefineConstants),USE_INTERNAL_ACCESSIBILITY</DefineConstants> |
There was a problem hiding this comment.
I'm not sure I like this living in Directory.Build.props. Shouldn't it rather be something that individual projects opt into?
There was a problem hiding this comment.
That was my first reaction too. Levi suggested that it live here, so I didn't pay too much attention to it. In my next PR, I'll move it to System.Utf8Experimental.csproj.
There was a problem hiding this comment.
Is this constant meant to be used in contexts other than intrinsics shims? If not, then we should probably use a more specific name like USE_INTERNAL_INTRINSICS_SHIMS or something.
There was a problem hiding this comment.
From an infrastructure standpoint this is wrong as the TargetFramework property shouldn't be read outside the project file. Instead inferred properties like TargetFrameworkVersion and TargetFrameworkIdentifier should be used. If you already plan to move it then it's fine.
| /// </summary> | ||
| [CLSCompliant(false)] | ||
| public abstract class ArmBase | ||
| #if USE_INTERNAL_ACCESSIBILITY |
There was a problem hiding this comment.
I think it would make sense to remove the CLSCompliant attribute when USE_INTERNAL_ACCESSIBILITY is enabled. Getting build warnings which I have to explicitly disable.
There was a problem hiding this comment.
Ah yes. Will submit a small PR for this shortly
Implements 1 API from #35034