Export (0) Print
Expand All

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

  1. Open the solution cpuid.sln.
  2. From the Build menu, click Build.
  3. 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

See Also

C Run-Time Samples

Show:
© 2014 Microsoft