1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-28 01:16:02 +02:00

add benchmarks for AVX-512 and NEON

This commit is contained in:
Jack O'Connor 2019-12-08 18:17:09 -05:00
parent 78191a676f
commit ae7271cc87
3 changed files with 45 additions and 0 deletions

View File

@ -80,6 +80,15 @@ fn bench_single_compression_sse41(b: &mut Bencher) {
bench_single_compression_fn(b, blake3::sse41::compress);
}
#[bench]
#[cfg(feature = "c_avx512")]
fn bench_single_compression_avx512(b: &mut Bencher) {
if !blake3::platform::avx512_detected() {
return;
}
bench_single_compression_fn(b, blake3::c_avx512::compress);
}
type HashManyFn<A> = unsafe fn(
inputs: &[&A],
key: &[u8; blake3::KEY_LEN],
@ -136,6 +145,22 @@ fn bench_many_chunks_avx2(b: &mut Bencher) {
bench_many_chunks_fn(b, blake3::avx2::hash_many, blake3::avx2::DEGREE);
}
#[bench]
#[cfg(feature = "c_avx512")]
fn bench_many_chunks_avx512(b: &mut Bencher) {
if !blake3::platform::avx512_detected() {
return;
}
bench_many_chunks_fn(b, blake3::c_avx512::hash_many, blake3::c_avx512::DEGREE);
}
#[bench]
#[cfg(feature = "c_neon")]
fn bench_many_chunks_neon(b: &mut Bencher) {
// When "c_neon" is on, NEON support is assumed.
bench_many_chunks_fn(b, blake3::c_neon::hash_many, blake3::c_neon::DEGREE);
}
// TODO: When we get const generics we can unify this with the chunks code.
fn bench_many_parents_fn(b: &mut Bencher, f: HashManyFn<[u8; BLOCK_LEN]>, degree: usize) {
let mut inputs = Vec::new();
@ -182,6 +207,22 @@ fn bench_many_parents_avx2(b: &mut Bencher) {
bench_many_parents_fn(b, blake3::avx2::hash_many, blake3::avx2::DEGREE);
}
#[bench]
#[cfg(feature = "c_avx512")]
fn bench_many_parents_avx512(b: &mut Bencher) {
if !blake3::platform::avx512_detected() {
return;
}
bench_many_parents_fn(b, blake3::c_avx512::hash_many, blake3::c_avx512::DEGREE);
}
#[bench]
#[cfg(feature = "c_neon")]
fn bench_many_parents_neon(b: &mut Bencher) {
// When "c_neon" is on, NEON support is assumed.
bench_many_parents_fn(b, blake3::c_neon::hash_many, blake3::c_neon::DEGREE);
}
fn bench_atonce(b: &mut Bencher, len: usize) {
let mut input = RandomInput::new(b, len);
b.iter(|| blake3::hash(input.get()));

View File

@ -1,5 +1,7 @@
use crate::{OffsetDeltas, BLOCK_LEN, KEY_LEN, OUT_LEN};
pub const DEGREE: usize = 16;
// Unsafe because this may only be called on platforms supporting AVX-512.
pub unsafe fn compress(
cv: &[u8; 32],

View File

@ -1,5 +1,7 @@
use crate::{OffsetDeltas, BLOCK_LEN, KEY_LEN, OUT_LEN};
pub const DEGREE: usize = 4;
// Unsafe because this may only be called on platforms supporting NEON.
pub unsafe fn hash_many<A: arrayvec::Array<Item = u8>>(
inputs: &[&A],