Community
cancel
Showing results for 
Search instead for 
Did you mean: 
200 Views

How to detect Hyper-Threading? EDX[28] is used for multi-threading which include hyper-threading and multi core

Use the CPUID instruction to detect the presence of hardware multi-threading support in a physical processor. Hardware multi-threading can support several varieties of multigrade and/or Intel Hyper-Threading Technology. CPUID instruction provides several sets of parameter information to aid software enumerating topology information. The relevant topology enumeration parameters provided by CPUID include:
Hardware Multi-Threading feature flag (CPUID.1:EDX[28] = 1) - Indicates when set that the physical package is capable of supporting Intel Hyper-Threading Technology and/or multiple cores.

Above are the statements in intel manuals, my questions is:

I want to detect whether a system is supporting Hyper-threading? EDX[28] is used to identify both hyper-threading and multi core, i try to google around but can not find a way to different Hyper-threading from multi core.

Thanks for your help.
0 Kudos
3 Replies
gaston-hillar
Black Belt
200 Views

Use the CPUID instruction to detect the presence of hardware multi-threading support in a physical processor. Hardware multi-threading can support several varieties of multigrade and/or Intel Hyper-Threading Technology. CPUID instruction provides several sets of parameter information to aid software enumerating topology information. The relevant topology enumeration parameters provided by CPUID include:
Hardware Multi-Threading feature flag (CPUID.1:EDX[28] = 1) - Indicates when set that the physical package is capable of supporting Intel Hyper-Threading Technology and/or multiple cores.

Above are the statements in intel manuals, my questions is:

I want to detect whether a system is supporting Hyper-threading? EDX[28] is used to identify both hyper-threading and multi core, i try to google around but can not find a way to different Hyper-threading from multi core.

Thanks for your help.

Hi soft...,

This post http://software.intel.com/en-us/articles/hyper-threading-technology-multi-core-and-mobile-intel-pent...

can help you. It uses C++ and a library to detect logical and physical cores.

It doesn't work with the newest microprocessors. However, today Khang Nguyen (Intel) added a comment telling me there is going to be a new version soon. :)

I think this is what you're looking for. I've been using this library for a while. Nonetheless, I'm looking forward for its new version to arrive.

Hope it helps.

Cheers,

Gastn
200 Views

Quoting - Gastn C. Hillar

Hi soft...,

This post http://software.intel.com/en-us/articles/hyper-threading-technology-multi-core-and-mobile-intel-pent...

can help you. It uses C++ and a library to detect logical and physical cores.

It doesn't work with the newest microprocessors. However, today Khang Nguyen (Intel) added a comment telling me there is going to be a new version soon. :)

I think this is what you're looking for. I've been using this library for a while. Nonetheless, I'm looking forward for its new version to arrive.

Hope it helps.

Cheers,

Gastn

HI Gaston,

Thanks for your reply. The way to detect HT in the article you mentioned did not work in my case.

I am trying to find a way to detect whether a system is supporting HT, EDX[28] seems means both HT and Multi core, i need to identify HT only.

Here is the define of HT_BIT from the .h file provided by Khang.
#define HT_BIT 0x10000000 // EDX[28] Bit 28 is set if HT is supported
// Doesn't mean HT is enabled in BIOS
gaston-hillar
Black Belt
200 Views


HI Gaston,

Thanks for your reply. The way to detect HT in the article you mentioned did not work in my case.

I am trying to find a way to detect whether a system is supporting HT, EDX[28] seems means both HT and Multi core, i need to identify HT only.

Here is the define of HT_BIT from the .h file provided by Khang.
#define HT_BIT 0x10000000 // EDX[28] Bit 28 is set if HT is supported
// Doesn't mean HT is enabled in BIOS

I think that the CPUCount function is going to help you.

This is the documentation:

*********CPUCount

Syntax: unsigned char CPUCount
(unsigned char *AvailLogicalNum,
unsigned char *AvailCoreNum,
unsigned char *PhysicalNum,)
Description: This function retrieves the number of available logical processors per physical package, available cores per physical package, and the total number of physical processors. The term available implies that the number of logical or cores that an application can use. These numbers are different from those returned by the functions LogicalProcPerPhysicalProc and CorePerPhysicalProc. These two functions return the maximum values of logical and cores that a physical package can handle. These numbers are for reference only. They cannot be used to create threads. Otherwise, performance will be degraded.

If for some reason that the total number of physical cannot be determined, the variable PhysicalNum will be set to this value: CANNOT_DETECT_PHY_CPU 0xFF

Return Value: Returns the status of the system. Following are the possible status:

SINGLE_CORE_AND_HT_ENABLED 1
SINGLE_CORE_AND_HT_DISABLED 2
SINGLE_CORE_AND_HT_NOT_CAPABLE 4
MULTI_CORE_AND_HT_NOT_CAPABLE 5
MULTI_CORE_AND_HT_ENABLED 6
MULTI_CORE_AND_HT_DISABLED 7
CORE_AND_HT_CANNOT_DETECT 8
CORE_CANNOT_DETECT_AND_HT_NOT_CAPABLE 9

*********

If the number of physical cores != number of logical cores => (HT== true)

Hope this helps.

Cheers,

Gaston
Reply