|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
CPUID Sample: Determines CPU Capabilities
The CPUID sample provides a routine that uses the CPUID instruction to determine the capabilities of the CPU being run.
The sample provides the function
int _cpuid(_p_info *pinfo), which returns data about the CPU. The
int return value is a bitmask of flags for major processor features. The bits that might be set are:
#define _CPU_FEATURE_MMX 0x0001
#define _CPU_FEATURE_SSE 0x0002
#define _CPU_FEATURE_SSE2 0x0004
#define _CPU_FEATURE_3DNOW 0x0008
Building and Running the Sample
To build and run this sample
- Open the solution cpuid.sln.
- From the Build menu, click Build.
- From the Debug menu, select Start Without Debugging.
Example Program Output
The sample includes a test.cpp file that trivially calls
_cpuid and outputs the values in the resulting
_p_info struct. For example, on a Pentium III computer that supports MMX and SSE, the program output would look something like this:
C:\work\cpuid>test v_name: GenuineIntel model: INTEL Pentium-III family: 6 model: 8 stepping: 3 feature: 00000003 yes _CPU_FEATURE_MMX yes _CPU_FEATURE_SSE no _CPU_FEATURE_SSE2 no _CPU_FEATURE_3DNOW os_support: 00000003 yes _CPU_FEATURE_MMX yes _CPU_FEATURE_SSE no _CPU_FEATURE_SSE2 no _CPU_FEATURE_3DNOW checks: 0000000f