background image

Vol. 3A 8-43

MULTIPLE-PROCESSOR MANAGEMENT

The extraction start from the right-most bit field, corresponding to SMT_ID, the innermost hierarchy in 

a three-level topology (See Figure 8-7). For the right-most bit field, the shift value of the working mask 
is zero. The width of the bit field is determined dynamically using the maximum number of logical 
processor per core, which can be derived from information provided from CPUID.

To extract the next bit-field, the shift value of the working mask is determined from the width of the bit 

mask of the previous step. The width of the bit field is determined dynamically using the maximum 
number of cores per package.

To extract the remaining bit-field, the shift value of the working mask is determined from the maximum 

number of logical processor per package. So the remaining bits in the APIC ID (excluding those bits 
already extracted in the two previous steps) are extracted as the third identifier. This applies to a non-
clustered MP system, or if there is no need to distinguish between PACKAGE_ID and CLUSTER_ID.

If there is need to distinguish between PACKAGE_ID and CLUSTER_ID, PACKAGE_ID can be extracted 
using an algorithm similar to the extraction of CORE_ID, assuming the number of physical packages in 
each node of a clustered system is symmetric.

Assemble the three-level identifiers of SMT_ID, CORE_ID, PACKAGE_IDs into arrays for each enabled logical 
processor. This is shown in Example 8-22a.

To detect the number of physical packages: use PACKAGE_ID to identify those logical processors that reside in 
the same physical package. This is shown in Example 8-22b. This example also depicts a technique to construct 
a mask to represent the logical processors that reside in the same package.

To detect the number of processor cores: use CORE_ID to identify those logical processors that reside in the 
same core. This is shown in Example 8-22. This example also depicts a technique to construct a mask to 
represent the logical processors that reside in the same core.

In Example 8-21, the numerical ID value can be obtained from the value extracted with the mask by shifting it right 
by shift count. Algorithms below do not shift the value. The assumption is that the SubID values can be compared 
for equivalence without the need to shift. 

Example 8-21.  Pseudo Code Depicting Three-level Extraction Algorithm

For Each local_APIC_ID{

// Calculate SMT_MASK, the bit mask pattern to extract SMT_ID, 
// SMT_MASK is determined using topology enumertaion parameters
// from CPUID leaf 0BH (Example 8-19);
// otherwise, SMT_MASK is determined using CPUID leaf 01H and leaf 04H (Example 8-20).
// This algorithm assumes there is symmetry across core boundary, i.e. each core within a
//  package has the same number of logical processors
// SMT_ID always starts from bit 0, corresponding to the right-most bit-field
SMT_ID = APIC_ID & SMT_MASK;

// Extract CORE_ID:

// CORE_MASK is determined in Example 8-19 or Example 8-20
CORE_ID = (APIC_ID & CORE_MASK) ;

// Extract PACKAGE_ID:
// Assume single cluster. 
// Shift out the mask width for maximum logical processors per package
// PACKAGE_MASK is determined in Example 8-19 or Example 8-20
PACKAGE_ID = (APIC_ID & PACKAGE_MASK) ;

}