Skip to content

Commit

Permalink
libavutil/cpu: Add AV_CPU_FLAG_SLOW_GATHER.
Browse files Browse the repository at this point in the history
This flag is set on Haswell and earlier and all AMD cpus.
  • Loading branch information
Alan Kelly authored and jamrial committed Dec 21, 2021
1 parent 14b6805 commit ffbab99
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
3 changes: 3 additions & 0 deletions doc/APIchanges
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ libavutil: 2021-04-27

API changes, most recent first:

2021-12-21 - xxxxxxxxxx - lavu 57.12.100 - cpu.h
Add AV_CPU_FLAG_SLOW_GATHER.

2021-12-20 - xxxxxxxxxx - lavu 57.11.101 - display.h
Modified the documentation of av_display_rotation_set()
to match its longstanding actual behaviour of treating
Expand Down
1 change: 1 addition & 0 deletions libavutil/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1
#define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2
#define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used
#define AV_CPU_FLAG_SLOW_GATHER 0x2000000 ///< CPU has slow gathers.

#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard
#define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06
Expand Down
4 changes: 2 additions & 2 deletions libavutil/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
*/

#define LIBAVUTIL_VERSION_MAJOR 57
#define LIBAVUTIL_VERSION_MINOR 11
#define LIBAVUTIL_VERSION_MICRO 101
#define LIBAVUTIL_VERSION_MINOR 12
#define LIBAVUTIL_VERSION_MICRO 100

#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
LIBAVUTIL_VERSION_MINOR, \
Expand Down
15 changes: 14 additions & 1 deletion libavutil/x86/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,21 @@ int ff_get_cpu_flags_x86(void)
if (max_std_level >= 7) {
cpuid(7, eax, ebx, ecx, edx);
#if HAVE_AVX2
if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020))
if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020)) {
rval |= AV_CPU_FLAG_AVX2;
cpuid(1, eax, ebx, ecx, std_caps);
family = ((eax >> 8) & 0xf) + ((eax >> 20) & 0xff);
model = ((eax >> 4) & 0xf) + ((eax >> 12) & 0xf0);
/* Haswell has slow gather */
if (!strncmp(vendor.c, "GenuineIntel", 12))
if (family == 6 && model < 70)
rval |= AV_CPU_FLAG_SLOW_GATHER;
/* Zen 3 and earlier have slow gather */
if (!strncmp(vendor.c, "AuthenticAMD", 12))
if (family <= 0x19)
rval |= AV_CPU_FLAG_SLOW_GATHER;
}

#if HAVE_AVX512 /* F, CD, BW, DQ, VL */
if ((xcr0_lo & 0xe0) == 0xe0) { /* OPMASK/ZMM state */
if ((rval & AV_CPU_FLAG_AVX2) && (ebx & 0xd0030000) == 0xd0030000)
Expand Down

0 comments on commit ffbab99

Please sign in to comment.