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§
- Hash
Many Job - A job for the
hash_manyfunction. After callinghash_manyon a collection ofHashManyJobobjects, you can callto_hashon each job to get the result.
Constants§
- MAX_
DEGREE - The largest possible value of
degreeon the target platform.
Functions§
- degree
- The parallelism degree of the implementation, detected at runtime. If you
hash your inputs in small batches, making the batch size a multiple of
degreewill generally give good performance. - hash_
many - Hash any number of complete inputs all at once.
- update_
many - Update any number of
Stateobjects at once.