Skip to content
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

Lzcnt/popcnt functions? #35

Open
touisteur opened this issue Aug 27, 2021 · 4 comments
Open

Lzcnt/popcnt functions? #35

touisteur opened this issue Aug 27, 2021 · 4 comments

Comments

@touisteur
Copy link

Hi,

Unless I haven't looked in the right places, there doesn't seem to be any support lane-wise lzcnt or popcount. Is it foreseen in the future or out of scope of this library?

Thanks in advance

@kouchy
Copy link
Member

kouchy commented Oct 18, 2021

Hi @touisteur,

At this time this feature does not exist. Maybe you can use mipp::sum as a work around until I implement the popcount.

Hope it helps.

@hayguen
Copy link
Contributor

hayguen commented Oct 22, 2021

a look at https://github.com/kimwalisch/libpopcnt might be interesting - although i would think, there are different goals:

  • libpopcnt is targeted for big data sizes
  • mipp IMHO should target inlined code for simple data types

@kouchy : don't see how mipp::sum could be any workaround?!

@yzazik
Copy link

yzazik commented Oct 24, 2021

@hayguen I guess, you would use LUT to convert each byte/nibble to a number of set bits in it, then shuffle/permute and sum till you reach your lane width. Some libraries even do it recursively and optimizer unwinds it quite nicely.

@hayguen
Copy link
Contributor

hayguen commented Oct 24, 2021

@yzazik i had found my non-simd solution at https://graphics.stanford.edu/~seander/bithacks.html
specifically https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel , if i remind right
benchmarks showed, that it's very near to CPU intrinsic on x64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants