Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.

Get CPU information?

tcorp1
Beginner
1,497 Views
Is there in IPP some functions that can say for example, how many cores has CPU, or how is he loaded. I want to build some "adaptive" programs that will automaticly incrises number of working threads if CPU can handle it.
So can you help me with it?
Thank you, Ron
0 Kudos
8 Replies
Martin_Brenner
Beginner
1,497 Views
Basically, what we are using is based on the sample code "Coding for Multiple Cores on Xbox 360 and Microsoft Windows" from the DirectX SDK. This is a DirectX sample from 2006 which is still present in the June 2010 DirectX SDK which reports the number of cores and hyperthreading information. It uses the GetLogicalProcessorInformation() if it is available (starting from certain WindowsXP versions) and falls back to using the CPUID instruction otherwise.
0 Kudos
kimyko
Beginner
1,497 Views
I think there is some sort of functions for that it also depends on the capacity of the memory drive of the cpu can handle.
0 Kudos
SergeyKostrov
Valued Contributor II
1,497 Views
In an older version of IPP there is an include file "ippcore.h" and it hasseveral 'ippCore*****' likefunctions, but I don't know if you will be able to get a number of CPU cores.

On Windows platforms Win32 API provideslots ofinformation regarding CPU, etc.

Also, you can get complete CPU details with CPUID instruction in assembler or in C/C++ codes with inline assembler. Here isan example ofwhat information you can get with CPUID instruction:

Basic CPUID Information 0
CPUInfo[0] = 0x0000000A
CPUInfo[1] = 0x756E6547
CPUInfo[2] = 0x6C65746E
CPUInfo[3] = 0x49656E69
Basic CPUID Information 1
CPUInfo[0] = 0x000106C2
CPUInfo[1] = 0x00020800
CPUInfo[2] = 0x0040C39D
CPUInfo[3] = 0xBFE9FBFF
Basic CPUID Information 2
CPUInfo[0] = 0x4FBA5901
CPUInfo[1] = 0x0E3080C0
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 3
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 4
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 5
CPUInfo[0] = 0x00000040
CPUInfo[1] = 0x00000040
CPUInfo[2] = 0x00000003
CPUInfo[3] = 0x00020220
Basic CPUID Information 6
CPUInfo[0] = 0x00000001
CPUInfo[1] = 0x00000002
CPUInfo[2] = 0x00000001
CPUInfo[3] = 0x00000000
Basic CPUID Information 7
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 8
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 9
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Basic CPUID Information 10
CPUInfo[0] = 0x07280203
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00002501
Extended Function CPUID Information 80000000
CPUInfo[0] = 0x80000008
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Extended Function CPUID Information 80000001
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000001
CPUInfo[3] = 0x00000000
Extended Function CPUID Information 80000002
CPUInfo[0] = 0x20202020
CPUInfo[1] = 0x20202020
CPUInfo[2] = 0x746E4920
CPUInfo[3] = 0x52286C65
Extended Function CPUID Information 80000003
CPUInfo[0] = 0x74412029
CPUInfo[1] = 0x54286D6F
CPUInfo[2] = 0x4320294D
CPUInfo[3] = 0x4E205550
Extended Function CPUID Information 80000004
CPUInfo[0] = 0x20303732
CPUInfo[1] = 0x20402020
CPUInfo[2] = 0x30362E31
CPUInfo[3] = 0x007A4847
Extended Function CPUID Information 80000005
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Extended Function CPUID Information 80000006
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x02008040
CPUInfo[3] = 0x00000000
Extended Function CPUID Information 80000007
CPUInfo[0] = 0x00000000
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
Extended Function CPUID Information 80000008
CPUInfo[0] = 0x00002020
CPUInfo[1] = 0x00000000
CPUInfo[2] = 0x00000000
CPUInfo[3] = 0x00000000
CPU Brand String: Intel Atom CPU N270 @ 1.60GHz
CPU Vendor : GenuineIntel
Stepping ID = 2
Model = 12
Family = 6
Extended Model = 1
CLFLUSH Cache Line Size = 64
The following features are supported:
SSE3 New Instructions
MONITOR/MWAIT
CPL Qualified Debug Store
Thermal Monitor 2
FPU - Floating Point Unit On Chip
VME - Virtual 8086 Mode Enhancement
DE - Debugging Extensions
PSE - Page Size Extensions
TSC - Time Stamp Counter
MSR - Model Specific Registers RDMSR and WRMSR Instructions
PAE - Physical Address Extensions
MCE - Machine Check Exception
CX8 - CMPXCHG8B Instruction
APIC - APIC On Chip
SEP - SYSENTER and SYSEXIT
MTRR - Memory Type Range Registers
PGE - PTE Global Bit
MCA - Machine Check Architecture
CMOV - Conditional Move Instructions
PAT - Page Attribute Table
CLFSH- CLFLUSH Instruction
DS - Debug Store
ACPI - Thermal Monitor and Software Controlled Clock Facilities
MMX - Intel MMX Technology
FXSR - FXSAVE and FXRSTOR Instructions
SSE - SSE Extensions
SSE2 - SSE2 Extensions
SS - Self Snoop
HTT - Hyper-Threading Technology
TM - Thermal Monitor
PBE - Pending Break Enable
Cache Line Size = 64
L2 Associativity = 8
Cache Size = 512K
0 Kudos
SergeyKostrov
Valued Contributor II
1,497 Views
Unfortunately, GetLogicalProcessorInformation Win32 API function is available on Windows XP Professional x64 Edition only.

You could also useGetProcessAffinityMask Win32 API function because it is very old and was introduced in WindowsNTsome timebefore 1992 - 1993.
0 Kudos
Martin_Brenner
Beginner
1,497 Views
Yes, thats why the example falls back to using CPUID directly (using some inline assembler code) in case GetLogicalProcessorInformation is not available. And while GetProcessAffinityMask gives you the number of HW threads, it doesn't tell you which of these result from Hyperthreading.
0 Kudos
SergeyKostrov
Valued Contributor II
1,497 Views
Hi,

What I really understood that I need to lookagainatIntel's docs regarding Hyper-threading...

What doyou mean by saying:

>>...HW threads, it doesn't tell you which of these result from Hyperthreading...

Best regards,
Sergey
0 Kudos
TimP
Honored Contributor III
1,497 Views
For example, for several years of linux kernels, /proc/cpuinfo has designated HyperThreads as siblings. This makes it possible, although inconvenient, to count physical cores as well as logical processors. Utilities which come with MPI, such as Intel MPI cpuinfo, or (open source) hwloc (does it work on Windows?) sort out (for the supported CPU types) a list of which processor numbers are associated with each core.
For a long time, Windows programmers were expected to write low level code and test it for the particular CPU models of interest. Likewise, Windows has continued to flip-flop about providing uniform facilities to optimize mapping of threads to cores under programming models such as OpenMP, MPI, Cilk+, ....
0 Kudos
Martin_Brenner
Beginner
1,497 Views
What I meant was that while GetProcessAffinityMask does tell you the number of concurrent processors the CPU supports, it doesn't give you the information which of these are true separate cores or share a core through hyperthreading (logical processors).

For the nitty gritty details there is an article from Intel on the subject of getting the numbers of cores and logical processors from CPUID:

http://software.intel.com/en-us/articles/multi-core-detect/

Cheers,
-Martin
0 Kudos
Reply