Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Rémi Denis-Courmont" <remi@remlab.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] lavc/ac3dsp: R-V V sum_square_butterfly_float
Date: Mon, 29 Apr 2024 22:21:44 +0300
Message-ID: <20240429192144.84571-2-remi@remlab.net> (raw)
In-Reply-To: <20240429192144.84571-1-remi@remlab.net>

As we do not need to widen accumulators to 64 bits, we effectively get
double capacity for unrolling compared to the integer function. This
explains the slightly better performance gains.

ac3_sum_square_bufferfly_float_c:       65.2
ac3_sum_square_bufferfly_float_rvv_f32: 12.2
---
 libavcodec/riscv/ac3dsp_init.c |  6 +++++-
 libavcodec/riscv/ac3dsp_rvv.S  | 39 ++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/libavcodec/riscv/ac3dsp_init.c b/libavcodec/riscv/ac3dsp_init.c
index be5e153fac..e120aa2dce 100644
--- a/libavcodec/riscv/ac3dsp_init.c
+++ b/libavcodec/riscv/ac3dsp_init.c
@@ -30,6 +30,8 @@ void ff_extract_exponents_rvb(uint8_t *exp, int32_t *coef, int nb_coefs);
 void ff_float_to_fixed24_rvv(int32_t *dst, const float *src, size_t len);
 void ff_sum_square_butterfly_int32_rvv(int64_t *, const int32_t *,
                                        const int32_t *, int);
+void ff_sum_square_butterfly_float_rvv(float *, const float *,
+                                       const float *, int);
 
 av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
 {
@@ -39,8 +41,10 @@ av_cold void ff_ac3dsp_init_riscv(AC3DSPContext *c)
     if (flags & AV_CPU_FLAG_RVB_ADDR) {
         if (flags & AV_CPU_FLAG_RVB_BASIC)
             c->extract_exponents = ff_extract_exponents_rvb;
-        if (flags & AV_CPU_FLAG_RVV_F32)
+        if (flags & AV_CPU_FLAG_RVV_F32) {
             c->float_to_fixed24 = ff_float_to_fixed24_rvv;
+            c->sum_square_butterfly_float = ff_sum_square_butterfly_float_rvv;
+        }
 # if __riscv_xlen >= 64
         if (flags & AV_CPU_FLAG_RVV_I64)
             c->sum_square_butterfly_int32 = ff_sum_square_butterfly_int32_rvv;
diff --git a/libavcodec/riscv/ac3dsp_rvv.S b/libavcodec/riscv/ac3dsp_rvv.S
index dd0b4cd797..397e000ab0 100644
--- a/libavcodec/riscv/ac3dsp_rvv.S
+++ b/libavcodec/riscv/ac3dsp_rvv.S
@@ -78,3 +78,42 @@ func ff_sum_square_butterfly_int32_rvv, zve64x
         ret
 endfunc
 #endif
+
+func ff_sum_square_butterfly_float_rvv, zve32f
+        vsetvli     t0, zero, e32, m8, ta, ma
+        vmv.v.x     v0, zero
+        vmv.v.x     v8, zero
+1:
+        vsetvli     t0, a3, e32, m4, tu, ma
+        vle32.v     v16, (a1)
+        sub         a3, a3, t0
+        vle32.v     v20, (a2)
+        sh2add      a1, t0, a1
+        vfadd.vv    v24, v16, v20
+        sh2add      a2, t0, a2
+        vfsub.vv    v28, v16, v20
+        vfmacc.vv   v0, v16, v16
+        vfmacc.vv   v4, v20, v20
+        vfmacc.vv   v8, v24, v24
+        vfmacc.vv   v12, v28, v28
+        bnez        a3, 1b
+
+        vsetvli     t0, zero, e32, m4, ta, ma
+        vmv.s.x     v16, zero
+        vmv.s.x     v17, zero
+        vfredsum.vs v16, v0, v16
+        vmv.s.x     v18, zero
+        vfredsum.vs v17, v4, v17
+        vmv.s.x     v19, zero
+        vfredsum.vs v18, v8, v18
+        vfmv.f.s    ft0, v16
+        vfredsum.vs v19, v12, v19
+        vfmv.f.s    ft1, v17
+        fsw         ft0,   (a0)
+        vfmv.f.s    ft2, v18
+        fsw         ft1,  4(a0)
+        vfmv.f.s    ft3, v19
+        fsw         ft2,  8(a0)
+        fsw         ft3, 12(a0)
+        ret
+endfunc
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-04-29 19:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 19:21 [FFmpeg-devel] [PATCH 1/2] lavc/ac3dsp: R-V V sum_square_butterfly_int32 Rémi Denis-Courmont
2024-04-29 19:21 ` Rémi Denis-Courmont [this message]
2024-05-01  6:40 ` [FFmpeg-devel] [PATCH 3/3] lavc/ac3dsp: R-V V min_exponents Rémi Denis-Courmont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240429192144.84571-2-remi@remlab.net \
    --to=remi@remlab.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git