2 ms·
Yes, that makes sense now. Thanks! Edit: I fiddled around a bit and came up with: https://pastebin.com/WA1Tp2KK https://pastebin.com/WA1Tp2KK The nullprogram
by sounds 9y ago
Yes, that makes sense now. Thanks!
Edit: I fiddled around a bit and came up with:
https://pastebin.com/WA1Tp2KK https://pastebin.com/WA1Tp2KK
The nullprogram.com version is 0x185 bytes (gcc 4.8.4 x86_64 -O3; objdump -s -j .text -j .rodata)
I switched to __builtin_clz (with cross platform support). I hesitate to put in your assembly code, though it would work great! My version still sticks to C and not inline assembly.
My version takes 0xeb bytes.
Benchmarking with clang-802.0.42 -O3 -march=native on a Core i7-4770HQ @ 2.20GHz:
branchless: 490.666725 MB/s, 0 errors
0xeb small: 352.000042 MB/s, 0 errors
Hoehrmann: 337.333374 MB/s, 0 errors
With gcc 4.8.4 -O3 -march=native on a Xeon E5-1650v3 @ 3.50GHz:
branchless: 436.000052 MB/s, 0 errors
0xeb small: 345.333375 MB/s, 0 errors
Hoehrmann: 412.000049 MB/s, 0 errors
[1] https://stackoverflow.com/questions/19527897/how-undefined-are-builtin-ctz0-or-builtin-clz0 https://stackoverflow.com/questions/19527897/how-undefined-a...
- sounds 9y agoI was able to reduce it to 0xe9 bytes and I'm getting: clang-802.0.42 -O3 -march=native on a Core i7-4770HQ @ 2.20GHz: branchless: 490.666725 MB/s, 0 errors 0xe9 small: 380.000045 MB/s, 0 errors Hoehrmann: 337.333374 MB/s, 0 errors With gcc 4.8.4 -O3 -march=native on a Xeon E5-1650v3 @ 3.50GHz: branchless: 436.000052 MB/s, 0 errors 0xe9 small: 405.333382 MB/s, 0 errors Hoehrmann: 412.000049 MB/s, 0 errors https://pastebin.com/j7T3bDwR https://pastebin.com/j7T3bDwR