forge
Explore
Log in

Don't you dare go Hollow

Constant-length row copies on the whole-pel inter path

Browse files at this commit

3a35e5fda4b730e38f9ec7c62360737d22ffda89Ahmet Kaan GümüşParent: 209d003
  • perf
    • constant-length row copies on the whole-pel inter path
Show full message
perf(av1): constant-length row copies on the whole-pel inter path

A whole-pel prediction is a clamped copy, and its per-row
`copy_from_slice` compiled to a `memcpy` call with a runtime length --
for the 8-sample row of an 8x8 block (the most common inter shape on
real 4K content) the call costs more than the move it makes. The three
common widths get a constant length, which inlines.

-0.11% instructions on the 4K segment (523.67 -> 523.07 G at one
thread), -5.4% cumulative; all twelve gate hashes unchanged.
crates/ec-av1/src/mc.rsmodified+10 -1
@@ -1063,7 +1063,16 @@ pub(crate) fn predict_with_filters_kern(
10631063 // lane-perf2: an interior row is one contiguous copy.
10641064 if x0 >= 0 && x0 as usize + block_w <= true_width {
10651065 if let Some(src) = reference.get(row_base + x0 as usize..row_base + x0 as usize + block_w) {
1066- out.copy_from_slice(src);
1066+ // The common widths get a constant-length copy: at 8
1067+ // samples a `memcpy` call costs more than the move it
1068+ // makes, and 8x8 is the most common inter block on real
1069+ // 4K content.
1070+ match block_w {
1071+ 4 => out[..4].copy_from_slice(&src[..4]),
1072+ 8 => out[..8].copy_from_slice(&src[..8]),
1073+ 16 => out[..16].copy_from_slice(&src[..16]),
1074+ _ => out.copy_from_slice(src),
1075+ }
10671076 continue;
10681077 }
10691078 }