Get CPU information?

Get CPU information?

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

9 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

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.

Martin Brenner EGOSOFT GmbH http://www.egosoft.com

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.

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

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.

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.

Martin Brenner EGOSOFT GmbH http://www.egosoft.com

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

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+, ....

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

Martin Brenner EGOSOFT GmbH http://www.egosoft.com

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi