- Notifications
You must be signed in to change notification settings - Fork5.1k
Vectorize TensorPrimitives.PopCount#98281
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
ghost commentedFeb 11, 2024
Tagging subscribers to this area: @dotnet/area-system-numerics Issue DetailsUse popcount hardware intrinsics to vectorize TensorPrimitives.PopCount for sizeof(T) == 1 on platforms that have intrinsics. I tried doing this more generally on other platforms with: Vector128<byte>lookup=Vector128.Create((byte)0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4);Vector128<byte>cnt1=Vector128.Shuffle(lookup,x.AsByte()&Vector128.Create((byte)0xF));Vector128<byte>cnt2=Vector128.Shuffle(lookup,(x.AsByte()>>4)&Vector128.Create((byte)0xF));return(cnt1+cnt2).As<byte,T>(); and the equivalent for Vector256/512, but it ended up being ~5x slower than just using the scalar byte.PopCount for each element. I also tried using this with SumAbsoluteDifferences in support of sizeof(T) == 8, and it ended up being an order of magnitude worse.
|
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.cs OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
46fdc2f
toe0c3aca
Compare...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
...ries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorPrimitives.netcore.csShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Contributes to#97193