Skip to main content

finalize_each

Function finalize_each 

Source
pub fn finalize_each(
    hashers: &mut [Hasher],
    which: &[usize],
    out: &mut [[u8; 32]],
)
Expand description

The hash of each message which names: out[k] is what hashers[which[k]].finalize() would give, and that hasher is then reset for its next message (no length hint). Requires out.len() == which.len(), each index < hashers.len(), and distinct indices: it panics on an index named twice, in every build. A call that is refused hashes nothing and leaves every hasher as it was. Messages that finish in one call hash side by side where the CPU has the lanes (with at least two eligible hashers in a 128-hasher window): on x86-64, staged plain 1 KiB chunks via hash_many_rounded (ceiling 32 lanes on Zen 5 / 16 on AVX-512 / 8 on AVX2 / 4 on SSE4.1), staged plain multi-block 65..=1023 B messages on AVX2/AVX-512 via hash_by_blocks (equal-prefix-length blocks batched in SIMD, and on Linux x86-64 AVX-512/AVX2 their final blocks compressed in output16/output8 SIMD lanes for chunks of four or more; SSE4.1 finishes staged < 1 KiB messages individually), and output16/output8 for every 4+ eligible counter-zero final blocks packed from remaining hashers on Linux AVX-512/AVX2; on AArch64, staged plain messages of up to 1024 bytes via hash_by_blocks and counter-zero final blocks via NEON output8.

§Panics

Panics if out.len() != which.len(), an index is out of range, an index is repeated, or any named hasher was poisoned (after a panic). A refused call hashes nothing, leaves out untouched, and leaves every hasher as it was.

§Key-dependent timing

Selected hashers may use different secret keys. Key values and key equality select neither the finalization path nor its amount of work. See the key-independence contract.