traits icon indicating copy to clipboard operation
traits copied to clipboard

universal-hash: parallel block processing

Open tarcieri opened this issue 4 years ago • 2 comments

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

tarcieri avatar Sep 08 '20 17:09 tarcieri

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).

tarcieri avatar Nov 03 '20 15:11 tarcieri

Note: #444 contains some discussion of this

tarcieri avatar Jan 03 '21 16:01 tarcieri