Looking for ways to detect Hyper Threading

Looking for ways to detect Hyper Threading

Hi,

I am loking for ways to detect hyper threading in c++ program on Linux. I don't intent to read /proc/cpuinfo file.

I have tried cpuid and then edx value, somehow, it returns the same value on machines with HT and without HT.

It seems some cpucounter program on web is not working for intel64. 

I am using 64 bit Linux machine with :

processor : 1
vendor_id : GenuineIntel
cpu family : 6
model : 45
model name : Intel(R) Core(TM) i7-3960X CPU @ 3.30GHz

...

Thank you.

4 帖子 / 0 全新
最新文章
如需更全面地了解编译器优化,请参阅优化注意事项
jimdempseyatthecove的头像

The question becomes: Do you want completely portable code?
IOW to older generations of Intel and non-Intel (AMD?) archetectures than your Intel(R) Core(TM) i7-3960X CPU
Also, there is a potential issue should you have a multi-socket system where some sockets have HT (enabled) and others do not.

You might start by consulting Google:

"detecting multi-core processor topology" site:intel.com format:.pdf

*** open the.PDF file link(s) not the non-pdf file (html) link
*** the Intel site has wrong hyperlinks in (bmunged up in update)

Jim Dempsey

www.quickthreadprogramming.com
jimdempseyatthecove的头像

GRIPE

Unable to post comments with simple formatting such as blank lines and white space on left side for indentation
And NO I am not willing to accept having to type in HTML tags.
This is a general purpose programmers forum (e.g. C++, FORTRAN, etc), not a web designer/programmer forum (HTML, HTML6).

Jim Dempsey

www.quickthreadprogramming.com

>>...I have tried cpuid and then edx value, somehow, it returns the same value on machines with HT and without HT...

I have two test-cases that use CPUID instruction and I didn't have any problems with detecting HTT:
...
const RTuint _HTT_FEATURE_BIT = 0x10000000; // 00010000000000000000000000000000
...
MOV eax, 1
CPUID
MOV uiFeatureRegCX, ecx
MOV uiFeatureRegDX, edx
if( ( uiFeatureRegDX & _HTT_FEATURE_BIT )
{
return ( RTbool )RTtrue;
}
...
Did you check a 28th bit of EDX register?

登陆并发表评论。