Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: base/cpu.cc

Issue 12049058: Adds AVX detection to CPU and records a histogram of Intel uArch Support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing feedback Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/cpu.h" 5 #include "base/cpu.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 type_ = (cpu_info[0] >> 12) & 0x3; 110 type_ = (cpu_info[0] >> 12) & 0x3;
111 ext_model_ = (cpu_info[0] >> 16) & 0xf; 111 ext_model_ = (cpu_info[0] >> 16) & 0xf;
112 ext_family_ = (cpu_info[0] >> 20) & 0xff; 112 ext_family_ = (cpu_info[0] >> 20) & 0xff;
113 has_mmx_ = (cpu_info[3] & 0x00800000) != 0; 113 has_mmx_ = (cpu_info[3] & 0x00800000) != 0;
114 has_sse_ = (cpu_info[3] & 0x02000000) != 0; 114 has_sse_ = (cpu_info[3] & 0x02000000) != 0;
115 has_sse2_ = (cpu_info[3] & 0x04000000) != 0; 115 has_sse2_ = (cpu_info[3] & 0x04000000) != 0;
116 has_sse3_ = (cpu_info[2] & 0x00000001) != 0; 116 has_sse3_ = (cpu_info[2] & 0x00000001) != 0;
117 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0; 117 has_ssse3_ = (cpu_info[2] & 0x00000200) != 0;
118 has_sse41_ = (cpu_info[2] & 0x00080000) != 0; 118 has_sse41_ = (cpu_info[2] & 0x00080000) != 0;
119 has_sse42_ = (cpu_info[2] & 0x00100000) != 0; 119 has_sse42_ = (cpu_info[2] & 0x00100000) != 0;
120 has_avx_ = (cpu_info[2] & 0x10000000) != 0;
120 } 121 }
121 122
122 // Get the brand string of the cpu. 123 // Get the brand string of the cpu.
123 __cpuid(cpu_info, 0x80000000); 124 __cpuid(cpu_info, 0x80000000);
124 const int parameter_end = 0x80000004; 125 const int parameter_end = 0x80000004;
125 126
126 if (cpu_info[0] >= parameter_end) { 127 if (cpu_info[0] >= parameter_end) {
127 char* cpu_string_ptr = cpu_string; 128 char* cpu_string_ptr = cpu_string;
128 129
129 for (int parameter = 0x80000002; parameter <= parameter_end && 130 for (int parameter = 0x80000002; parameter <= parameter_end &&
130 cpu_string_ptr < &cpu_string[sizeof(cpu_string)]; parameter++) { 131 cpu_string_ptr < &cpu_string[sizeof(cpu_string)]; parameter++) {
131 __cpuid(cpu_info, parameter); 132 __cpuid(cpu_info, parameter);
132 memcpy(cpu_string_ptr, cpu_info, sizeof(cpu_info)); 133 memcpy(cpu_string_ptr, cpu_info, sizeof(cpu_info));
133 cpu_string_ptr += sizeof(cpu_info); 134 cpu_string_ptr += sizeof(cpu_info);
134 } 135 }
135 cpu_brand_.assign(cpu_string, cpu_string_ptr - cpu_string); 136 cpu_brand_.assign(cpu_string, cpu_string_ptr - cpu_string);
136 } 137 }
137 #endif 138 #endif
138 } 139 }
139 140
141 CPU::IntelMicroArchitecture CPU::GetIntelMicroArchitecture() const {
142 if (has_avx()) return AVX;
143 if (has_sse42()) return SSE42;
144 if (has_sse41()) return SSE41;
145 if (has_ssse3()) return SSSE3;
146 if (has_sse3()) return SSE3;
147 if (has_sse2()) return SSE2;
148 if (has_sse()) return SSE;
149 return PENTIUM;
150 }
151
140 } // namespace base 152 } // namespace base
OLDNEW
« no previous file with comments | « base/cpu.h ('k') | chrome/browser/chrome_browser_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698