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

Side by Side Diff: base/cpu.h

Issue 1380943002: Add AVX2 detection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change test to be visual c 32 bit specific Created 5 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 | « no previous file | base/cpu.cc » ('j') | base/cpu_unittest.cc » ('J')
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 #ifndef BASE_CPU_H_ 5 #ifndef BASE_CPU_H_
6 #define BASE_CPU_H_ 6 #define BASE_CPU_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/base_export.h" 10 #include "base/base_export.h"
11 11
12 namespace base { 12 namespace base {
13 13
14 // Query information about the processor. 14 // Query information about the processor.
15 class BASE_EXPORT CPU { 15 class BASE_EXPORT CPU {
16 public: 16 public:
17 // Constructor 17 // Constructor
18 CPU(); 18 CPU();
19 19
20 enum IntelMicroArchitecture { 20 enum IntelMicroArchitecture {
21 PENTIUM, 21 PENTIUM,
22 SSE, 22 SSE,
23 SSE2, 23 SSE2,
24 SSE3, 24 SSE3,
25 SSSE3, 25 SSSE3,
26 SSE41, 26 SSE41,
27 SSE42, 27 SSE42,
28 AVX, 28 AVX,
29 AVX2,
29 MAX_INTEL_MICRO_ARCHITECTURE 30 MAX_INTEL_MICRO_ARCHITECTURE
30 }; 31 };
31 32
32 // Accessors for CPU information. 33 // Accessors for CPU information.
33 const std::string& vendor_name() const { return cpu_vendor_; } 34 const std::string& vendor_name() const { return cpu_vendor_; }
34 int signature() const { return signature_; } 35 int signature() const { return signature_; }
35 int stepping() const { return stepping_; } 36 int stepping() const { return stepping_; }
36 int model() const { return model_; } 37 int model() const { return model_; }
37 int family() const { return family_; } 38 int family() const { return family_; }
38 int type() const { return type_; } 39 int type() const { return type_; }
39 int extended_model() const { return ext_model_; } 40 int extended_model() const { return ext_model_; }
40 int extended_family() const { return ext_family_; } 41 int extended_family() const { return ext_family_; }
41 bool has_mmx() const { return has_mmx_; } 42 bool has_mmx() const { return has_mmx_; }
42 bool has_sse() const { return has_sse_; } 43 bool has_sse() const { return has_sse_; }
43 bool has_sse2() const { return has_sse2_; } 44 bool has_sse2() const { return has_sse2_; }
44 bool has_sse3() const { return has_sse3_; } 45 bool has_sse3() const { return has_sse3_; }
45 bool has_ssse3() const { return has_ssse3_; } 46 bool has_ssse3() const { return has_ssse3_; }
46 bool has_sse41() const { return has_sse41_; } 47 bool has_sse41() const { return has_sse41_; }
47 bool has_sse42() const { return has_sse42_; } 48 bool has_sse42() const { return has_sse42_; }
48 bool has_avx() const { return has_avx_; } 49 bool has_avx() const { return has_avx_; }
50 bool has_avx2() const { return has_avx2_; }
49 // has_avx_hardware returns true when AVX is present in the CPU. This might 51 // has_avx_hardware returns true when AVX is present in the CPU. This might
50 // differ from the value of |has_avx()| because |has_avx()| also tests for 52 // differ from the value of |has_avx()| because |has_avx()| also tests for
51 // operating system support needed to actually call AVX instuctions. 53 // operating system support needed to actually call AVX instuctions.
52 // Note: you should never need to call this function. It was added in order 54 // Note: you should never need to call this function. It was added in order
53 // to workaround a bug in NSS but |has_avx()| is what you want. 55 // to workaround a bug in NSS but |has_avx()| is what you want.
54 bool has_avx_hardware() const { return has_avx_hardware_; } 56 bool has_avx_hardware() const { return has_avx_hardware_; }
55 bool has_aesni() const { return has_aesni_; } 57 bool has_aesni() const { return has_aesni_; }
56 bool has_non_stop_time_stamp_counter() const { 58 bool has_non_stop_time_stamp_counter() const {
57 return has_non_stop_time_stamp_counter_; 59 return has_non_stop_time_stamp_counter_;
58 } 60 }
(...skipping 18 matching lines...) Expand all
77 int ext_family_; 79 int ext_family_;
78 bool has_mmx_; 80 bool has_mmx_;
79 bool has_sse_; 81 bool has_sse_;
80 bool has_sse2_; 82 bool has_sse2_;
81 bool has_sse3_; 83 bool has_sse3_;
82 bool has_ssse3_; 84 bool has_ssse3_;
83 bool has_sse41_; 85 bool has_sse41_;
84 bool has_sse42_; 86 bool has_sse42_;
85 bool has_avx_; 87 bool has_avx_;
86 bool has_avx_hardware_; 88 bool has_avx_hardware_;
89 bool has_avx2_;
87 bool has_aesni_; 90 bool has_aesni_;
88 bool has_non_stop_time_stamp_counter_; 91 bool has_non_stop_time_stamp_counter_;
89 bool has_broken_neon_; 92 bool has_broken_neon_;
90 std::string cpu_vendor_; 93 std::string cpu_vendor_;
91 std::string cpu_brand_; 94 std::string cpu_brand_;
92 }; 95 };
93 96
94 } // namespace base 97 } // namespace base
95 98
96 #endif // BASE_CPU_H_ 99 #endif // BASE_CPU_H_
OLDNEW
« no previous file with comments | « no previous file | base/cpu.cc » ('j') | base/cpu_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698