0

Is there any simple performance test to detect is HT enabled or not? For example I need it it case when max CPU number is limited by linux kernel(NR_CPUS) and no access to BIOS.

So could you advice any code to detect is HT enabled?

I glanced here or here but it's not the answers. Thanx.

Community
  • 1
  • 1

3 Answers3

2

There is another way - the /sys/ file system, it is supposed to be more orderly than /proc. /proc/cpuinfo varies between kernel versions;

cat /sys/devices/system/cpu/cpu0/topology/thread_siblings

gives you the list of hardware threads that run together with core cpu0.

https://www.kernel.org/doc/Documentation/cputopology.txt

4) /sys/devices/system/cpu/cpuX/topology/thread_siblings:

    internal kernel map of cpuX's hardware threads within the same
    core as cpuX
MichaelMoser
  • 3,172
  • 1
  • 26
  • 26
1

On Linux I think you can read /proc/cpuinfo, but after that you have to do a bit of thinking to see whether we have multicore cpu, or HT enabled cpu etc.

First, flags will give you supported features, and ht there will indicate hyperthreading support.

Then you have to check whether sibling count matches core count on each CPU, so look for cpu id, and deduct from there. (So if sibling count matches core count -> no HT) More information can be found here: http://richweb.com/cpu_info

julumme
  • 2,326
  • 2
  • 25
  • 38
  • Ok. I thanx for the answer. But i'm not interesting in any kind of flags. I need test what which test can show difference between system with enabled HT and disabled. Not any program which read flags but program which do something like matrix multiplication or similar. – Spoonwalker Highwater Sep 18 '13 at 07:45
0

Checking the flags would give you a clear answer, whereas a performance test (particularly if programmatically checking the result) would have some uncertainty. For what performance characteristic is the hyper-threading (HT) signature that we will test? HT provides better performance when the threads are doing different work, where different is defined based on the microarchitecture. In contrast, separate cores have little performance correlation due to the code executing on each core (some factors still exist like memory bandwidth or shared caches).

There are a variety of combinations for which you could test; I will sketch out one possible solution here. Assuming that the system has at least two cores that may also have HT enabled. This presents 4 logical processors (LP) on which threads can be scheduled. Craft a single-threaded program that can stress one core's resources. Now, duplicate that work, so that we'll have two threads that can run independently. To then test performance, set the scheduling affinity of the threads to different pairs of LPs in the system. Then measure the performance for running on different pairs. A HT pair will give different performance than pairing separate cores.

In writing the performance test, you have the usual concerns with measuring performance. Does the mechanism for measuring have the requisite granularity? Is the variable you are testing (HT versus core) changing, but no other variables are? For example, is the cache in the same state before each test? Or, do some cores share caches, so pairing them in a test would give different performance from other pairs? Now, if you do all of this, then you should observe different performance results depending on which pair of LPs you have scheduled your work.

Brian
  • 2,693
  • 5
  • 26
  • 27
  • So the answer to my question is finding the biggest shared block, finding operation of the block and start couple of threads which do the operation in cycle. The threads should be attached to the checking couple of cores. Performance of the operations should differ twice if HT enable or not. Am i right? – Spoonwalker Highwater Sep 18 '13 at 16:37