richardstartin / richardstartin.github.io

12 stars 4 forks source link

posts/finding-bytes #36

Open utterances-bot opened 2 years ago

utterances-bot commented 2 years ago

Finding Bytes in Arrays | Richard Startin’s Blog

Thanks to everybody who reviewed and made helpful suggestions to improve this post.

https://richardstartin.github.io/posts/finding-bytes

zbjornson commented 2 years ago

Nice article.The vectorization example can be way simpler: cmp to compare each byte, pmovmskb to take the high bit of each byte, then lzcnt. Supported back to SSE2 (for 128b regs). If you have AVX-512, then you can compare into a k reg directly.

richardstartin commented 2 years ago

Nice article.The vectorization example can be way simpler: cmp to compare each byte, pmovmskb to take the high bit of each byte, then lzcnt. Supported back to SSE2 (for 128b regs). If you have AVX-512, then you can compare into a k reg directly.

The post is about what was possible with the Vector API prototype back in 2019. It may be possible to write simpler code now, but the API abstracts over instruction sets so won’t look exactly the same.

zbjornson commented 2 years ago

Ah right, looks like that sequence could be abstracted by VectorMask<T>::firstTrue() in JDK16.