Skip to main content

hash_each_multithreaded

Function hash_each_multithreaded 

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

hash_each, using other CPU cores for collections whose small items total 512 KiB or more (and for individual items of 512 KiB or more, as hash_multithreaded does), returning the same digests. Requires out.len() == items.len().

use blake3_servil::{Mode, throughput::{self, Block}};
let blocks: Vec<Vec<Block>> = (0..100).map(|i| vec![Block([i as u8; 64]); (1000 * i as usize).div_ceil(64)]).collect();
let items: Vec<(&[Block], usize)> = blocks.iter().enumerate().map(|(i, b)| (&b[..], 1000 * i)).collect();
let (mut a, mut b) = (vec![[0u8; 32]; 100], vec![[0u8; 32]; 100]);
throughput::hash_each_multithreaded(Mode::Plain, &items, &mut a);
throughput::hash_each(Mode::Plain, &items, &mut b);
assert_eq!(a, b);