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-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to