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.
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.
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.
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: