3 ms·
A lot of these were the recruiter having no understanding of what they were asking, but the bit counting is just nonsense. A lookup table requires an extra mem
by AboutTheWhisles 8y ago
A lot of these were the recruiter having no understanding of what they were asking, but the bit counting is just nonsense. A lookup table requires an extra memory access that by its nature is incoherent.
Contrast that to being able to read the memory straight through and having it prefetched, then using the popcnt instruction:
https://www.felixcloutier.com/x86/POPCNT.html https://www.felixcloutier.com/x86/POPCNT.html
- compumike 8y agoAccessible as __builtin__popcountll(unsigned long long) in gcc or clang. Especially handy if you're writing a chess bot.
- zeusk 8y ago> A lookup table requires an extra memory access that by its nature is incoherent. Pedantic but, the LUT would also remain in the cache if there wasn't some issue with cacheline contention. Although, I do agree that POPCNT + prefetch and unrolling will do much better.
- AboutTheWhisles 8y agoI thought the same thing, although I've tried LUT approaches to other problems like gauss curves and the results were much slower than I expected. The LUT may stay in the L2 cache, but whatever was going on, there was actually a big discrepancy between looking values up and just calculating the gauss curve equation even though it had exponents on floats.