Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] Discrepancy between comments for AVX512 flags
@ 2022-08-26 22:01 James Darnley
  2022-08-27  0:14 ` Hendrik Leppkes
  0 siblings, 1 reply; 3+ messages in thread
From: James Darnley @ 2022-08-26 22:01 UTC (permalink / raw)
  To: ffmpeg-devel

While cherry-picking some stuff for avx512 I have noticed that ffmpeg 
has a discrepancy in the comments for the two avx512 flags.

Lets start with the public header
> libavutil/cpu.h
>   56│ #define AV_CPU_FLAG_AVX512     0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used
>   57│ #define AV_CPU_FLAG_AVX512ICL  0x200000 ///< F/CD/BW/DQ/VL/VNNI/IFMA/VBMI/VBMI2/VPOPCNTDQ/BITALG/GFNI/VAES/VPCLMULQDQ

This seem to imply the first only detects ZMM support and the second 
groups all instruction sets together.  This appears to be different to 
what we imply in internal code
> libavutil/x86/cpu.c
>  151│ #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
> libavutil/x86/x86inc.asm
>  840│ %assign cpuflags_avx512    (1<<20)| cpuflags_avx2 ; F, CD, BW, DQ, VL     

The detection code itself has
> libavutil/x86/cpu.c
>  151│ #if HAVE_AVX512 /* F, CD, BW, DQ, VL */
>  152│         if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
>  153│             if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000) {
>  154│                 rval |= AV_CPU_FLAG_AVX512;
>  155│ #if HAVE_AVX512ICL
>  156│                 if ((ebx & 0xd0200000) == 0xd0200000 && (ecx & 0x5f42) == 0x5f42)
>  157│                     rval |= AV_CPU_FLAG_AVX512ICL;

If you decode the bits being checked you'll see that the base avx512 
checks ebx for F DQ CD BW VL and avx512icl checks ebx for IFMA CD BW VL 
and ecx for VBMI VBMI2 GFNI VAES VPCLMULQDQ VNNI BITALG VPOPCNTDQ.  The 
first matches what the internal comments imply.

Part of the difference is my fault and dates from when the flag was 
first added.

Has there been a discussion about which features should go with which flag?
_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2022-08-27 12:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-26 22:01 [FFmpeg-devel] Discrepancy between comments for AVX512 flags James Darnley
2022-08-27  0:14 ` Hendrik Leppkes
2022-08-27 12:15   ` Henrik Gramner

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