diff options
author | whunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-02 01:10:02 +0000 |
---|---|---|
committer | whunt@chromium.org <whunt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-02 01:10:02 +0000 |
commit | 5016a9dde9a77b4801bf4126317ab2a271be0768 (patch) | |
tree | 25892984a39553f1609faddb620534d4094aa419 | |
parent | 5380d16e9d6e32809f1c05a6a4eac264fa3dba26 (diff) | |
download | chromium_src-5016a9dde9a77b4801bf4126317ab2a271be0768.zip chromium_src-5016a9dde9a77b4801bf4126317ab2a271be0768.tar.gz chromium_src-5016a9dde9a77b4801bf4126317ab2a271be0768.tar.bz2 |
Adds AVX detection to CPU and records a histogram of Intel Microarchitecture Support
I added detection of AVX as well. I'm not really sure the best place to put the test. It's currently run at startup time. The patch stores and Enumerated Histogram for the supported micro-architecture.
BUG=171824
NOTRY=true
Review URL: https://chromiumcodereview.appspot.com/12049058
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@180223 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/cpu.cc | 12 | ||||
-rw-r--r-- | base/cpu.h | 15 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 12 |
3 files changed, 39 insertions, 0 deletions
diff --git a/base/cpu.cc b/base/cpu.cc index cf4f2f1..d6976ba 100644 --- a/base/cpu.cc +++ b/base/cpu.cc @@ -117,6 +117,7 @@ void CPU::Initialize() { has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; has_sse41_ = (cpu_info[2] & 0x00080000) != 0; has_sse42_ = (cpu_info[2] & 0x00100000) != 0; + has_avx_ = (cpu_info[2] & 0x10000000) != 0; } // Get the brand string of the cpu. @@ -137,4 +138,15 @@ void CPU::Initialize() { #endif } +CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const { + if (has_avx()) return AVX; + if (has_sse42()) return SSE42; + if (has_sse41()) return SSE41; + if (has_ssse3()) return SSSE3; + if (has_sse3()) return SSE3; + if (has_sse2()) return SSE2; + if (has_sse()) return SSE; + return PENTIUM; +} + } // namespace base @@ -17,6 +17,18 @@ class BASE_EXPORT CPU { // Constructor CPU(); + enum IntelMicroArchitecture { + PENTIUM, + SSE, + SSE2, + SSE3, + SSSE3, + SSE41, + SSE42, + AVX, + MAX_INTEL_MICRO_ARCHITECTURE + }; + // Accessors for CPU information. const std::string& vendor_name() const { return cpu_vendor_; } int stepping() const { return stepping_; } @@ -32,6 +44,8 @@ class BASE_EXPORT CPU { bool has_ssse3() const { return has_ssse3_; } bool has_sse41() const { return has_sse41_; } bool has_sse42() const { return has_sse42_; } + bool has_avx() const { return has_avx_; } + IntelMicroArchitecture GetIntelMicroArchitecture() const; const std::string& cpu_brand() const { return cpu_brand_; } private: @@ -51,6 +65,7 @@ class BASE_EXPORT CPU { bool has_ssse3_; bool has_sse41_; bool has_sse42_; + bool has_avx_; std::string cpu_vendor_; std::string cpu_brand_; }; diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 245f860..8083563 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -14,6 +14,7 @@ #include "base/at_exit.h" #include "base/bind.h" #include "base/command_line.h" +#include "base/cpu.h" #include "base/debug/trace_event.h" #include "base/file_path.h" #include "base/file_util.h" @@ -207,6 +208,13 @@ using content::BrowserThread; namespace { +void LogIntelMicroArchitecture() { + base::CPU cpu; + base::CPU::IntelMicroArchitecture arch = cpu.GetIntelMicroArchitecture(); + UMA_HISTOGRAM_ENUMERATION("Platform.IntelMaxMicroArchitecture", arch, + base::CPU::MAX_INTEL_MICRO_ARCHITECTURE); +} + // This function provides some ways to test crash and assertion handling // behavior of the program. void HandleTestParameters(const CommandLine& command_line) { @@ -1029,6 +1037,10 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { StartMetricsRecording(); #endif +#if defined(ARCH_CPU_X86_FAMILY) + LogIntelMicroArchitecture(); +#endif // defined(ARCH_CPU_X86_FAMILY) + // Create watchdog thread after creating all other threads because it will // watch the other threads and they must be running. browser_process_->watchdog_thread(); |