13.07.2015 Views

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

Intel® 64 and IA-32 Architectures Optimization Reference Manual

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

MULTICORE AND HYPER-THREADING TECHNOLOGY• Core: A physical processor package consists of one or more processor cores.ACORE_ID label can be used to distinguish different processor cores within apackage.• SMT: A processor core provides one or more logical processors sharing executionresources. A SMT_ID label can be used to distinguish different logical processorsin the same processor core.Typically, each logical processor that is enabled by the operating system <strong>and</strong> madeavailable to application for thread-scheduling is represented by a bit in an OSconstruct, commonly referred to as an affinity mask 8 . Software can use an affinitymask to control the binding of a software thread to a specific logical processor atruntime.Software can query CPUID on each enabled logical processor to assemble a table foreach level of the three-level identifiers. These tables can be used to track the topologicalrelationships between PACKAGE_ID, CORE_ID, <strong>and</strong> SMT_ID <strong>and</strong> to constructlook-up tables of initial APIC_ID <strong>and</strong> affinity masks.The sequence to assemble tables of PACKAGE_ID, CORE_ID, <strong>and</strong> SMT_ID is shown inExample 8-11. The example uses support routines described in Chapter 7 of theIntel® <strong>64</strong> <strong>and</strong> <strong>IA</strong>-<strong>32</strong> <strong>Architectures</strong> Software Developer’s <strong>Manual</strong>, Volume 3A.Affinity masks can be used to optimize shared multithreading resources.Example 8-11. Assembling 3-level IDs, Affinity Masks for Each Logical Processor// The BIOS <strong>and</strong>/or OS may limit the number of logical processors// available to applications after system boot.// The below algorithm will compute topology for the logical processors// visible to the thread that is computing it.// Extract the 3-levels of IDs on every processor.// SystemAffinity is a bitmask of all the processors started by the OS.// Use OS specific APIs to obtain it.// ThreadAffinityMask is used to affinitize the topology enumeration// thread to each processor using OS specific APIs.// Allocate per processor arrays to store the Package_ID, Core_ID <strong>and</strong>// SMT_ID for every started processor.8. The number of non-zero bits in the affinity mask provided by the OS at runtime may be less thanthe total number of logical processors available in the platform hardware, due to various featuresimplemented either in the BIOS or OS.8-35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!