CPUID signature

CPUID signature

zhangxiuxia's picture

Intel 64 and IA-32 Architectures Optimization Reference Manual
Order Number: 248966-024
April 2011


it said using cpuid can catch cpuid signature

set eax=1
the cpuid
the low 12bit of eax is cpu signature

main ()
int low12bit;
int ebx, ecx, edx, eax;
ecx = 0;
edx = 0;
ebx = 0;
eax = 1;
__asm__ ("cpuid": "=b" (ebx), "=c" (ecx), "=d" (edx), "=a" (eax):"a" (eax));

low12bit = eax & 0x0FFF;
printf ("%x %x %x %x \\n", eax, ebx, ecx, edx);
printf ("%x\\n", low12bit);
printf("model %x \\n",44);
return 0;

But I can not get the same value as waht the manual said .
On sandyBirdge , I get 06a7 , but on the manual , the sandybirge is 062a
On Nehalem , I get 06A5(E5530) , 06C2 (X5650), not the same as manual

When I read the manual carefully , I find that
The column represented by 0xF3n also applies to
Intel processors with CPUID signature 0xF4n and 0xF6n. The notation 0xF2n represents
the hex value of the lower 12 bits of the EAX register reported by CPUID
instruction with input value of EAX = 1; F indicates the family encoding value is 15,
2 indicates the model encoding is 2, n indicates it applies to any value in the stepping


I use cat /proc/cpuinfo to get the model and the family encoding .

and transform them to hexadecimal and find the value
concatenating is the same as manal.

So ,I doublt whether set eax=1 can get the cpuid signature ?

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Maxym Dmytrychenko (Intel)'s picture

just have a look on the following document:


where note that for Model, there are actually : "Extended Model" and just "Model" which have to be combined like:

M = (Extended Model << 4) + Model
which is actually like:

M = (CPUID(1).EAX[19:16] << 4) + CPUID(1).EAX[7:4]
from "Equation 5-2.Calculated Model Value" of the document above,

so, you code might look like:

low12bit = ((eax & 0xF0000) >> 12) + ((eax & 0x0FF) >> 4);

as by this code - dont forget to skip stepping, if not needed , which are CPUID(1).EAX[3:0]

zhangxiuxia's picture

I got it , thanks !
But the expression in Optimazation Manual is confusing about how to get the cpuid signature .
At first sight, it looks like the lower 12bit of eax.

In fact ,it is the
concatenation of eax[19,16] eax[15,8] eax[7,4]

eax[19,16] eax[7,4] is the model

eax[15,8] is the cpu family

Sergey Kostrov's picture

Here is example on how to get a CPU Vendor text with a '__cpuid' intrinsic function:

int CPUInfo[4] = { -1, -1, -1, -1 };
char CPUVendor[32] = { 0x0 };
uint nIds = 0;

__cpuid( CPUInfo, 0 );

nIds = CPUInfo[0];

*( ( int * )( CPUVendor )) = CPUInfo[1];
*( ( int * )( CPUVendor+4 )) = CPUInfo[3];
*( ( int * )( CPUVendor+8 )) = CPUInfo[2];
printf( "\tCPU Vendor: %s\n", CPUVendor );

and in case of Intel CPU the output should look like:

CPU Vendor: GenuineIntel

Login to leave a comment.