| Last Modified On : | March 20, 2008 6:40 PM PDT |
Rate |
|
Detect the presence or absence of Hyper-Threading Technology-support in a processor. Hyper-Threading Technology-enabled processors contain multiple logical processors per physical processor package. The state information necessary to support each logical processor is replicated, while sharing the underlying physical processor resources. Given that processor resources are generally underutilized by most applications, Hyper-Threading Technology-enabled processors can improve overall application performance. Multiple threads running in parallel can achieve higher utilization and increased throughput.
Use the CPUID instruction to determine whether the physical processor supports Hyper-Threading Technology. First, ensure that the processor supports the cpuid instruction and is a genuine Intel® Pentium® 4 family processor or later. Then retrieve model-specific feature information about Hyper-Threading Technology using the cpuid instruction and setting the eax register to 1.
If the platform supports more than one physical processor, it does not matter on which processor you execute the cpuid instruction, since all physical processors present on the platform must support the same number of logical processors. After executing the cpuid instruction, if bit 28 in edx is set, then the physical processor supports Hyper-Threading Technology.
The following code fragment enables an application to determine whether Hyper-Threading Technology is supported on the processor:
#define HT_BIT 0x10000000 // EDX[28] - Bit 28 set |
Note that support for Hyper-Threading technology on the processor does not necessarily mean that the processor supports more than one logical processor, that the BIOS has d the feature, or that the operating system is utilizing the extra logical processors. Additional steps are required to determine the number of logical processors supported by the physical processor, as well as querying the operating system to determine the logical-to-physical processor mapping. Some of these issues are addressed in the following separate items:
Refer to Intel's Application Note AP-485 titled Intel Processor Identification and the CPUID Instruction for details on detecting model specific features available on all Intel processors.
