Skip to main content

hash_each_multithreaded_with

Function hash_each_multithreaded_with 

Source
pub fn hash_each_multithreaded_with(
    mode: Mode<'_>,
    items: &[&[u8]],
    out: &mut [[u8; 32]],
)
Expand description

hash_each_with, using other CPU cores where that is faster: the same hashes, never slower. Collections of 512 KiB and more in all use them, as hash_multithreaded does. Requires out.len() == items.len().

use blake3_servil::Mode;
let items: Vec<Vec<u8>> = (0..100).map(|i| vec![i as u8; 1000 * i]).collect();
let slices: Vec<&[u8]> = items.iter().map(|m| m.as_slice()).collect();
let (mut a, mut b) = (vec![[0u8; 32]; 100], vec![[0u8; 32]; 100]);
blake3_servil::hash_each_multithreaded_with(Mode::Hash, &slices, &mut a);
blake3_servil::hash_each_with(Mode::Hash, &slices, &mut b);
assert_eq!(a, b);