Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad
@ 2024-02-06 15:56 flow gg
  2024-02-21 18:07 ` Rémi Denis-Courmont
  0 siblings, 1 reply; 4+ messages in thread
From: flow gg @ 2024-02-06 15:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: 0005-lavc-me_cmp-R-V-V-vsse-vsad.patch --]
[-- Type: text/x-patch, Size: 4704 bytes --]

From 67f2a662be1533e52a28971152bff670f78544fd Mon Sep 17 00:00:00 2001
From: sunyuechi <sunyuechi@iscas.ac.cn>
Date: Tue, 6 Feb 2024 23:18:51 +0800
Subject: [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad

C908:
vsad_0_c: 936.0
vsad_0_rvv_i32: 236.2
vsad_1_c: 424.0
vsad_1_rvv_i32: 190.2
vsse_0_c: 877.0
vsse_0_rvv_i32: 204.2
vsse_1_c: 439.0
vsse_1_rvv_i32: 140.2
---
 libavcodec/riscv/me_cmp_init.c | 10 ++++
 libavcodec/riscv/me_cmp_rvv.S  | 98 ++++++++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)

diff --git a/libavcodec/riscv/me_cmp_init.c b/libavcodec/riscv/me_cmp_init.c
index 85ecc22cbc..a6ef5addd0 100644
--- a/libavcodec/riscv/me_cmp_init.c
+++ b/libavcodec/riscv/me_cmp_init.c
@@ -46,6 +46,11 @@ int ff_sse8_rvv(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
 int ff_sse4_rvv(MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2,
                    ptrdiff_t stride, int h);
 
+int ff_vsse16_rvv(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
+int ff_vsse8_rvv(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
+int ff_vsad16_rvv(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
+int ff_vsad8_rvv(MpegEncContext *c, const uint8_t *s1, const uint8_t *s2, ptrdiff_t stride, int h);
+
 av_cold void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx)
 {
 #if HAVE_RVV
@@ -64,6 +69,11 @@ av_cold void ff_me_cmp_init_riscv(MECmpContext *c, AVCodecContext *avctx)
         c->sse[0] = ff_sse16_rvv;
         c->sse[1] = ff_sse8_rvv;
         c->sse[2] = ff_sse4_rvv;
+
+        c->vsse[0] = ff_vsse16_rvv;
+        c->vsse[1] = ff_vsse8_rvv;
+        c->vsad[0] = ff_vsad16_rvv;
+        c->vsad[1] = ff_vsad8_rvv;
     }
 #endif
 }
diff --git a/libavcodec/riscv/me_cmp_rvv.S b/libavcodec/riscv/me_cmp_rvv.S
index 11848f3f21..25b15c74ce 100644
--- a/libavcodec/riscv/me_cmp_rvv.S
+++ b/libavcodec/riscv/me_cmp_rvv.S
@@ -231,3 +231,101 @@ func ff_sse4_rvv, zve32x
         vmv.x.s         a0, v0
         ret
 endfunc
+
+.macro vabsaddu dst src tmp
+        vneg.v          \tmp, \src
+        vmax.vv         \tmp, \src, \tmp
+        vwaddu.wv       \dst, \dst, \tmp
+.endm
+
+.macro  vsad_vsse16 type
+        vsetivli        t0, 16, e32, m4, ta, ma
+        addi            a4, a4, -1
+        add             t1, a1, a3
+        add             t2, a2, a3
+        vmv.v.x         v24, zero
+        vmv.s.x         v0, zero
+1:
+        vsetvli         zero, zero, e8, m1, tu, ma
+        vle8.v          v4, (a1)
+        vle8.v          v8, (t1)
+        vle8.v          v12, (a2)
+        vle8.v          v16, (t2)
+        addi            a4, a4, -1
+        vwsubu.vv       v28, v4, v12
+        vwsubu.wv       v12, v28, v8
+        vwaddu.wv       v28, v12, v16
+        vsetvli         zero, zero, e16, m2, tu, ma
+
+.ifc \type,abs
+        vabsaddu        v24, v28, v12
+.endif
+.ifc \type,square
+        vwmacc.vv       v24, v28, v28
+.endif
+
+        add             a1, a1, a3
+        add             a2, a2, a3
+        add             t1, t1, a3
+        add             t2, t2, a3
+        bnez            a4, 1b
+
+        vsetvli         zero, zero, e32, m4, tu, ma
+        vredsum.vs      v0, v24, v0
+        vmv.x.s         a0, v0
+        ret
+.endm
+
+.macro  vsad_vsse8 type
+        vsetivli        t0, 8, e32, m2, ta, ma
+        addi            a4, a4, -1
+        add             t1, a1, a3
+        add             t2, a2, a3
+        vmv.v.x         v24, zero
+        vmv.s.x         v0, zero
+1:
+        vsetvli         zero, zero, e8, mf2, tu, ma
+        vle8.v          v4, (a1)
+        vle8.v          v8, (t1)
+        vle8.v          v12, (a2)
+        vle8.v          v16, (t2)
+        addi            a4, a4, -1
+        vwsubu.vv       v28, v4, v12
+        vwsubu.wv       v12, v28, v8
+        vwaddu.wv       v28, v12, v16
+        vsetvli         zero, zero, e16, m1, tu, ma
+
+.ifc \type,abs
+        vabsaddu        v24, v28, v12
+.endif
+.ifc \type,square
+        vwmacc.vv       v24, v28, v28
+.endif
+
+        add             a1, a1, a3
+        add             a2, a2, a3
+        add             t1, t1, a3
+        add             t2, t2, a3
+        bnez            a4, 1b
+
+        vsetvli         zero, zero, e32, m2, tu, ma
+        vredsum.vs      v0, v24, v0
+        vmv.x.s         a0, v0
+        ret
+.endm
+
+func ff_vsse16_rvv, zve32x
+        vsad_vsse16 square
+endfunc
+
+func ff_vsse8_rvv, zve32x
+        vsad_vsse8 square
+endfunc
+
+func ff_vsad16_rvv, zve32x
+        vsad_vsse16 abs
+endfunc
+
+func ff_vsad8_rvv, zve32x
+        vsad_vsse8 abs
+endfunc
-- 
2.43.0


[-- Attachment #3: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad
  2024-02-06 15:56 [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad flow gg
@ 2024-02-21 18:07 ` Rémi Denis-Courmont
  2024-02-22  3:04   ` flow gg
  0 siblings, 1 reply; 4+ messages in thread
From: Rémi Denis-Courmont @ 2024-02-21 18:07 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Le tiistaina 6. helmikuuta 2024, 17.56.32 EET flow gg a écrit :
> 

Did you try to compute integral absolute values with the ad-hoc (floating 
point) instruction instead of vneg/vmax? It should work since the sign is in 
the same place, though I don't know if it will be faster.

-- 
レミ・デニ-クールモン
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad
  2024-02-21 18:07 ` Rémi Denis-Courmont
@ 2024-02-22  3:04   ` flow gg
  2024-02-22 10:50     ` Rémi Denis-Courmont
  0 siblings, 1 reply; 4+ messages in thread
From: flow gg @ 2024-02-22  3:04 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

.macro vabsaddu dst src tmp
        - vneg.v          \tmp, \src
        - vmax.vv         \tmp, \src, \tmp
        + vfabs.v             \tmp, \src
        vwaddu.wv       \dst, \dst, \tmp
.endm

After making this change, the tests did not pass. I'm not quite clear on
how to understand the differences..

checkasm: 4 of 21 tests have failed
benchmarking with native FFmpeg timers
nop: 7.0
func: vsad_0, x=46 y=13 h=4, error: asm=720974 c=6162
func: vsad_1, x=16 y=14 h=10, error: asm=1146753 c=9353
func: vsad_4, x=13 y=32 h=12, error: asm=2654565 c=14573
func: vsad_5, x=32 y=1 h=8, error: asm=917745 c=3865

Rémi Denis-Courmont <remi@remlab.net> 于2024年2月22日周四 02:07写道:

> Le tiistaina 6. helmikuuta 2024, 17.56.32 EET flow gg a écrit :
> >
>
> Did you try to compute integral absolute values with the ad-hoc (floating
> point) instruction instead of vneg/vmax? It should work since the sign is
> in
> the same place, though I don't know if it will be faster.
>
> --
> レミ・デニ-クールモン
> 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".
>
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad
  2024-02-22  3:04   ` flow gg
@ 2024-02-22 10:50     ` Rémi Denis-Courmont
  0 siblings, 0 replies; 4+ messages in thread
From: Rémi Denis-Courmont @ 2024-02-22 10:50 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



Le 22 février 2024 05:04:58 GMT+02:00, flow gg <hlefthleft@gmail.com> a écrit :
>.macro vabsaddu dst src tmp
>        - vneg.v          \tmp, \src
>        - vmax.vv         \tmp, \src, \tmp
>        + vfabs.v             \tmp, \src
>        vwaddu.wv       \dst, \dst, \tmp
>.endm
>
>After making this change, the tests did not pass. I'm not quite clear on
>how to understand the differences..

Well yeah, it was a stupid idea, but I'm sad that there's no integer absolute value instruction.
_______________________________________________
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".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-22 10:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-06 15:56 [FFmpeg-devel] [PATCH 5/7] lavc/me_cmp: R-V V vsse vsad flow gg
2024-02-21 18:07 ` Rémi Denis-Courmont
2024-02-22  3:04   ` flow gg
2024-02-22 10:50     ` Rémi Denis-Courmont

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