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: Re: [FFmpeg-devel] [PATCH] lavu/float_dsp: rework RISC-V V scalar product
Date: Mon, 17 Jul 2023 20:51:16 +0300
Message-ID: <28161559.SLL423Wn8p@basile.remlab.net> (raw)
In-Reply-To: <20230717172557.15848-1-remi@remlab.net>

Le maanantaina 17. heinäkuuta 2023, 20.25.57 EEST Rémi Denis-Courmont a écrit 
:
> 1) Take the reductive sum out of the loop,
>    leaving a regular vector addition in the loop.
> 2) Merge the addition and the multiplication.
> 3) Unroll.
> 
> Before:
> scalarproduct_float_rvv_f32: 832.5
> 
> After:
> scalarproduct_float_rvv_f32: 275.2
> ---
>  libavutil/riscv/float_dsp_rvv.S | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/libavutil/riscv/float_dsp_rvv.S
> b/libavutil/riscv/float_dsp_rvv.S index 77961b7387..c80fde2f7e 100644
> --- a/libavutil/riscv/float_dsp_rvv.S
> +++ b/libavutil/riscv/float_dsp_rvv.S
> @@ -166,20 +166,21 @@ endfunc
> 
>  // a0 = (a0).(a1) [0..a2-1]
>  func ff_scalarproduct_float_rvv, zve32f
> -        vsetivli     zero, 1, e32, m1, ta, ma
> -        vmv.s.x      v8, zero
> +        vsetvli      t0, zero, e32, m8, ta, ma
> +        vmv.v.x      v8, zero
> +        vmv.s.x      v0, zero
>  1:
> -        vsetvli      t0, a2, e32, m1, ta, ma
> +        vsetvli      t0, a2, e32, m8, tu, ma
>          vle32.v      v16, (a0)
>          sub          a2, a2, t0
>          vle32.v      v24, (a1)
>          sh2add       a0, t0, a0
> -        vfmul.vv     v16, v16, v24
> +        vfmacc.vv    v8, v16, v24
>          sh2add       a1, t0, a1
> -        vfredusum.vs v8, v16, v8
>          bnez         a2, 1b
> 
> -        vfmv.f.s fa0, v8
> +        vfredusum.vs v0, v8, v0

Missing vsetvli; this won't work unless the input vector size is a multiple of 
the hardware vector length.

> +        vfmv.f.s     fa0, v0
>  NOHWF   fmv.x.w  a0, fa0
>          ret
>  endfunc


-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/



_______________________________________________
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:[~2023-07-17 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-17 17:25 Rémi Denis-Courmont
2023-07-17 17:51 ` Rémi Denis-Courmont [this message]

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=28161559.SLL423Wn8p@basile.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