Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged
stephentoub merged 4 commits intodotnet:mainfromstephentoub:vectorizepopcount
Feb 16, 2024

Conversation

stephentoub
Copy link
Member

@stephentoubstephentoub commentedFeb 11, 2024
edited
Loading

Contributes to#97193

@ghost
Copy link

Tagging subscribers to this area: @dotnet/area-system-numerics
See info inarea-owners.md if you want to be subscribed.

Issue Details

Use 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.

Author:stephentoub
Assignees:stephentoub
Labels:

area-System.Numerics

Milestone:-

@stephentoubstephentoub changed the titleUse intrinsics in TensorPrimitives.PopCount for sizeof(T) == 1Vectorize TensorPrimitives.PopCountFeb 15, 2024
@stephentoubstephentoub merged commitbfc1a74 intodotnet:mainFeb 16, 2024
@stephentoubstephentoub deleted the vectorizepopcount branchFebruary 16, 2024 00:22
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 17, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@eiriktsarpaliseiriktsarpaliseiriktsarpalis approved these changes

@tannergoodingtannergoodingtannergooding left review comments

@MichalPetrykaMichalPetrykaMichalPetryka left review comments

Assignees

@stephentoubstephentoub

Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@stephentoub@eiriktsarpalis@tannergooding@MichalPetryka

[8]ページ先頭

©2009-2025 Movatter.jp