Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, August 2006
How to get number of physical CPUs in RHEL & SuSE


Message 1 in thread

From my application code, I want to get number of
physical processors present in system (RHEL & SuSE).
How do i go about?

sysconf( ) - provides only logical CPUs count, not
physical CPUs count

Thanks,
++Sathya

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

--
 [ signature omitted ] 

Message 2 in thread

On Tue, Aug 29, Srinivasan Sathyanarayanan wrote:

> From my application code, I want to get number of
> physical processors present in system (RHEL & SuSE).
> How do i go about?
> 
> sysconf( ) - provides only logical CPUs count, not
> physical CPUs count
> 


You can look at /proc/cpuinfo

This box has 2 real CPUs:



processor       : 0
vendor_id       : GenuineIntel
cpu family      : 6
model           : 8
model name      : Pentium III (Coppermine)
stepping        : 6
cpu MHz         : 864.382
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse
bogomips        : 1703.93

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 6
model           : 8
model name      : Pentium III (Coppermine)
stepping        : 6
cpu MHz         : 864.382
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse
bogomips        : 1724.41





This box has 2 cores and hyperthreading ("ht" in flags):

processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      :                    Genuine Intel(R) CPU 3.00GHz
stepping        : 4
cpu MHz         : 2994.478
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 0
cpu cores       : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr
bogomips        : 5998.34
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 4
model name      :                    Genuine Intel(R) CPU 3.00GHz
stepping        : 4
cpu MHz         : 2994.478
cache size      : 1024 KB
physical id     : 0
siblings        : 2
core id         : 1
cpu cores       : 2
fpu             : yes
fpu_exception   : yes
cpuid level     : 5
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm syscall nx lm constant_tsc pni monitor ds_cpl est cid cx16 xtpr
bogomips        : 5989.34
clflush size    : 64
cache_alignment : 128
address sizes   : 36 bits physical, 48 bits virtual
power management:


Best,

        Uwe 

-- 
 [ signature omitted ] 

Message 3 in thread

Hi,

> From my application code, I want to get number of
> physical processors present in system (RHEL & SuSE).
> How do i go about?
> 
> sysconf( ) - provides only logical CPUs count, not
> physical CPUs count

This question is not related to Qt. I suggest trying other mailing lists 
such as:
	http://www.gnu.org/software/libc/resources.html

As far as I know sysconf() is the appropriate API for that. If there's 
no macro to retrieve the number of physical CPUs (whatever you mean by 
physical count with new multicore processors) then there's probably no 
API to retrieve that information from the C library. If so, you need to 
get the information directly from the kernel, for example by parsing 
/proc/cpuinfo on systems that make it available.

--
 [ signature omitted ]