Commit ab415818 authored by fbarchard@google.com's avatar fbarchard@google.com

Change cpu id constants to hex to indicate they are flags. Reserve values for…

Change cpu id constants to hex to indicate they are flags.  Reserve values for future flags.  make unittest print in hex.  Add environment variables to disable sse42 and avx.
BUG=none
TEST=none
Review URL: https://webrtc-codereview.appspot.com/608006

git-svn-id: http://libyuv.googlecode.com/svn/trunk@272 16f28f9a-4ce2-e073-06de-1de4eb20be90
parent 4ae6b46c
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 271
Version: 272
License: BSD
License File: LICENSE
......
......@@ -17,19 +17,21 @@ extern "C" {
#endif
// Internal flag to indicate cpuid is initialized.
static const int kCpuInitialized = 1;
// These flags are only valid on ARM processors
static const int kCpuHasARM = 2;
static const int kCpuHasNEON = 4;
// These flags are only valid on x86 processors
static const int kCpuHasX86 = 8;
static const int kCpuHasSSE2 = 16;
static const int kCpuHasSSSE3 = 32;
static const int kCpuHasSSE41 = 64;
static const int kCpuHasSSE42 = 128;
static const int kCpuHasAVX = 256;
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;
// 0x400 reserved for AVX2.
// Detect CPU has SSE2 etc.
// Test_flag parameter should be one of kCpuHas constants above.
......
......@@ -11,7 +11,7 @@
#ifndef INCLUDE_LIBYUV_VERSION_H_
#define INCLUDE_LIBYUV_VERSION_H_
#define LIBYUV_VERSION 271
#define LIBYUV_VERSION 272
#endif // INCLUDE_LIBYUV_VERSION_H_
......@@ -104,6 +104,12 @@ int InitCpuFlags() {
if (getenv("LIBYUV_DISABLE_SSE41")) {
cpu_info_ &= ~kCpuHasSSE41;
}
if (getenv("LIBYUV_DISABLE_SSE42")) {
cpu_info_ &= ~kCpuHasSSE42;
}
if (getenv("LIBYUV_DISABLE_AVX")) {
cpu_info_ &= ~kCpuHasAVX;
}
if (getenv("LIBYUV_DISABLE_ASM")) {
cpu_info_ = kCpuInitialized;
}
......
......@@ -26,21 +26,21 @@ TEST_F(libyuvTest, TestCpuHas) {
int cpu_flags = TestCpuFlag(~kCpuInitialized);
printf("Cpu Flags %x\n", cpu_flags);
int has_arm = TestCpuFlag(kCpuHasARM);
printf("Has ARM %d\n", has_arm);
printf("Has ARM %x\n", has_arm);
int has_neon = TestCpuFlag(kCpuHasNEON);
printf("Has NEON %d\n", has_neon);
printf("Has NEON %x\n", has_neon);
int has_x86 = TestCpuFlag(kCpuHasX86);
printf("Has X86 %d\n", has_x86);
printf("Has X86 %x\n", has_x86);
int has_sse2 = TestCpuFlag(kCpuHasSSE2);
printf("Has SSE2 %d\n", has_sse2);
printf("Has SSE2 %x\n", has_sse2);
int has_ssse3 = TestCpuFlag(kCpuHasSSSE3);
printf("Has SSSE3 %d\n", has_ssse3);
printf("Has SSSE3 %x\n", has_ssse3);
int has_sse41 = TestCpuFlag(kCpuHasSSE41);
printf("Has SSE4.1 %d\n", has_sse41);
printf("Has SSE4.1 %x\n", has_sse41);
int has_sse42 = TestCpuFlag(kCpuHasSSE42);
printf("Has SSE4.2 %d\n", has_sse42);
printf("Has SSE4.2 %x\n", has_sse42);
int has_avx = TestCpuFlag(kCpuHasAVX);
printf("Has AVX %d\n", has_avx);
printf("Has AVX %x\n", has_avx);
}
#if defined(__i386__) || defined(__x86_64__) || \
......@@ -79,7 +79,8 @@ TEST_F(libyuvTest, TestCpuId) {
CpuId(cpu_info, 1);
int family = ((cpu_info[0] >> 8) & 0x0f) | ((cpu_info[0] >> 16) & 0xff0);
int model = ((cpu_info[0] >> 4) & 0x0f) | ((cpu_info[0] >> 12) & 0xf0);
printf("Cpu Family %d, Model %d\n", family, model);
printf("Cpu Family %d (0x%x), Model %d (0x%x)\n", family, family,
model, model);
}
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment