4 ms·
use the popcnt instruction or the popcnt intrinsic function. It counts how many bits are set to 1, you’re looking for 0. You can also cast it into a uint64_t
by _3u10 5y ago
use the popcnt instruction or the popcnt intrinsic function.
It counts how many bits are set to 1, you’re looking for 0.
You can also cast it into a uint64_t integer and do an equality test. There might be a way to use fused multiply add.
Also are you mmaping the file so you can just read it directly as a single buffer? You should be able to madvise to free pages after they’ve been checked.
PUSHFB can also be used. http://0x80.pl/articles/sse-popcount.html http://0x80.pl/articles/sse-popcount.html
Essentially you want to vectorize this tho memcmp may already be vectorized and do the cpu detection.
Edit: also…
You should be able to load 15 x 256 bits and then test them.
Try VPTEST
https://www.intel.com/content/www/us/en/develop/documentation/cpp-compiler-developer-guide-and-reference/top/compiler-reference/intrinsics/intrinsics-for-intel-advanced-vector-extensions/intrinsics-for-packed-test-operations/mm256-testz-si256.html https://www.intel.com/content/www/us/en/develop/documentatio...