History

lavc/pixblockdsp: rework R-V V get_pixels_unaligned

As in the aligned case, we can use VLSE64.V, though the way of doing so gets more convoluted, so the performance gains are more modest: get_pixels_unaligned_c: 126.7 get_pixels_unaligned_rvv_i32: 145.5 (before) get_pixels_unaligned_rvv_i64: 62.2 (after) For the reference, those are the aligned benchmarks (unchanged) on the same T-Head C908 hardware: get_pixels_c: 126.7 get_pixels_rvi: 85.7 get_pixels_rvv_i64: 33.2

Rémi Denis-Courmont committed 3 years ago

Commit 02594c81 parent f68ad5d2 files · +24 −21Browse files

Showing the changes to libavcodec (2 of 2 files). Show all

Unified · Split

2 files
  1. libavcodec/riscv/pixblockdsp_init.c +7 −10
  2. libavcodec/riscv/pixblockdsp_rvv.S +17 −11
libavcodec/riscv/pixblockdsp_init.c+7−10
@@ -56,20 +56,17 @@ av_cold void ff_pixblockdsp_init_riscv(PixblockDSPContext *c, · 55 unmodified lines
5656
5757 #if HAVE_RVV
5858 if ((cpu_flags & AV_CPU_FLAG_RVV_I32) && ff_get_rv_vlenb() >= 16) {
59− if (!high_bit_depth) {
60− c->get_pixels = ff_get_pixels_unaligned_8_rvv;
61− c->get_pixels_unaligned = ff_get_pixels_unaligned_8_rvv;
62− }
63−
6459 c->diff_pixels = ff_diff_pixels_unaligned_rvv;
6560 c->diff_pixels_unaligned = ff_diff_pixels_unaligned_rvv;
61+ }
6662
67− if (cpu_flags & AV_CPU_FLAG_RVV_I64) {
68− if (!high_bit_depth)
69− c->get_pixels = ff_get_pixels_8_rvv;
70−
71− c->diff_pixels = ff_diff_pixels_rvv;
63+ if ((cpu_flags & AV_CPU_FLAG_RVV_I64) && ff_get_rv_vlenb() >= 16) {
64+ if (!high_bit_depth) {
65+ c->get_pixels = ff_get_pixels_8_rvv;
66+ c->get_pixels_unaligned = ff_get_pixels_unaligned_8_rvv;
7267 }
68+
69+ c->diff_pixels = ff_diff_pixels_rvv;
7370 }
7471 #endif
7572 }
libavcodec/riscv/pixblockdsp_rvv.S+17−11
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 func ff_get_pixels_8_rvv, zve64x
2424 vsetivli zero, 8, e8, mf2, ta, ma
2525 li t0, 8 * 8
26+1:
2627 vlse64.v v16, (a1), a2
2728 vsetvli zero, t0, e8, m4, ta, ma
2829 vwcvtu.x.x.v v8, v16
@@ -30,18 +31,23 @@ func ff_get_pixels_8_rvv, zve64x · 1 unmodified line
3031 ret
3132 endfunc
3233
33−func ff_get_pixels_unaligned_8_rvv, zve32x
34− vsetivli zero, 8, e8, mf2, ta, ma
35− vlsseg8e8.v v16, (a1), a2
34+func ff_get_pixels_unaligned_8_rvv, zve64x
35+ andi t1, a1, 7
36+ vsetivli zero, 8, e64, m4, ta, ma
37+ li t0, 8 * 8
38+ beqz t1, 1b
39+ andi a1, a1, -8
40+ slli t2, t1, 3
41+ addi t1, a1, 8
42+ sub t3, t0, t2
43+ vlse64.v v16, (a1), a2
44+ vlse64.v v24, (t1), a2
45+ vsrl.vx v16, v16, t2
46+ vsll.vx v24, v24, t3
47+ vor.vv v16, v16, v24
48+ vsetvli zero, t0, e8, m4, ta, ma
3649 vwcvtu.x.x.v v8, v16
37− vwcvtu.x.x.v v9, v17
38− vwcvtu.x.x.v v10, v18
39− vwcvtu.x.x.v v11, v19
40− vwcvtu.x.x.v v12, v20
41− vwcvtu.x.x.v v13, v21
42− vwcvtu.x.x.v v14, v22
43− vwcvtu.x.x.v v15, v23
44− vsseg8e16.v v8, (a0)
50+ vse16.v v8, (a0)
4551 ret
4652 endfunc
4753

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t