[fpc-devel] AMD & Intel CPUCount

Ludo Brands ludo.brands at free.fr
Fri Dec 28 20:27:46 CET 2012

On 28/12/2012 20:01, Ewald wrote:
>> Xeon:#max threads sharing caches: 16
>> Atom:#max threads sharing caches: 2
>> On Xeon cpuid 00000004 returns 0x1c004121 in rax ,  on Atom 0x4121 in
>> eax. So both report 2 threads per cache. The cores per package (bits
>> 31..26) is not coherent. Don't know how to solve that.
> Well, it is as you say, the `max cores per packge` just doesn't make any
> sense at all. How can a processor hav  e a maximum of one core per
> physical package, while in reality it has two threads sharing the same
> cache? Either I'm missing something here, or the behaviour of CPUID has
> changed over the years.
Atom 230 is one of the first atoms. 
lists a few bugs with cpuid but not this one.
> Either way: it leaves me with a method that is not 100% reliable.
This uses libc but on the Xeon and Atom it gives the correct result 
using debian and ubuntu:

program cpucount;

{$mode objfpc}{$H+}

function sysconf (__name : longint) : longint; cdecl; external 'c' name 
   _SC_UIO_MAXIOV = 60;

   writeln('Number of processors: ',sysconf(_SC_NPROCESSORS_CONF));



More information about the fpc-devel mailing list