CPUID and number of cores

  • Follow


It is written in "Intel  Processor Identification and the CPUID
Instruction" that:

"The BIOS will use this function to determine the number of cores
implemented in a specific
physical processor package. To do this the BIOS must initially set the
EAX register to 4 and the
ECX register to 0 prior to executing the CPUID instruction. After
executing the CPUID
instruction, (EAX[31:26] + 1) contains the number of cores."

This is my cpuid function:
void cpuid(uint param, uint *a, uint *b, uint *c, uint *d) {
	__asm {
		mov eax, param
		xor ebx, ebx
		xor ecx, ecx
		xor edx, edx
		cpuid
		mov edi, a
		mov [edi], eax
		mov edi, b
		mov [edi], ebx
		mov edi, c
		mov [edi], ecx
		mov edi, d
		mov [edi], edx
	}
}

and that is how i read number of cpu cores:
cpuid(0x4, &eax, &ebx, &ecx, &edx);
cpu->CORE_NUM = (eax>>26) + 1;

But funny thing, on Celereon CORE_NUM is 26!!
I would like to have so many cores ;-]

I do not remeber what Celeron is it, cos it is pc from my work...
So, what is wrong with this??

Thanks for any help,

regards,

Przemek

0
Reply spamtrap2 (1628) 7/22/2007 8:32:10 PM

Bronson wrote:
> It is written in "Intel  Processor Identification and the CPUID
> Instruction" that:
> 
> "The BIOS will use this function to determine the number of cores
> implemented in a specific
> physical processor package. To do this the BIOS must initially set the
> EAX register to 4 and the
> ECX register to 0 prior to executing the CPUID instruction. After
> executing the CPUID
> instruction, (EAX[31:26] + 1) contains the number of cores."
> 
> This is my cpuid function:
> void cpuid(uint param, uint *a, uint *b, uint *c, uint *d) {
> 	__asm {
> 		mov eax, param
> 		xor ebx, ebx
> 		xor ecx, ecx
> 		xor edx, edx
> 		cpuid
> 		mov edi, a
> 		mov [edi], eax
> 		mov edi, b
> 		mov [edi], ebx
> 		mov edi, c
> 		mov [edi], ecx
> 		mov edi, d
> 		mov [edi], edx
> 	}
> }
> 
> and that is how i read number of cpu cores:
> cpuid(0x4, &eax, &ebx, &ecx, &edx);
> cpu->CORE_NUM = (eax>>26) + 1;
> 
> But funny thing, on Celereon CORE_NUM is 26!!
> I would like to have so many cores ;-]
> 
> I do not remeber what Celeron is it, cos it is pc from my work...
> So, what is wrong with this??

I'm not too familiar with cpuid, but I understand that with eax=1 it 
returns the vendor string in ebx, edx, ecx... and the maximum supported 
"level" in eax (2, for me). If it doesn't say 4 (or greater), "get 
number of cores" isn't going to work. I'm showing 26 cores, too, and I 
*think* that's why...

Best,
Frank

0
Reply Frank 7/23/2007 4:57:20 AM


Frank Kotler wrote:
> I'm not too familiar with cpuid, but I understand that with eax=1

That would be eax=0, sorry.

> it 
> returns the vendor string in ebx, edx, ecx... and the maximum supported 
> "level" in eax (2, for me). If it doesn't say 4 (or greater), "get 
> number of cores" isn't going to work. I'm showing 26 cores, too, and I 
> *think* that's why...

Best,
Frank

0
Reply Frank 7/23/2007 6:50:10 AM

On 23 Lip, 08:50, Frank Kotler  <spamt...@crayne.org> wrote:
> Frank Kotler wrote:
> > I'm not too familiar with cpuid, but I understand that with eax=1
>
> That would be eax=0, sorry.
>
> > it
> > returns the vendor string in ebx, edx, ecx... and the maximum supported
> > "level" in eax (2, for me). If it doesn't say 4 (or greater), "get
> > number of cores" isn't going to work. I'm showing 26 cores, too, and I
> > *think* that's why...
>
> Best,
> Frank

That is a good point, i've missed that.
So you're saying that when this option is not available i should
assume one core??

Regards,

Przemek

0
Reply Bronson 7/23/2007 10:43:12 AM

Bronson wrote:
> On 23 Lip, 08:50, Frank Kotler  <spamt...@crayne.org> wrote:
> 
>>Frank Kotler wrote:
>>
>>>I'm not too familiar with cpuid, but I understand that with eax=1
>>
>>That would be eax=0, sorry.
>>
>>
>>>it
>>>returns the vendor string in ebx, edx, ecx... and the maximum supported
>>>"level" in eax (2, for me). If it doesn't say 4 (or greater), "get
>>>number of cores" isn't going to work. I'm showing 26 cores, too, and I
>>>*think* that's why...
>>
>>Best,
>>Frank
> 
> 
> That is a good point, i've missed that.
> So you're saying that when this option is not available i should
> assume one core??

I ASSume so - it's what I'd try... Sandpile has a pile of info:

http://www.sandpile.org/ia32/cpuid.htm

Anyone got a Centuar, so we can verify that it says, "CentuarHauls"? I 
think it's funny that they use this for competing "slogans".

Intel offers a "robust algorithm"...

http://www.developers.net/intelmcshowcase/view/2093

I did not download the .pdf...

Best,
Frank

0
Reply Frank 7/23/2007 2:08:15 PM

On 23 Lip, 16:08, Frank Kotler  <spamt...@crayne.org> wrote:
> Bronson wrote:
> > On 23 Lip, 08:50, Frank Kotler  <spamt...@crayne.org> wrote:
>
> >>Frank Kotler wrote:
>
> >>>I'm not too familiar with cpuid, but I understand that with eax=1
>
> >>That would be eax=0, sorry.
>
> >>>it
> >>>returns the vendor string in ebx, edx, ecx... and the maximum supported
> >>>"level" in eax (2, for me). If it doesn't say 4 (or greater), "get
> >>>number of cores" isn't going to work. I'm showing 26 cores, too, and I
> >>>*think* that's why...
>
> >>Best,
> >>Frank
>
> > That is a good point, i've missed that.
> > So you're saying that when this option is not available i should
> > assume one core??
>
> I ASSume so - it's what I'd try... Sandpile has a pile of info:
>
> http://www.sandpile.org/ia32/cpuid.htm
>
> Anyone got a Centuar, so we can verify that it says, "CentuarHauls"? I
> think it's funny that they use this for competing "slogans".
>
> Intel offers a "robust algorithm"...
>
> http://www.developers.net/intelmcshowcase/view/2093
>
> I did not download the .pdf...
>
> Best,
> Frank

Ok, thanks a lot.
That explains everything (in Intel code they assume one core when
cpuid(4) is not available).

Regards,

Przemek

0
Reply Bronson 7/23/2007 4:13:42 PM

5 Replies
419 Views

(page loaded in 0.103 seconds)

Similiar Articles:













7/20/2012 3:00:47 PM


Reply: