* [FFmpeg-devel] [PATCH] avcodec/v210enc: add new function for avx2 avx512 avx512icl
@ 2022-10-28 18:55 James Darnley
2022-10-28 23:26 ` Kieran Kunhya
2022-10-29 8:19 ` Christophe Gisquet
0 siblings, 2 replies; 4+ messages in thread
From: James Darnley @ 2022-10-28 18:55 UTC (permalink / raw)
To: ffmpeg-devel
Negligible speed difference for avx2 on Zen 2 (Ryzen 5700X) and
Broadwell (Xeon E5-2620 v4):
1690±4.3 decicycles vs. 1693±78.4
1439±31.1 decicycles vs 1429±16.7
Moderate speedup with avx512 on Skylake-X (Xeon D-2123IT):
1.22x faster (793±0.8 vs. 649±5.5 decicycles) compared with avx2
Better speedup with avx512icl on Ice Lake (Xeon Silver 4316):
1.77x faster (784±1.8 vs. 442±11.6 decicycles) compared with avx2
Co-authors:
Henrik Gramner <henrik@gramner.com>
Kieran Kunhya <kierank@obe.tv>
---
libavcodec/x86/v210enc.asm | 80 ++++++++++++++++++++++++++++++++++-
libavcodec/x86/v210enc_init.c | 14 ++++++
2 files changed, 92 insertions(+), 2 deletions(-)
diff --git a/libavcodec/x86/v210enc.asm b/libavcodec/x86/v210enc.asm
index 965f2bea3c..afac238ede 100644
--- a/libavcodec/x86/v210enc.asm
+++ b/libavcodec/x86/v210enc.asm
@@ -21,7 +21,7 @@
%include "libavutil/x86/x86util.asm"
-SECTION_RODATA 32
+SECTION_RODATA 64
cextern pw_4
%define v210_enc_min_10 pw_4
@@ -46,6 +46,16 @@ v210_enc_chroma_shuf2_8: times 2 db 3,-1,4,-1,5,-1,7,-1,11,-1,12,-1,13,-1,15,-1
v210_enc_chroma_mult_8: times 2 dw 4,16,64,0,64,4,16,0
+v210enc_8_permb: db 32, 0,48,-1 , 1,33, 2,-1 , 49, 3,34,-1 , 4,50, 5,-1
+ db 35, 6,51,-1 , 7,36, 8,-1 , 52, 9,37,-1 , 10,53,11,-1
+ db 38,12,54,-1 , 13,39,14,-1 , 55,15,40,-1 , 16,56,17,-1
+ db 41,18,57,-1 , 19,42,20,-1 , 58,21,43,-1 , 22,59,23,-1
+v210enc_8_shufb: db 0, 8, 1,-1 , 9, 2,10,-1 , 3,11, 4,-1 , 12, 5,13,-1
+ db 2,10, 3,-1 , 11, 4,12,-1 , 5,13, 6,-1 , 14, 7,15,-1
+v210enc_8_permd: dd 0,1,4,5, 1,2,5,6
+v210enc_8_mult: db 4, 0, 64, 0
+v210enc_8_mask: dd 255<<12
+
SECTION .text
%macro v210_planar_pack_10 0
@@ -178,7 +188,73 @@ INIT_XMM avx
v210_planar_pack_8
%endif
+%macro v210_planar_pack_8_new 0
+
+cglobal v210_planar_pack_8, 5, 5, 7+notcpuflag(avx512icl), y, u, v, dst, width
+ add yq, widthq
+ shr widthq, 1
+ add uq, widthq
+ add vq, widthq
+ neg widthq
+
+ %if cpuflag(avx512icl)
+ mova m2, [v210enc_8_permb]
+ %else
+ mova m2, [v210enc_8_permd]
+ %endif
+ vpbroadcastd m3, [v210enc_8_mult]
+ VBROADCASTI128 m4, [v210_enc_min_8] ; only ymm sized
+ VBROADCASTI128 m5, [v210_enc_max_8] ; only ymm sized
+ vpbroadcastd m6, [v210enc_8_mask]
+ %if notcpuflag(avx512icl)
+ movu m7, [v210enc_8_shufb]
+ %endif
+
+ .loop:
+ %if cpuflag(avx512icl)
+ movu ym1, [yq + 2*widthq]
+ vinserti32x4 m1, [uq + 1*widthq], 2
+ vinserti32x4 m1, [vq + 1*widthq], 3
+ vpermb m1, m2, m1 ; uyv0 yuy0 vyu0 yvy0
+ %else
+ movq xm0, [uq + 1*widthq] ; uuuu uuxx
+ movq xm1, [vq + 1*widthq] ; vvvv vvxx
+ punpcklbw xm1, xm0, xm1 ; uvuv uvuv uvuv xxxx
+ vinserti128 m1, m1, [yq + 2*widthq], 1 ; uvuv uvuv uvuv xxxx yyyy yyyy yyyy xxxx
+ vpermd m1, m2, m1 ; uvuv uvxx yyyy yyxx xxuv uvuv xxyy yyyy
+ pshufb m1, m7 ; uyv0 yuy0 vyu0 yvy0
+ %endif
+ CLIPUB m1, m4, m5
+
+ pmaddubsw m0, m1, m3
+ pslld m1, 4
+ %if cpuflag(avx512)
+ vpternlogd m0, m1, m6, 0xd8 ; C?B:A
+ %else
+ pand m1, m6, m1
+ pandn m0, m6, m0
+ por m0, m0, m1
+ %endif
+
+ movu [dstq], m0
+ add dstq, mmsize
+ add widthq, (mmsize*3)/16
+ jl .loop
+RET
+
+%endmacro
+
%if HAVE_AVX2_EXTERNAL
INIT_YMM avx2
-v210_planar_pack_8
+v210_planar_pack_8_new
+%endif
+
+%if HAVE_AVX512_EXTERNAL
+INIT_YMM avx512
+v210_planar_pack_8_new
+%endif
+
+%if HAVE_AVX512ICL_EXTERNAL
+INIT_ZMM avx512icl
+v210_planar_pack_8_new
%endif
diff --git a/libavcodec/x86/v210enc_init.c b/libavcodec/x86/v210enc_init.c
index 13a351dd1d..6e9f8c6e61 100644
--- a/libavcodec/x86/v210enc_init.c
+++ b/libavcodec/x86/v210enc_init.c
@@ -27,6 +27,10 @@ void ff_v210_planar_pack_8_avx(const uint8_t *y, const uint8_t *u,
const uint8_t *v, uint8_t *dst, ptrdiff_t width);
void ff_v210_planar_pack_8_avx2(const uint8_t *y, const uint8_t *u,
const uint8_t *v, uint8_t *dst, ptrdiff_t width);
+void ff_v210_planar_pack_8_avx512(const uint8_t *y, const uint8_t *u,
+ const uint8_t *v, uint8_t *dst, ptrdiff_t width);
+void ff_v210_planar_pack_8_avx512icl(const uint8_t *y, const uint8_t *u,
+ const uint8_t *v, uint8_t *dst, ptrdiff_t width);
void ff_v210_planar_pack_10_ssse3(const uint16_t *y, const uint16_t *u,
const uint16_t *v, uint8_t *dst,
ptrdiff_t width);
@@ -52,4 +56,14 @@ av_cold void ff_v210enc_init_x86(V210EncContext *s)
s->sample_factor_10 = 2;
s->pack_line_10 = ff_v210_planar_pack_10_avx2;
}
+
+ if (EXTERNAL_AVX512(cpu_flags)) {
+ s->sample_factor_8 = 2;
+ s->pack_line_8 = ff_v210_planar_pack_8_avx512;
+ }
+
+ if (EXTERNAL_AVX512ICL(cpu_flags)) {
+ s->sample_factor_8 = 4;
+ s->pack_line_8 = ff_v210_planar_pack_8_avx512icl;
+ }
}
--
2.38.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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] avcodec/v210enc: add new function for avx2 avx512 avx512icl
2022-10-28 18:55 [FFmpeg-devel] [PATCH] avcodec/v210enc: add new function for avx2 avx512 avx512icl James Darnley
@ 2022-10-28 23:26 ` Kieran Kunhya
2022-10-29 8:19 ` Christophe Gisquet
1 sibling, 0 replies; 4+ messages in thread
From: Kieran Kunhya @ 2022-10-28 23:26 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, 28 Oct 2022 at 19:57, James Darnley <jdarnley@obe.tv> wrote:
> Negligible speed difference for avx2 on Zen 2 (Ryzen 5700X) and
> Broadwell (Xeon E5-2620 v4):
> 1690±4.3 decicycles vs. 1693±78.4
> 1439±31.1 decicycles vs 1429±16.7
>
Just to avoid confusion for anyone who decides to review this over the
weekend, Broadwell is in fact ~10% faster, these numbers look like a
mistake.
Kieran
_______________________________________________
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] avcodec/v210enc: add new function for avx2 avx512 avx512icl
2022-10-28 18:55 [FFmpeg-devel] [PATCH] avcodec/v210enc: add new function for avx2 avx512 avx512icl James Darnley
2022-10-28 23:26 ` Kieran Kunhya
@ 2022-10-29 8:19 ` Christophe Gisquet
2022-10-31 12:52 ` James Darnley
1 sibling, 1 reply; 4+ messages in thread
From: Christophe Gisquet @ 2022-10-29 8:19 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Hello,
Le ven. 28 oct. 2022 à 20:57, James Darnley <jdarnley@obe.tv> a écrit :
> + %else
> + pand m1, m6, m1
> + pandn m0, m6, m0
> + por m0, m0, m1
> + %endif
Isn't that pattern a vpblendb or some such ?
--
Christophe
_______________________________________________
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] avcodec/v210enc: add new function for avx2 avx512 avx512icl
2022-10-29 8:19 ` Christophe Gisquet
@ 2022-10-31 12:52 ` James Darnley
0 siblings, 0 replies; 4+ messages in thread
From: James Darnley @ 2022-10-31 12:52 UTC (permalink / raw)
To: ffmpeg-devel
>> + %else
>> + pand m1, m6, m1
>> + pandn m0, m6, m0
>> + por m0, m0, m1
>> + %endif
>
> Isn't that pattern a vpblendb or some such ?
I think Kieran already responded to this on IRC but I will too.
Unfortunately not. This blend is at the bit level. This is v210 so the
packing has the middle sample overlapping with the bottom sample in the
second byte.
I also want to amend my performance numbers on Broadwell. I can confirm
Kieran's disagreement and can reproduce the 10% speed up on it:
1676±14.6 vs 1426±20.9
I will re-check Zen and amend the commit message as necessary.
_______________________________________________
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:[~2022-10-31 12:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-28 18:55 [FFmpeg-devel] [PATCH] avcodec/v210enc: add new function for avx2 avx512 avx512icl James Darnley
2022-10-28 23:26 ` Kieran Kunhya
2022-10-29 8:19 ` Christophe Gisquet
2022-10-31 12:52 ` James Darnley
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