Module blake2b_simd::many
source · Expand description
Interfaces for hashing multiple inputs at once, using SIMD more efficiently.
The throughput of these interfaces is comparable to BLAKE2bp, about twice the throughput of regular BLAKE2b when AVX2 is available.
These interfaces can accept any number of inputs, and the implementation
does its best to parallelize them. In general, the more inputs you can pass
in at once the better. If you need to batch your inputs in smaller groups,
see the degree
function for a good batch size.
The implementation keeps working in parallel even when inputs are of different lengths, by managing a working set of jobs whose input isn’t yet exhausted. However, if one or two inputs are much longer than the others, and they’re encountered only at the end, there might not be any remaining work to parallelize them with. In this case, sorting the inputs longest-first can improve parallelism.
Example
use blake2b_simd::{blake2b, State, many::update_many};
let mut states = [
State::new(),
State::new(),
State::new(),
State::new(),
];
let inputs = [
&b"foo"[..],
&b"bar"[..],
&b"baz"[..],
&b"bing"[..],
];
update_many(states.iter_mut().zip(inputs.iter()));
for (state, input) in states.iter_mut().zip(inputs.iter()) {
assert_eq!(blake2b(input), state.finalize());
}
Structs
Constants
- The largest possible value of
degree
on the target platform.
Functions
- The parallelism degree of the implementation, detected at runtime. If you hash your inputs in small batches, making the batch size a multiple of
degree
will generally give good performance. - Hash any number of complete inputs all at once.
- Update any number of
State
objects at once.