User's Manual

8-60 Vol. 3
MULTIPLE-PROCESSOR MANAGEMENT
Software must not assume local APIC_ID values in an MP system are consecutive.
Non-consecutive local APIC_IDs may be the result of hardware configurations or
debug features implemented in the BIOS or OS.
An identifier for each hierarchical level can be extracted from an 8-bit APIC_ID using
the support routines illustrated in Example 8-20. The appropriate bit mask and shift
value to construct the appropriate bit mask for each level must be determined
dynamically at runtime.
8.9.5 Identifying Topological Relationships in a MP System
To detect the number of physical packages, processor cores, or other topological
relationships in a MP system, the following procedures are recommended:
Extract the three-level identifiers from the APIC ID of each logical processor
enabled by system software. The sequence is as follows (See the pseudo code
shown in Example 8-21 and support routines shown in Example 8-18):
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