TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Popcount as an Example of Microbenchmarking in C [video]

4 pointsby teknotusover 10 years ago

1 comment

dalkeover 10 years ago
It was a decent presentation. Popcount has a long history, going back to the very first programming text book. (So says Knuth.) Someone interested in it might also like the chapter in &quot;Beautiful Code&quot;.<p>My own code does a lot of popcounts, of very wide (~1024 bit) values. A run might take several hours, so for me a 1% performance boost is still a couple of minutes of savings, and worth my development time to investigate.<p>On the other hand, I also use the POPCNT instruction if available, and fall back to the nibble LUT version using the shuffle instruction if available, before using the generic C versions. There are also some techniques that work for very large sets of bits that aren&#x27;t covered in this talk, which focused only on 32 bit&#x2F;word popcounts.