Intel 64 and IA-32 Architectures Software Developers Manual Volume 3A, System Programming Guide, Part 1
7-40 Vol. 3A
MULTIPLE-PROCESSOR MANAGEMENT
The extraction algorithm (for three-level mappings of an initial APIC_ID) uses the
following support routines (Example 7-1):
1. Detect capability for hardware multi-threading support in the processor.
2. Identify the maximum number of logical processors in a physical processor
package. This is used to determine the topological relationship between logical
processors and the physical package.
3. Identify the maximum number of processor cores in a physical processor
package. This is used to determine the topological relationship between
processor cores and the physical package.
4. Extract the initial APIC ID for the logical processor where the current thread is
executing.
5. Calculate a mask from the maximum count that the bit field can represent.
6. Use full 8-bit ID and mask to extract sub-field IDs.
Example 7-1. Support Routines for Detecting Hardware Multi-Threading and Identifying the
Relationships Between Package, Core and Logical Processors
1. Detect support for Hardware Multi-Threading Support in a processor.
// Returns a non-zero value if CPUID reports the presence of hardware multi-threading
// support in the physical package where the current logical processor is located.
// This does not guarantee BIOS or OS will enable all logical processors in the physical
// package and make them available to applications.
// Returns zero if hardware multi-threading is not present.
#define HWMT_BIT 0x10000000
unsigned int HWMTSupported(void)
{
try { // verify cpuid instruction is supported
execute cpuid with eax = 0 to get vendor string
execute cpuid with eax = 1 to get feature flag and signature
}
except (EXCEPTION_EXECUTE_HANDLER) {
return 0 ; // CPUID is not supported; So HW Multi-threading capability is not present
}
// Check to see if this a Genuine Intel Processor