Module blake2b_simd::many[][src]

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

HashManyJob

A job for the hash_many function. After calling hash_many on a collection of HashManyJob objects, you can call to_hash on each job to get the result.

Constants

MAX_DEGREE

The largest possible value of degree on 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 degree will generally give good performance.

hash_many

Hash any number of complete inputs all at once.

update_many

Update any number of State objects at once.