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

Side by Side Diff: source/cpu_id.cc

Issue 2418763006: Add f16c (halffloat) cpuid (Closed)
Patch Set: bump version to r1627 Created 4 years, 2 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
« no previous file with comments | « include/libyuv/version.h ('k') | source/planar_functions.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 /* 1 /*
2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 int cpu_info = 0; 222 int cpu_info = 0;
223 #if !defined(__pnacl__) && !defined(__CLR_VER) && defined(CPU_X86) 223 #if !defined(__pnacl__) && !defined(__CLR_VER) && defined(CPU_X86)
224 uint32 cpu_info0[4] = { 0, 0, 0, 0 }; 224 uint32 cpu_info0[4] = { 0, 0, 0, 0 };
225 uint32 cpu_info1[4] = { 0, 0, 0, 0 }; 225 uint32 cpu_info1[4] = { 0, 0, 0, 0 };
226 uint32 cpu_info7[4] = { 0, 0, 0, 0 }; 226 uint32 cpu_info7[4] = { 0, 0, 0, 0 };
227 CpuId(0, 0, cpu_info0); 227 CpuId(0, 0, cpu_info0);
228 CpuId(1, 0, cpu_info1); 228 CpuId(1, 0, cpu_info1);
229 if (cpu_info0[0] >= 7) { 229 if (cpu_info0[0] >= 7) {
230 CpuId(7, 0, cpu_info7); 230 CpuId(7, 0, cpu_info7);
231 } 231 }
232 cpu_info = ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) | 232 cpu_info = kCpuHasX86 |
233 ((cpu_info1[3] & 0x04000000) ? kCpuHasSSE2 : 0) |
233 ((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) | 234 ((cpu_info1[2] & 0x00000200) ? kCpuHasSSSE3 : 0) |
234 ((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) | 235 ((cpu_info1[2] & 0x00080000) ? kCpuHasSSE41 : 0) |
235 ((cpu_info1[2] & 0x00100000) ? kCpuHasSSE42 : 0) | 236 ((cpu_info1[2] & 0x00100000) ? kCpuHasSSE42 : 0) |
236 ((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0) | 237 ((cpu_info7[1] & 0x00000200) ? kCpuHasERMS : 0);
237 ((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) |
238 kCpuHasX86;
239 238
240 #ifdef HAS_XGETBV 239 #ifdef HAS_XGETBV
241 // AVX requires CPU has AVX, XSAVE and OSXSave for xgetbv 240 // AVX requires CPU has AVX, XSAVE and OSXSave for xgetbv
242 if (((cpu_info1[2] & 0x1c000000) == 0x1c000000) && // AVX and OSXSave 241 if (((cpu_info1[2] & 0x1c000000) == 0x1c000000) && // AVX and OSXSave
243 ((GetXCR0() & 6) == 6)) { // Test OS saves YMM registers 242 ((GetXCR0() & 6) == 6)) { // Test OS saves YMM registers
244 cpu_info |= ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) | kCpuHasAVX; 243 cpu_info |= kCpuHasAVX |
244 ((cpu_info7[1] & 0x00000020) ? kCpuHasAVX2 : 0) |
245 ((cpu_info1[2] & 0x00001000) ? kCpuHasFMA3 : 0) |
246 ((cpu_info1[2] & 0x20000000) ? kCpuHasF16C : 0);
245 247
246 // Detect AVX512bw 248 // Detect AVX512bw
247 if ((GetXCR0() & 0xe0) == 0xe0) { 249 if ((GetXCR0() & 0xe0) == 0xe0) {
248 cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX3 : 0; 250 cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX3 : 0;
249 } 251 }
250 } 252 }
251 #endif 253 #endif
252 254
253 // Environment variable overrides for testing. 255 // Environment variable overrides for testing.
254 if (TestEnv("LIBYUV_DISABLE_X86")) { 256 if (TestEnv("LIBYUV_DISABLE_X86")) {
(...skipping 19 matching lines...) Expand all
274 } 276 }
275 if (TestEnv("LIBYUV_DISABLE_ERMS")) { 277 if (TestEnv("LIBYUV_DISABLE_ERMS")) {
276 cpu_info &= ~kCpuHasERMS; 278 cpu_info &= ~kCpuHasERMS;
277 } 279 }
278 if (TestEnv("LIBYUV_DISABLE_FMA3")) { 280 if (TestEnv("LIBYUV_DISABLE_FMA3")) {
279 cpu_info &= ~kCpuHasFMA3; 281 cpu_info &= ~kCpuHasFMA3;
280 } 282 }
281 if (TestEnv("LIBYUV_DISABLE_AVX3")) { 283 if (TestEnv("LIBYUV_DISABLE_AVX3")) {
282 cpu_info &= ~kCpuHasAVX3; 284 cpu_info &= ~kCpuHasAVX3;
283 } 285 }
286 if (TestEnv("LIBYUV_DISABLE_F16C")) {
287 cpu_info &= ~kCpuHasF16C;
288 }
289
284 #endif 290 #endif
285 #if defined(__mips__) && defined(__linux__) 291 #if defined(__mips__) && defined(__linux__)
286 #if defined(__mips_dspr2) 292 #if defined(__mips_dspr2)
287 cpu_info |= kCpuHasDSPR2; 293 cpu_info |= kCpuHasDSPR2;
288 #endif 294 #endif
289 #if defined(__mips_msa) 295 #if defined(__mips_msa)
290 cpu_info = MipsCpuCaps("/proc/cpuinfo", " msa"); 296 cpu_info = MipsCpuCaps("/proc/cpuinfo", " msa");
291 #endif 297 #endif
292 cpu_info |= kCpuHasMIPS; 298 cpu_info |= kCpuHasMIPS;
293 if (getenv("LIBYUV_DISABLE_DSPR2")) { 299 if (getenv("LIBYUV_DISABLE_DSPR2")) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // Note that use of this function is not thread safe. 335 // Note that use of this function is not thread safe.
330 LIBYUV_API 336 LIBYUV_API
331 void MaskCpuFlags(int enable_flags) { 337 void MaskCpuFlags(int enable_flags) {
332 cpu_info_ = InitCpuFlags() & enable_flags; 338 cpu_info_ = InitCpuFlags() & enable_flags;
333 } 339 }
334 340
335 #ifdef __cplusplus 341 #ifdef __cplusplus
336 } // extern "C" 342 } // extern "C"
337 } // namespace libyuv 343 } // namespace libyuv
338 #endif 344 #endif
OLDNEW
« no previous file with comments | « include/libyuv/version.h ('k') | source/planar_functions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698