Commit 2547f66b authored by David Michael Barr's avatar David Michael Barr

Add 8-bit benchmarks for all intra predictors

The inputs are generated with dav1d layout.
parent 02c89ba7
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
// PATENTS file, you can obtain it at www.aomedia.org/license/patent. // PATENTS file, you can obtain it at www.aomedia.org/license/patent.
use criterion::*; use criterion::*;
use rand::{ChaChaRng, Rng, SeedableRng}; use rand::{ChaChaRng, Rng, RngCore, SeedableRng};
use rav1e::partition::BlockSize; use rav1e::partition::BlockSize;
use rav1e::predict::{Block4x4, Intra}; use rav1e::predict::{Block4x4, Intra};
use util::*;
pub const BLOCK_SIZE: BlockSize = BlockSize::BLOCK_32X32; pub const BLOCK_SIZE: BlockSize = BlockSize::BLOCK_32X32;
...@@ -24,12 +25,13 @@ pub fn generate_block(rng: &mut ChaChaRng) -> (Vec<u16>, Vec<u16>, Vec<u16>) { ...@@ -24,12 +25,13 @@ pub fn generate_block(rng: &mut ChaChaRng) -> (Vec<u16>, Vec<u16>, Vec<u16>) {
(block, above_context, left_context) (block, above_context, left_context)
} }
pub fn generate_block_u8(rng: &mut ChaChaRng) -> (Vec<u8>, Vec<u8>, Vec<u8>) { pub fn generate_block_u8<'a>(
rng: &mut ChaChaRng, edge_buf: &'a mut AlignedArray<[u8; 65]>
) -> (Vec<u8>, &'a [u8], &'a [u8]) {
let block = vec![0u8; BLOCK_SIZE.width() * BLOCK_SIZE.height()]; let block = vec![0u8; BLOCK_SIZE.width() * BLOCK_SIZE.height()];
let above_context: Vec<u8> = rng.fill_bytes(&mut edge_buf.array);
(0..BLOCK_SIZE.height()).map(|_| rng.gen()).collect(); let above_context = &edge_buf.array[33..];
let left_context: Vec<u8> = let left_context = &edge_buf.array[..32];
(0..BLOCK_SIZE.width()).map(|_| rng.gen()).collect();
(block, above_context, left_context) (block, above_context, left_context)
} }
...@@ -53,7 +55,6 @@ where ...@@ -53,7 +55,6 @@ where
pub fn pred_bench(c: &mut Criterion) { pub fn pred_bench(c: &mut Criterion) {
bench_pred_fn(c, "intra_dc_4x4", intra_dc_4x4); bench_pred_fn(c, "intra_dc_4x4", intra_dc_4x4);
bench_pred_fn(c, "intra_dc_128_4x4_u8", intra_dc_128_4x4_u8);
bench_pred_fn(c, "intra_dc_left_4x4", intra_dc_left_4x4); bench_pred_fn(c, "intra_dc_left_4x4", intra_dc_left_4x4);
bench_pred_fn(c, "intra_dc_top_4x4", intra_dc_top_4x4); bench_pred_fn(c, "intra_dc_top_4x4", intra_dc_top_4x4);
bench_pred_fn(c, "intra_h_4x4", intra_h_4x4); bench_pred_fn(c, "intra_h_4x4", intra_h_4x4);
...@@ -63,29 +64,30 @@ pub fn pred_bench(c: &mut Criterion) { ...@@ -63,29 +64,30 @@ pub fn pred_bench(c: &mut Criterion) {
bench_pred_fn(c, "intra_smooth_h_4x4", intra_smooth_h_4x4); bench_pred_fn(c, "intra_smooth_h_4x4", intra_smooth_h_4x4);
bench_pred_fn(c, "intra_smooth_v_4x4", intra_smooth_v_4x4); bench_pred_fn(c, "intra_smooth_v_4x4", intra_smooth_v_4x4);
bench_pred_fn(c, "intra_cfl_4x4", intra_cfl_4x4); bench_pred_fn(c, "intra_cfl_4x4", intra_cfl_4x4);
bench_pred_fn(c, "intra_dc_4x4_u8", intra_dc_4x4_u8);
bench_pred_fn(c, "intra_dc_128_4x4_u8", intra_dc_128_4x4_u8);
bench_pred_fn(c, "intra_dc_left_4x4_u8", intra_dc_left_4x4_u8);
bench_pred_fn(c, "intra_dc_top_4x4_u8", intra_dc_top_4x4_u8);
bench_pred_fn(c, "intra_h_4x4_u8", intra_h_4x4_u8);
bench_pred_fn(c, "intra_v_4x4_u8", intra_v_4x4_u8);
bench_pred_fn(c, "intra_paeth_4x4_u8", intra_paeth_4x4_u8);
bench_pred_fn(c, "intra_smooth_4x4_u8", intra_smooth_4x4_u8);
bench_pred_fn(c, "intra_smooth_h_4x4_u8", intra_smooth_h_4x4_u8);
bench_pred_fn(c, "intra_smooth_v_4x4_u8", intra_smooth_v_4x4_u8);
} }
pub fn intra_dc_4x4(b: &mut Bencher) { pub fn intra_dc_4x4(b: &mut Bencher) {
let mut ra = ChaChaRng::from_seed([0; 32]); let mut rng = ChaChaRng::from_seed([0; 32]);
let (mut block, above, left) = generate_block(&mut ra); let (mut block, above, left) = generate_block(&mut rng);
b.iter(|| { b.iter(|| {
Block4x4::pred_dc(&mut block, BLOCK_SIZE.width(), &above[..4], &left[..4]); Block4x4::pred_dc(&mut block, BLOCK_SIZE.width(), &above[..4], &left[..4]);
}) })
} }
pub fn intra_dc_128_4x4_u8(b: &mut Bencher) {
let mut ra = ChaChaRng::from_seed([0; 32]);
let (mut block, _above, _left) = generate_block_u8(&mut ra);
b.iter(|| {
Block4x4::pred_dc_128(&mut block, BLOCK_SIZE.width(), 8);
})
}
pub fn intra_dc_left_4x4(b: &mut Bencher) { pub fn intra_dc_left_4x4(b: &mut Bencher) {
let mut ra = ChaChaRng::from_seed([0; 32]); let mut rng = ChaChaRng::from_seed([0; 32]);
let (mut block, above, left) = generate_block(&mut ra); let (mut block, above, left) = generate_block(&mut rng);
b.iter(|| { b.iter(|| {
Block4x4::pred_dc_left( Block4x4::pred_dc_left(
...@@ -98,8 +100,8 @@ pub fn intra_dc_left_4x4(b: &mut Bencher) { ...@@ -98,8 +100,8 @@ pub fn intra_dc_left_4x4(b: &mut Bencher) {
} }
pub fn intra_dc_top_4x4(b: &mut Bencher) { pub fn intra_dc_top_4x4(b: &mut Bencher) {
let mut ra = ChaChaRng::from_seed([0; 32]); let mut rng = ChaChaRng::from_seed([0; 32]);
let (mut block, above, left) = generate_block(&mut ra); let (mut block, above, left) = generate_block(&mut rng);
b.iter(|| { b.iter(|| {
Block4x4::pred_dc_top( Block4x4::pred_dc_top(
...@@ -197,3 +199,140 @@ pub fn intra_cfl_4x4(b: &mut Bencher) { ...@@ -197,3 +199,140 @@ pub fn intra_cfl_4x4(b: &mut Bencher) {
Block4x4::pred_cfl(&mut block, BLOCK_SIZE.width(), &ac, alpha, 8); Block4x4::pred_cfl(&mut block, BLOCK_SIZE.width(), &ac, alpha, 8);
}) })
} }
pub fn intra_dc_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_dc(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
pub fn intra_dc_128_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, _above, _left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_dc_128(&mut block, BLOCK_SIZE.width(), 8);
})
}
pub fn intra_dc_left_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_dc_left(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
pub fn intra_dc_top_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_dc_top(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
pub fn intra_h_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, _above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_h(&mut block, BLOCK_SIZE.width(), &left[32 - 4..]);
})
}
pub fn intra_v_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, _left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_v(&mut block, BLOCK_SIZE.width(), &above[..4]);
})
}
pub fn intra_paeth_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
let above_left = unsafe { *above.as_ptr().offset(-1) };
b.iter(|| {
Block4x4::pred_paeth(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..],
above_left
);
})
}
pub fn intra_smooth_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_smooth(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
pub fn intra_smooth_h_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_smooth_h(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
pub fn intra_smooth_v_4x4_u8(b: &mut Bencher) {
let mut rng = ChaChaRng::from_seed([0; 32]);
let mut edge_buf = UninitializedAlignedArray();
let (mut block, above, left) = generate_block_u8(&mut rng, &mut edge_buf);
b.iter(|| {
Block4x4::pred_smooth_v(
&mut block,
BLOCK_SIZE.width(),
&above[..4],
&left[32 - 4..]
);
})
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment