tango.core.tools.Cpuid

Identify the characteristics of the host CPU, providing information about cache sizes and assembly optimisation hints.

Some of this information was extremely difficult to track down. Some of the documents below were found only in cached versions stored by search engines! This code relies on information found in:

  • "Intel(R) 64 and IA-32 Architectures Software Developers Manual, Volume 2A: Instruction Set Reference, A-M" (2007).
  • "AMD CPUID Specification", Advanced Micro Devices, Rev 2.28 (2008).
  • "AMD Processor Recognition Application Note For Processors Prior to AMD Family 0Fh Processors", Advanced Micro Devices, Rev 3.13 (2005).
  • "AMD Geode(TM) GX Processors Data Book", Advanced Micro Devices, Publication ID 31505E, (2005).
  • "AMD K6 Processor Code Optimisation", Advanced Micro Devices, Rev D (2000).
  • "Application note 106: Software Customization for the 6x86 Family", Cyrix Corporation, Rev 1.5 (1998)
  • http://ftp.intron.ac/pub/document/cpu/cpuid.htm
  • "Geode(TM) GX1 Processor Series Low Power Integrated X86 Solution", National Semiconductor, (2002)
  • "The VIA Isaiah Architecture", G. Glenn Henry, Centaur Technology, Inc (2008).
  • http://www.sandpile.org/ia32/cpuid.htm
  • http://grafi.ii.pw.edu.pl/gbm/x86/cpuid.html
  • "What every programmer should know about memory", Ulrich Depper, Red Hat, Inc., (2007).
  • "CPU Identification by the Windows Kernel", G. Chappell (2009). http://www.geoffchappell.com/viewer.htm?doc=studies/windows/km/cpu/cx8.htm
  • "Intel(R) Processor Identification and the CPUID Instruction, Application Note 485" (2009).

Members

Functions

processor
const(char)[] processor()

Returns processor string, for display purposes only

vendor
const(char)[] vendor()

Returns vendor string, for display purposes only. Do NOT use this to determine features! Note that some CPUs have programmable vendorIDs.

Properties

amd3dnow
bool amd3dnow [@property getter]

Is AMD 3DNOW supported?

amd3dnowExt
bool amd3dnowExt [@property getter]

Is AMD 3DNOW Ext supported?

amdMmx
bool amdMmx [@property getter]

Are AMD extensions to MMX supported?

coresPerCPU
uint coresPerCPU [@property getter]

Returns number of cores in CPU

has3dnowPrefetch
bool has3dnowPrefetch [@property getter]

Is 3DNow prefetch supported?

hasCmov
bool hasCmov [@property getter]

Is cmov supported?

hasCmpxchg16b
bool hasCmpxchg16b [@property getter]

Is cmpxchg8b supported?

hasCmpxchg8b
bool hasCmpxchg8b [@property getter]

Is cmpxchg8b supported?

hasFxsr
bool hasFxsr [@property getter]

Is fxsave/fxrstor supported?

hasLahfSahf
bool hasLahfSahf [@property getter]

Are LAHF and SAHF supported in 64-bit mode?

hasLzcnt
bool hasLzcnt [@property getter]

Is LZCNT supported?

hasPopcnt
bool hasPopcnt [@property getter]

Is POPCNT supported?

hasRdtsc
bool hasRdtsc [@property getter]

Is rdtsc supported?

hasSysEnterSysExit
bool hasSysEnterSysExit [@property getter]

Is SYSENTER/SYSEXIT supported?

hyperThreading
bool hyperThreading [@property getter]

Is hyperthreading supported?

isItanium
bool isItanium [@property getter]

Is this an IA64 (Itanium) processor?

isX86_64
bool isX86_64 [@property getter]

Is this an Intel64 or AMD 64?

mmx
bool mmx [@property getter]

Is MMX supported?

preferAthlon
bool preferAthlon [@property getter]

Optimisation hints for assembly code. For forward compatibility, the CPU is compared against different microarchitectures. For 32-bit X86, comparisons are made against the Intel PPro/PII/PIII/PM family.

preferPentium1
bool preferPentium1 [@property getter]

Does this CPU perform better on Pentium I code than Pentium Pro code?

preferPentium4
bool preferPentium4 [@property getter]

Does this CPU perform better on Pentium4 code than PentiumPro..Core2 code?

sse
bool sse [@property getter]

Is SSE supported?

sse2
bool sse2 [@property getter]

Is SSE2 supported?

sse3
bool sse3 [@property getter]

Is SSE3 supported?

sse41
bool sse41 [@property getter]

Is SSE4.1 supported?

sse42
bool sse42 [@property getter]

Is SSE4.2 supported?

sse4a
bool sse4a [@property getter]

Is SSE4a supported?

ssse3
bool ssse3 [@property getter]

Is SSSE3 supported?

threadsPerCPU
uint threadsPerCPU [@property getter]

Returns number of threads per CPU

x87onChip
bool x87onChip [@property getter]

Does it have an x87 FPU on-chip?

Structs

CacheInfo
struct CacheInfo

Cache size and behaviour.

Variables

datacache
CacheInfo[5] datacache;

The data caches. If there are fewer than 5 physical caches levels, the remaining levels are set to uint.max (== entire memory space)

family
uint family;
model
uint model;

Processor type (vendor-dependent). This should be visible ONLY for display purposes.

numCacheLevels
uint numCacheLevels;
Undocumented in source.
stepping
uint stepping;

Processor type (vendor-dependent). This should be visible ONLY for display purposes.

Bugs

Currently only works on x86 CPUs. Many processors have bugs in their microcode for the CPUID instruction, so sometimes the cache information may be incorrect.

Meta

Authors

Don Clugston, Tomas Lindquist Olsen $(EMAIL tomas@famolsen.dk)