From a6a2ec654b1be1166b376476a7555c89eca0c275 Mon Sep 17 00:00:00 2001 From: Frank Barchard Date: Mon, 12 Feb 2024 11:11:06 -0800 Subject: [PATCH] Add AMXINT8 cpu detect sde -spr -- libyuv_test -- --gunit_filter=*Cpu* Note: Google Test filter = *Cpu* [==========] Running 4 tests from 2 test suites. [----------] Global test environment set-up. [----------] 3 tests from LibYUVBaseTest [ RUN ] LibYUVBaseTest.TestCpuHas Cpu Flags 0x57fff9 Has X86 0x8 Has SSE2 0x10 Has SSSE3 0x20 Has SSE41 0x40 Has SSE42 0x80 Has AVX 0x100 Has AVX2 0x200 Has ERMS 0x400 Has FMA3 0x800 Has F16C 0x1000 Has AVX512BW 0x2000 Has AVX512VL 0x4000 Has AVX512VNNI 0x8000 Has AVX512VBMI 0x10000 Has AVX512VBMI2 0x20000 Has AVX512VBITALG 0x40000 Has AVX10 0x0 HAS AVXVNNI 0x100000 Has AVXVNNIINT8 0x0 Has AMXINT8 0x400000 [ OK ] LibYUVBaseTest.TestCpuHas (34 ms) Bug: b/324356616 Change-Id: I5129b8946363a501bdd570e6dba3936c54aacd6c Reviewed-on: https://chromium-review.googlesource.com/c/libyuv/libyuv/+/5283433 Reviewed-by: richard winterton Commit-Queue: Frank Barchard --- README.chromium | 2 +- docs/environment_variables.md | 6 ++++-- include/libyuv/cpu_id.h | 40 +++++++++++++++++------------------ include/libyuv/version.h | 2 +- source/cpu_id.cc | 1 + source/mjpeg_decoder.cc | 3 +-- unit_test/cpu_test.cc | 2 ++ unit_test/unit_test.cc | 3 +++ util/cpuid.c | 2 ++ 9 files changed, 35 insertions(+), 26 deletions(-) diff --git a/README.chromium b/README.chromium index 42817b4d7..6d13097db 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: https://chromium.googlesource.com/libyuv/libyuv/ -Version: 1886 +Version: 1887 License: BSD License File: LICENSE Shipped: yes diff --git a/docs/environment_variables.md b/docs/environment_variables.md index 4eb096595..248cc082b 100644 --- a/docs/environment_variables.md +++ b/docs/environment_variables.md @@ -26,8 +26,10 @@ By default the cpu is detected and the most advanced form of SIMD is used. But LIBYUV_DISABLE_AVX512VBMI LIBYUV_DISABLE_AVX512VBMI2 LIBYUV_DISABLE_AVX512VBITALG - LIBYUV_DISABLE_AVX512VPOPCNTDQ - LIBYUV_DISABLE_GFNI + LIBYUV_DISABLE_AVX10 + LIBYUV_DISABLE_AVXVNNI + LIBYUV_DISABLE_AVXVNNIINT8 + LIBYUV_DISABLE_AMXINT8 ## ARM CPUs diff --git a/include/libyuv/cpu_id.h b/include/libyuv/cpu_id.h index 5a81e7c9d..7a1f1c25b 100644 --- a/include/libyuv/cpu_id.h +++ b/include/libyuv/cpu_id.h @@ -24,28 +24,28 @@ static const int kCpuInitialized = 0x1; // These flags are only valid on ARM processors. static const int kCpuHasARM = 0x2; static const int kCpuHasNEON = 0x4; -// 0x8 reserved for future ARM flag. // These flags are only valid on x86 processors. -static const int kCpuHasX86 = 0x10; -static const int kCpuHasSSE2 = 0x20; -static const int kCpuHasSSSE3 = 0x40; -static const int kCpuHasSSE41 = 0x80; -static const int kCpuHasSSE42 = 0x100; -static const int kCpuHasAVX = 0x200; -static const int kCpuHasAVX2 = 0x400; -static const int kCpuHasERMS = 0x800; -static const int kCpuHasFMA3 = 0x1000; -static const int kCpuHasF16C = 0x2000; -static const int kCpuHasAVX512BW = 0x4000; -static const int kCpuHasAVX512VL = 0x8000; -static const int kCpuHasAVX512VNNI = 0x10000; -static const int kCpuHasAVX512VBMI = 0x20000; -static const int kCpuHasAVX512VBMI2 = 0x40000; -static const int kCpuHasAVX512VBITALG = 0x80000; -static const int kCpuHasAVX10 = 0x100000; -static const int kCpuHasAVXVNNI = 0x200000; -static const int kCpuHasAVXVNNIINT8 = 0x400000; +static const int kCpuHasX86 = 0x8; +static const int kCpuHasSSE2 = 0x10; +static const int kCpuHasSSSE3 = 0x20; +static const int kCpuHasSSE41 = 0x40; +static const int kCpuHasSSE42 = 0x80; +static const int kCpuHasAVX = 0x100; +static const int kCpuHasAVX2 = 0x200; +static const int kCpuHasERMS = 0x400; +static const int kCpuHasFMA3 = 0x800; +static const int kCpuHasF16C = 0x1000; +static const int kCpuHasAVX512BW = 0x2000; +static const int kCpuHasAVX512VL = 0x4000; +static const int kCpuHasAVX512VNNI = 0x8000; +static const int kCpuHasAVX512VBMI = 0x10000; +static const int kCpuHasAVX512VBMI2 = 0x20000; +static const int kCpuHasAVX512VBITALG = 0x40000; +static const int kCpuHasAVX10 = 0x80000; +static const int kCpuHasAVXVNNI = 0x100000; +static const int kCpuHasAVXVNNIINT8 = 0x200000; +static const int kCpuHasAMXINT8 = 0x400000; // These flags are only valid on MIPS processors. static const int kCpuHasMIPS = 0x800000; diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 1d4a0f919..30e6d1255 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 1886 +#define LIBYUV_VERSION 1887 #endif // INCLUDE_LIBYUV_VERSION_H_ diff --git a/source/cpu_id.cc b/source/cpu_id.cc index eedce16b4..ad4246f55 100644 --- a/source/cpu_id.cc +++ b/source/cpu_id.cc @@ -323,6 +323,7 @@ static SAFEBUFFERS int GetCpuFlags(void) { cpu_info |= (cpu_info7[2] & 0x00000800) ? kCpuHasAVX512VNNI : 0; cpu_info |= (cpu_info7[2] & 0x00001000) ? kCpuHasAVX512VBITALG : 0; cpu_info |= (cpu_einfo7[3] & 0x00080000) ? kCpuHasAVX10 : 0; + cpu_info |= (cpu_info7[3] & 0x02000000) ? kCpuHasAMXINT8 : 0; } } #endif diff --git a/source/mjpeg_decoder.cc b/source/mjpeg_decoder.cc index 238456f6e..b93a8499e 100644 --- a/source/mjpeg_decoder.cc +++ b/source/mjpeg_decoder.cc @@ -13,8 +13,7 @@ #ifdef HAVE_JPEG #include -#if !defined(__pnacl__) && !defined(__CLR_VER) && \ - !defined(COVERAGE_ENABLED) +#if !defined(__pnacl__) && !defined(__CLR_VER) && !defined(COVERAGE_ENABLED) // Must be included before jpeglib. #include #define HAVE_SETJMP diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc index 437b66324..6e0fdef1b 100644 --- a/unit_test/cpu_test.cc +++ b/unit_test/cpu_test.cc @@ -56,6 +56,7 @@ TEST_F(LibYUVBaseTest, TestCpuHas) { int has_avx10 = TestCpuFlag(kCpuHasAVX10); int has_avxvnni = TestCpuFlag(kCpuHasAVXVNNI); int has_avxvnniint8 = TestCpuFlag(kCpuHasAVXVNNIINT8); + int has_amxint8 = TestCpuFlag(kCpuHasAMXINT8); printf("Has X86 0x%x\n", has_x86); printf("Has SSE2 0x%x\n", has_sse2); printf("Has SSSE3 0x%x\n", has_ssse3); @@ -75,6 +76,7 @@ TEST_F(LibYUVBaseTest, TestCpuHas) { printf("Has AVX10 0x%x\n", has_avx10); printf("HAS AVXVNNI 0x%x\n", has_avxvnni); printf("Has AVXVNNIINT8 0x%x\n", has_avxvnniint8); + printf("Has AMXINT8 0x%x\n", has_amxint8); #endif #if defined(__mips__) int has_mips = TestCpuFlag(kCpuHasMIPS); diff --git a/unit_test/unit_test.cc b/unit_test/unit_test.cc index 239d5b920..c351d5e25 100644 --- a/unit_test/unit_test.cc +++ b/unit_test/unit_test.cc @@ -153,6 +153,9 @@ int TestCpuEnv(int cpu_info) { if (TestEnv("LIBYUV_DISABLE_AVXVNNIINT8")) { cpu_info &= ~libyuv::kCpuHasAVXVNNIINT8; } + if (TestEnv("LIBYUV_DISABLE_AMXINT8")) { + cpu_info &= ~libyuv::kCpuHasAMXINT8; + } #endif if (TestEnv("LIBYUV_DISABLE_ASM")) { cpu_info = libyuv::kCpuInitialized; diff --git a/util/cpuid.c b/util/cpuid.c index fa19fab9a..b0b85f532 100644 --- a/util/cpuid.c +++ b/util/cpuid.c @@ -134,6 +134,7 @@ int main(int argc, const char* argv[]) { int has_avx10 = TestCpuFlag(kCpuHasAVX10); int has_avxvnni = TestCpuFlag(kCpuHasAVXVNNI); int has_avxvnniint8 = TestCpuFlag(kCpuHasAVXVNNIINT8); + int has_amxint8 = TestCpuFlag(kCpuHasAMXINT8); printf("Has X86 0x%x\n", has_x86); printf("Has SSE2 0x%x\n", has_sse2); printf("Has SSSE3 0x%x\n", has_ssse3); @@ -153,6 +154,7 @@ int main(int argc, const char* argv[]) { printf("Has AVX10 0x%x\n", has_avx10); printf("HAS AVXVNNI 0x%x\n", has_avxvnni); printf("Has AVXVNNIINT8 0x%x\n", has_avxvnniint8); + printf("Has AMXINT8 0x%x\n", has_amxint8); } return 0; }