[FFmpeg-cvslog] lavu/fixed_dsp: R-V V scalarproduct

Rémi Denis-Courmont git at videolan.org
Sat Oct 7 17:46:36 EEST 2023


ffmpeg | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Oct  3 20:46:04 2023 +0300| [eb73d178ea7f18817eb4f0808eb44ab095f725b1] | committer: Rémi Denis-Courmont

lavu/fixed_dsp: R-V V scalarproduct

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=eb73d178ea7f18817eb4f0808eb44ab095f725b1
---

 libavutil/riscv/fixed_dsp_init.c |  6 +++++-
 libavutil/riscv/fixed_dsp_rvv.S  | 22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/libavutil/riscv/fixed_dsp_init.c b/libavutil/riscv/fixed_dsp_init.c
index d4ca2e2064..409b6d7b55 100644
--- a/libavutil/riscv/fixed_dsp_init.c
+++ b/libavutil/riscv/fixed_dsp_init.c
@@ -25,6 +25,7 @@
 #include "libavutil/cpu.h"
 #include "libavutil/fixed_dsp.h"
 
+int ff_scalarproduct_fixed_rvv(const int *v1, const int *v2, int len);
 void ff_butterflies_fixed_rvv(int *v1, int *v2, int len);
 
 av_cold void ff_fixed_dsp_init_riscv(AVFixedDSPContext *fdsp)
@@ -32,7 +33,10 @@ av_cold void ff_fixed_dsp_init_riscv(AVFixedDSPContext *fdsp)
 #if HAVE_RVV
     int flags = av_get_cpu_flags();
 
-    if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR))
+    if ((flags & AV_CPU_FLAG_RVV_I32) && (flags & AV_CPU_FLAG_RVB_ADDR)) {
+        if (flags & AV_CPU_FLAG_RVV_I64)
+            fdsp->scalarproduct_fixed = ff_scalarproduct_fixed_rvv;
         fdsp->butterflies_fixed = ff_butterflies_fixed_rvv;
+    }
 #endif
 }
diff --git a/libavutil/riscv/fixed_dsp_rvv.S b/libavutil/riscv/fixed_dsp_rvv.S
index 6e13395294..83cad4bde3 100644
--- a/libavutil/riscv/fixed_dsp_rvv.S
+++ b/libavutil/riscv/fixed_dsp_rvv.S
@@ -20,6 +20,28 @@
 
 #include "asm.S"
 
+func ff_scalarproduct_fixed_rvv, zve64x
+        li      t1, 1 << 30
+        vsetvli t0, zero, e64, m8, ta, ma
+        vmv.v.x v8, zero
+        vmv.s.x v0, t1
+1:
+        vsetvli t0, a2, e32, m4, tu, ma
+        vle32.v v16, (a0)
+        sub     a2, a2, t0
+        vle32.v v20, (a1)
+        sh2add  a0, t0, a0
+        vwmacc.vv v8, v16, v20
+        sh2add  a1, t0, a1
+        bnez    a2, 1b
+
+        vsetvli t0, zero, e64, m8, ta, ma
+        vredsum.vs v0, v8, v0
+        vmv.x.s a0, v0
+        srai    a0, a0, 31
+        ret
+endfunc
+
 // (a0) = (a0) + (a1), (a1) = (a0) - (a1) [0..a2-1]
 func ff_butterflies_fixed_rvv, zve32x
 1:



More information about the ffmpeg-cvslog mailing list