History

lavc/flacdsp: optimise RVV vector type for lpc16

This calculates the optimal vector type value at run-time based on the hardware vector length and the FLAC LPC prediction order. In this particular case, the additional computation is easily amortised over the loop iterations: T-Head C908: C V before V after 1 48.0 214.7 95.2 2 64.7 214.2 94.7 3 79.7 213.5 94.5 4 96.2 196.5 94.2 # 5 111.0 195.7 118.5 6 127.0 211.2 102.0 7 143.7 194.2 101.5 8 175.7 193.2 101.2 # 9 176.2 224.2 126.0 10 191.5 192.0 125.5 11 224.5 191.2 124.7 12 223.0 190.2 124.2 13 239.2 189.5 123.7 14 253.7 188.7 139.5 15 286.2 188.0 122.7 16 284.0 187.0 122.5 # 17 300.2 186.5 186.5 18 314.0 185.5 185.7 19 329.7 184.7 185.0 20 343.0 184.2 184.2 21 358.7 199.2 183.7 22 371.7 182.7 182.7 23 387.5 181.7 182.0 24 400.7 181.0 181.2 25 431.5 180.2 196.5 26 443.7 195.5 196.0 27 459.0 178.7 196.2 28 470.7 177.7 194.2 29 470.0 177.0 193.5 30 481.2 176.2 176.5 31 496.2 175.5 175.7 32 507.2 174.7 191.0 # # Power of two boundary. With 128-bit vectors, improvements are expected for the first two test cases only. For the other two, there is overhead but below noise. Improvements should be better observable with prediction order of 8 and less, or on hardware with larger vector sizes.

Rémi Denis-Courmont committed 2 years ago

Commit 6ab4b921 parent ee1526c2 files · +4 −3Browse files

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

Unified · Split

2 files
  1. libavcodec/riscv/flacdsp_init.c +1 −1
  2. libavcodec/riscv/flacdsp_rvv.S +3 −2
libavcodec/riscv/flacdsp_init.c+1−1
@@ -71,7 +71,7 @@ av_cold void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, · 70 unmodified lines
71 if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {71 if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
72 int vlenb = ff_get_rv_vlenb();72 int vlenb = ff_get_rv_vlenb();
73 73
74 if (vlenb >= 16)74 if ((flags & AV_CPU_FLAG_RVB_BASIC) && vlenb >= 16)
75 c->lpc16 = ff_flac_lpc16_rvv;75 c->lpc16 = ff_flac_lpc16_rvv;
76 76
77# if (__riscv_xlen >= 64)77# if (__riscv_xlen >= 64)
libavcodec/riscv/flacdsp_rvv.S+3−2
@@ -20,8 +20,9 @@ · 19 unmodified lines
20 20
21#include "libavutil/riscv/asm.S"21#include "libavutil/riscv/asm.S"
22 22
23func ff_flac_lpc16_rvv, zve32x23func ff_flac_lpc16_rvv, zve32x, zbb
24 vsetvli zero, a2, e32, m8, ta, ma24 vtype_vli t0, a2, t2, e32, ta, ma
25 vsetvl zero, a2, t0
25 vle32.v v8, (a1)26 vle32.v v8, (a1)
26 sub a4, a4, a227 sub a4, a4, a2
27 vle32.v v16, (a0)28 vle32.v v16, (a0)

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