 |
Changeset 3999
- Timestamp:
- 10/10/08 04:27:31
(1 month ago)
- Author:
- Don Clugston
- Message:
Extended the list of features.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3995 |
r3999 |
|
| 83 | 83 | char[] vendor() {return vendorID;} |
|---|
| 84 | 84 | /// Returns processor string, for display purposes only |
|---|
| 85 | | char[] processor() {return processorName;} |
|---|
| | 85 | char[] processor() {return processorName;} |
|---|
| 86 | 86 | |
|---|
| 87 | 87 | /// The data caches. If there are fewer than 5 physical caches levels, |
|---|
| 88 | 88 | /// the remaining levels are set to uint.max (== entire memory space) |
|---|
| 89 | 89 | CacheInfo[5] datacache; |
|---|
| 90 | | /// Does it have an x87 FPU? |
|---|
| 91 | | bool x87() {return (features&FPU_BIT)!=0;} |
|---|
| | 90 | /// Does it have an x87 FPU on-chip? |
|---|
| | 91 | bool x87onChip() {return (features&FPU_BIT)!=0;} |
|---|
| 92 | 92 | /// Is MMX supported? |
|---|
| 93 | 93 | bool mmx() {return (features&MMX_BIT)!=0;} |
|---|
| … | … | |
| 154 | 154 | /// (1) Intel P6 (PentiumPro, PII, PIII, PM, Core, Core2). |
|---|
| 155 | 155 | /// (2) AMD Athlon (K7, K8, K10). |
|---|
| 156 | | /// (3) Intel NetBurst (Pentium 4, PentiumD). |
|---|
| 157 | | /// (4) In-order (Pentium1, PMMX, Atom) |
|---|
| 158 | | /// (5) Other cores, mostly in-order (Nx586, AMD K5, K6, Centaur C3, |
|---|
| 159 | | /// Cyrix, Transmeta, etc) |
|---|
| | 156 | /// (3) Intel NetBurst (Pentium 4, Pentium D). |
|---|
| | 157 | /// (4) In-order Pentium (Pentium1, PMMX) |
|---|
| | 158 | /// Other early CPUs (Nx586, AMD K5, K6, Centaur C3, Transmeta, |
|---|
| | 159 | /// Cyrix, Rise) were mostly in-order. |
|---|
| | 160 | /// Intel Atom and Centaur Isaiah are recent CPUs which do not fit |
|---|
| | 161 | /// into existing categories. |
|---|
| 160 | 162 | /// |
|---|
| 161 | 163 | /// Within each dynasty, the optimisation techniques are largely |
|---|
| … | … | |
| 171 | 173 | |
|---|
| 172 | 174 | private: |
|---|
| | 175 | public: |
|---|
| | 176 | /// Processor type (vendor-dependent). |
|---|
| | 177 | /// This should be visible ONLY for display purposes. |
|---|
| | 178 | uint stepping, model, family; |
|---|
| | 179 | uint numCacheLevels = 1; |
|---|
| | 180 | private: |
|---|
| 173 | 181 | bool probablyIntel; // true = _probably_ an Intel processor, might be faking |
|---|
| 174 | 182 | bool probablyAMD; // true = _probably_ an AMD processor |
|---|
| 175 | | /// Processor type (vendor-dependent). |
|---|
| 176 | | /// This should be visible ONLY for display purposes. |
|---|
| 177 | | uint stepping, model, family; |
|---|
| 178 | 183 | char [12] vendorID; |
|---|
| 179 | 184 | char [] processorName; |
|---|
| 180 | 185 | char [48] processorNameBuffer; |
|---|
| 181 | | uint numCacheLevels = 1; |
|---|
| 182 | 186 | uint features = 0; // mmx, sse, sse2, hyperthreading, etc |
|---|
| 183 | | uint miscfeatures = 0; // popcnt, sse3, etc. |
|---|
| 184 | | uint amdfeatures = 0; // 3dnow!, mmxext, etc |
|---|
| | 187 | uint miscfeatures = 0; // sse3, etc. |
|---|
| | 188 | uint amdfeatures = 0; // 3DNow!, mmxext, etc |
|---|
| 185 | 189 | uint amdmiscfeatures = 0; // sse4a, sse5, svm, etc |
|---|
| 186 | 190 | uint maxCores = 1; |
|---|
| … | … | |
| 189 | 193 | bool hyperThreadingBit() { return (features&HTT_BIT)!=0;} |
|---|
| 190 | 194 | |
|---|
| 191 | | // feature flags |
|---|
| | 195 | // feature flags CPUID1_EDX |
|---|
| 192 | 196 | enum : uint |
|---|
| 193 | 197 | { |
|---|
| … | … | |
| 204 | 208 | IA64_BIT = 1<<30 |
|---|
| 205 | 209 | } |
|---|
| 206 | | // feature flags misc |
|---|
| | 210 | // feature flags misc CPUID1_ECX |
|---|
| 207 | 211 | enum : uint |
|---|
| 208 | 212 | { |
|---|
| 209 | 213 | SSE3_BIT = 1, |
|---|
| | 214 | PCLMULQDQ_BIT = 1<<1, // from AVX |
|---|
| 210 | 215 | MWAIT_BIT = 1<<3, |
|---|
| 211 | 216 | SSSE3_BIT = 1<<9, |
|---|
| | 217 | FMA_BIT = 1<<12, // from AVX |
|---|
| 212 | 218 | CMPXCHG16B_BIT = 1<<13, |
|---|
| 213 | 219 | SSE41_BIT = 1<<19, |
|---|
| 214 | 220 | SSE42_BIT = 1<<20, |
|---|
| 215 | | POPCNT_BIT = 1<<23 |
|---|
| | 221 | POPCNT_BIT = 1<<23, |
|---|
| | 222 | AES_BIT = 1<<25, // AES instructions from AVX |
|---|
| | 223 | OSXSAVE_BIT = 1<<27, // Used for AVX |
|---|
| | 224 | AVX_BIT = 1<<28 |
|---|
| 216 | 225 | } |
|---|
| 217 | 226 | /+ |
|---|
| 218 | 227 | // Does it have Cyrix MMX extensions? (This works, but who cares?) |
|---|
| 219 | | bool has6x86MMX() {return ((features&FXSR_BIT)==0) && ((amdfeatures&FXR_OR_CYRIXMMX_BIT)!=0);} |
|---|
| | 228 | bool has6x86MMX() {return ((features&FXSR_BIT)==0) |
|---|
| | 229 | && ((amdfeatures&FXR_OR_CYRIXMMX_BIT)!=0);} |
|---|
| | 230 | version(X86_64) { |
|---|
| | 231 | bool hasAVXinHardware() { |
|---|
| | 232 | // This only indicates hardware support, not OS support. |
|---|
| | 233 | return (miscfeatures&AVX_BIT) && (miscfeatures&OSXSAVE_BIT); |
|---|
| | 234 | } |
|---|
| | 235 | // Is AVX supported (in both hardware & OS)? |
|---|
| | 236 | bool Avx() { |
|---|
| | 237 | if (!hasAVXinHardware()) return false; |
|---|
| | 238 | // Check for OS support |
|---|
| | 239 | uint xfeatures; |
|---|
| | 240 | asm {mov ECX, 0; xgetbv; mov xfeatures, EAX; } |
|---|
| | 241 | return (xfeatures&0x6)==6; |
|---|
| | 242 | } |
|---|
| | 243 | bool hasAvxFma() { |
|---|
| | 244 | if (!AVX()) return false; |
|---|
| | 245 | return (features&FMA_BIT)!=0; |
|---|
| | 246 | } |
|---|
| | 247 | } |
|---|
| 220 | 248 | +/ |
|---|
| 221 | 249 | // AMD feature flags |
|---|
| … | … | |
| 288 | 316 | datacache[level].size=sizes[i]; |
|---|
| 289 | 317 | datacache[level].associativity=ways[i]; |
|---|
| 290 | | if (level ==3 || x==0x2C || (x>=0x48 && x<=0x80) || x==0x86 || x==0x87 |
|---|
| | 318 | if (level == 3 || x==0x2C || (x>=0x48 && x<=0x80) |
|---|
| | 319 | || x==0x86 || x==0x87 |
|---|
| 291 | 320 | || (x>=0x66 && x<=0x68) || (x>=0x39 && x<=0x3E) ){ |
|---|
| 292 | 321 | datacache[level].lineSize = 64; |
|---|
Download in other formats:
|
 |