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

Provide a builtin for population counting / hamming distance #10757

Closed
brtzsnr opened this Issue May 8, 2015 · 1 comment

Comments

Projects
None yet
3 participants
@brtzsnr
Contributor

brtzsnr commented May 8, 2015

This feature was requested before #4988 but the bug was closed as WAI. I believe having popcnt part of standard library would benefit greatly many libraries.

For example there are two popcnt implementation in the golang tools:
https://github.com/golang/go/blob/dev.ssa/src/cmd/internal/ssa/regalloc.go#L39
https://github.com/golang/tools/blob/master/container/intsets/util.go#L22

It is also provided by several third party libraries
http://go-search.org/search?q=popcnt
http://go-search.org/search?q=popcount

These implementation are incomplete: the libraries provide assembly for one platform (amd64 in the best case), may not be not inlined (function call will dominate the benchmarks http://stackoverflow.com/questions/25471369/performance-discrepancy-in-compiled-vs-hand-written-assembly), are not well test, or are under a restrictive licence.

There is also a long standing bug #4816 which requests the POPCNT instruction on amd64. With POPCNT instruction population counting can be turned into a single instruction similarly to math.Sqrt (https://go-review.googlesource.com/#/c/8465/).

popcnt is very often used by chess, go (the game), checkers engines, all of them would benefit from a fast popcnt. #7357 provides another real word usage. Also a Go developer expressed his wish for popcnt (and other similar operations) to be provided by the standard library (https://go-review.googlesource.com/#/c/9761/1/src/cmd/internal/ssa/regalloc.go@41).

@robpike

This comment has been minimized.

Show comment
Hide comment
@robpike

robpike May 8, 2015

Contributor

Duplicate of #4988

No need for this to be in the standard library.

Contributor

robpike commented May 8, 2015

Duplicate of #4988

No need for this to be in the standard library.

@robpike robpike closed this May 8, 2015

@golang golang locked and limited conversation to collaborators Jun 25, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.