traits
traits copied to clipboard
universal-hash: parallel block processing
SIMD implementations of UHFs are able to process multiple input blocks in parallel. However UniversalHash::update
only processes one-block-at-a-time.
There's some precedent for parallel block processing in the block-cipher
crate, which has an associated ParBlocks
type-level constant which signals how many blocks a given implementation can process in parallel:
https://docs.rs/block-cipher/0.8.0/block_cipher/trait.BlockCipher.html#associatedtype.ParBlocks
I believe @newpavlov wanted to make some changes to how that works, but regardless, universal-hash
should have similar support for processing multiple blocks in parallel in SIMD contexts
/cc @str4d
What would be really interesting here is a way to keep data in SIMD registers (e.g. XMM registers like __m128i) when passing the output of a cipher which can also be implemented using XMM registers (e.g. AES-CTR, ChaCha20) to a UHF.
Of course it'd have to be portable (e.g. falling back to u128
on other platforms), and some consideration might need to be made to a "packed" data type (i.e. u128x4
).
Note: #444 contains some discussion of this