# 多线程（计算机体系结构）

**多线程**（multithreading）是计算机体系结构中的一组硬件技术，通过复制每线程的架构状态（寄存器和相关机器状态），同时共享核心的执行资源，使单个处理器核心能够同时保持多条执行线程并使其取得进展。其目的是提高处理器利用率：单条线程很少能让现代超标量乱序核心保持忙碌，因为缓存缺失、分支预测错误和数据依赖会使发射槽空闲。多线程用其他线程的指令填充这些空闲槽位。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup>

| 关键事实 | 详情 |
|---|---|
| 复制的部分 | 每个硬件线程拥有自己的架构状态：通用寄存器、段寄存器、控制寄存器和调试寄存器，大多数MSR，以及在IA-32实现中自己的中断控制器（APIC）。<sup>[2](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/25366521.pdf)</sup> |
| 共享的部分 | 执行单元、缓存、分支预测器、控制逻辑和总线由一个物理核心上的各逻辑处理器共享。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup> |
| 主要变体 | 粗粒度（在长延迟事件时切换）、细粒度（每周期切换）和同时多线程（SMT），后者在同一周期内向不同功能单元发射来自多条线程的指令。<sup>[4](https://pages.cs.wisc.edu/~markhill/restricted/micro05_niagara.pdf)</sup> |
| 英特尔实现 | 超线程技术是英特尔的SMT实现，将一个物理核心呈现为两个逻辑处理器；首个至强实现使相对芯片面积和最大功耗增加不到5%。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup> |
| 典型收益 | 英特尔指出，当一个任务在等待时，在一个核心上运行两个任务可使CPU利用率提高约10-30%。<sup>[5](https://www.intel.com/content/www/us/en/support/articles/000098959/processors/intel-xeon-processors.html)</sup> |
| 扩展行为 | 商业工作负载随核心增加以86-99%的效率扩展，但每核心增加硬件线程时效率仅为50-70%。<sup>[6](https://research.ibm.com/publications/performance-studies-of-commercial-workloads-on-a-multi-core-system)</sup> |
| 并非普遍采用 | Arm Neoverse N系列和V系列处理器不实现SMT；其中的每条线程都拥有其核心的全部资源。<sup>[7](https://developer.arm.com/community/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/reassess-cpu-utilization-on-x86-and-arm)</sup> |

## 多线程为何存在

超标量处理器的峰值指令吞吐量远高于单条线程所能维持的水平。在一个典型的4路设计中，平均持续IPC为1.5到2意味着利用率不到50%，损失来自分支预测错误、缓存缺失（尤其是L2缺失）以及指令间的数据依赖。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup> 多线程通过在一个核心上多路复用多条线程来应对这种浪费：如果一条线程无法使用某个发射槽，另一条可以。这种权衡是有意为之：用单线程延迟换取吞吐量，因为共享核心会降低每条线程的个体进展，同时提高总体完成率和利用率。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup>

多线程要工作，唯一必须复制的状态是每线程的架构状态；其他一切都可以共享。这就是为什么相对于增加第二个核心，该技术成本低廉：存储第二组寄存器只占处理器晶体管中极小的一部分。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup>

## 三种硬件变体

这些变体的区别在于硬件何时在线程之间切换以及流水线如何划分。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup>

**粗粒度多线程**让一条线程充分利用核心，直到发生长延迟事件（如需要访问DRAM的缓存缺失）；核心随后切换到另一条线程。切换带有流水线冲刷的开销，因此这种设计能容忍长延迟但无法容忍短延迟。<sup>[4](https://pages.cs.wisc.edu/~markhill/restricted/micro05_niagara.pdf)</sup>

**细粒度多线程**（交错多线程）在周期边界切换线程，通常采用轮转方式，因此每个周期都有不同的硬件线程占据流水线。停滞的线程被自动换出，其槽位让给下一条线程。Sun UltraSPARC T1就是这样工作的：八个核心，每个核心最多运行四条线程，每个核心每周期最多发射一条指令，全芯片每周期最多八条指令。<sup>[8](https://docs.oracle.com/cd/E19052-01/netra.dp11/820-2374-10/appB_tuning.html)</sup>

**同时多线程（SMT）**，也称水平多线程，在同一周期内将来自不同线程的指令调度到不同功能单元上。它天然适合乱序超标量处理器：一旦寄存器被重命名，发射逻辑根本无需区分线程。代价是更大的映射表和物理寄存器堆（其大小随线程数增长），以及每线程的流水线冲刷。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup> 混合设计结合了两种思路，用少量同时线程隐藏细粒度延迟，用粗粒度交换隐藏长延迟。<sup>[1](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)</sup>

## 英特尔超线程

超线程技术将SMT引入英特尔架构。它使单个物理处理器呈现为两个逻辑处理器：架构状态被复制，物理执行资源被共享，因此操作系统和程序像对待真实处理器一样向逻辑处理器调度工作，而来自两条线程的指令在共享硬件上同时执行。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup> 每个逻辑处理器保留完整的架构状态，包括自己的APIC，因此定向到一个逻辑处理器的中断仅由该逻辑处理器处理。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup>

首个实现用于面向双路和多路服务器的英特尔至强处理器系列，其设计目标是尽量减小芯片面积：使相对芯片面积和最大功耗需求增加不到5%。初步基准测试显示，与上一代[奔腾III](https://www.edgepedia.org/zh/pentium-iii)相比，高端服务器应用的性能提升最高达65%。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup> 该技术仍存在于当前产品中：第12代[英特尔酷睿](https://www.edgepedia.org/zh/intel-core)处理器允许一个IA核心作为两个逻辑处理器运行，缓存、执行单元和总线共享，每个逻辑处理器拥有独立的架构状态，通过BIOS启用并需要操作系统支持。<sup>[9](https://edc.intel.com/content/www/us/en/design/ipla/software-development-platforms/client/platforms/alder-lake-desktop/12th-generation-intel-core-processors-datasheet-volume-1-of-2/003/intel-hyper-threading-technology/)</sup> 英特尔的能效核设计不支持超线程。<sup>[10](https://www.intel.com/content/www/us/en/developer/articles/guide/12th-gen-intel-core-processor-gamedev-guide.html)</sup>

**操作系统支持**至关重要。英特尔针对首个实现的设计指南提出了两项优化：当一个逻辑处理器空闲时使用HALT指令，使核心能进入单线程模式，而不是在空闲循环中消耗共享执行资源；以及先将线程调度到不同物理处理器上，再将多条线程打包到一个物理处理器上。<sup>[3](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)</sup> 此后研究表明，感知SMT的任务调度能在硬件多线程系统上产生均匀的核心资源利用率并改善应用性能，而在这些系统上朴素的负载均衡可能降低性能。<sup>[11](https://research.ibm.com/publications/experiences-in-building-and-scaling-an-enterprise-application-on-multicore-systems)</sup>

## x86之外的SMT

SMT出现在线程数差异巨大的各类服务器处理器系列中。IBM的POWER5引入了SMT以提升服务器性能，<sup>[12](https://research.ibm.com/publications/design-and-implementation-of-the-power5tm-microprocessor--1)</sup> [POWER8](https://www.edgepedia.org/zh/power8)支持每核心最多8路多线程，这推动了对大数据工作负载动态调整每核心活跃线程数的研究。<sup>[13](https://research.ibm.com/publications/auto-tuning-spark-big-data-workloads-on-power8-prediction-based-dynamic-smt-threading)</sup> 在Arm方面，Neoverse E1是一个双线程SMT核心，其中每条线程都是一个独立的架构处理单元，拥有完整的架构状态副本，来自两条线程的指令可以在同一周期发射和执行；软件看待每条线程如同看待传统多核处理器中的一个核心。<sup>[14](https://developer.arm.com/documentation/101560/latest/Introduction-to-the-Neoverse-E1-core/About-the-core)</sup> 相比之下，Neoverse N系列和V系列完全省略了SMT，这使每条线程都能完全访问核心资源，在云环境中执行更可预测，并对线程间的意外数据泄漏有更强的防护。<sup>[7](https://developer.arm.com/community/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/reassess-cpu-utilization-on-x86-and-arm)</sup>

## 实际性能

实测收益在很大程度上取决于工作负载，而第二条线程的收益始终小于第二个核心的收益。在IBM针对SAP-SD、IBM Trade、SPECjbb2005和SPEC SDET等商业工作负载在面向吞吐量的多核系统上的研究中，随核心数扩展达到86-99%的效率，而随每核心硬件线程数扩展仅达到50-70%；隐藏长延迟L2缺失的能力是实现扩展的关键。<sup>[6](https://research.ibm.com/publications/performance-studies-of-commercial-workloads-on-a-multi-core-system)</sup> 一项针对三代支持超线程的至强处理器上网络服务器的研究发现，启用SMT通常只带来轻微收益，有时甚至造成损失，SMT增加的存储器引用往往使存储器系统成为多处理器配置中的瓶颈。<sup>[15](https://research.ibm.com/publications/evaluating-the-impact-of-simultaneous-multithreading-on-network-servers-using-real-hardware)</sup>

**SMT与增加核心的对比**是一种具有可衡量权衡的设计选择。在类似POWER4/POWER5核心上进行等面积比较时，对于CPU密集型基准，片上多处理在性能和能效上更优；而对于存储器密集型基准，SMT更优，因为单个大核心携带更大的L2缓存。两者的发热方式也不同：SMT的发热集中在关键共享结构上，而CMP的发热来自第二个核心的全局能量输出，这需要不同的热管理技术。<sup>[16](https://research.ibm.com/publications/performance-energy-and-thermal-considerations-for-smt-and-cmp-architectures)</sup> 软件结构也很重要：在多核SMT处理器上，多线程程序模型通过减少缓存和DTLB缺失，实现了比多进程模型更好的SMT可扩展性，尽管在使用多个核心时多线程模型产生的DTLB缺失最多高出7.4倍。<sup>[17](https://research.ibm.com/publications/performance-of-multi-process-and-multi-thread-processing-on-multi-core-smt-processors)</sup>

## References

1. [Multithreading Architecture, lecture notes (Nemirovsky & Tullsen), CS 752, University of Wisconsin-Madison](https://pages.cs.wisc.edu/~sinclair/courses/cs752/fall2021/handouts/lecture/14-multithread.pdf)
2. [Intel 64 and IA-32 Architectures Software Developer's Manual, Vol. 1, Section 2.2.5](https://www.intel.com/content/dam/support/us/en/documents/processors/pentium4/sb/25366521.pdf)
3. [Marr, D. T. et al. (2002). Hyper-Threading Technology Architecture and Microarchitecture. Intel Technology Journal, Vol. 6 Issue 1](https://www.intel.com/content/dam/www/public/us/en/documents/research/2002-vol06-iss-1-intel-technology-journal.pdf)
4. [Kongetira, P. et al. NIAGARA: A 32-Way Multithreaded Sparc Processor (Hot Chips 16 / IEEE Micro)](https://pages.cs.wisc.edu/~markhill/restricted/micro05_niagara.pdf)
5. [What Are the Differences Between vCPU, Core, and Hyperthreading on an Intel Xeon Processor, Intel Support](https://www.intel.com/content/www/us/en/support/articles/000098959/processors/intel-xeon-processors.html)
6. [Tseng, J. H. et al. (2007). Performance studies of commercial workloads on a multi-core system. IISWC 2007, IBM Research](https://research.ibm.com/publications/performance-studies-of-commercial-workloads-on-a-multi-core-system)
7. [Chang, R. (2024). Reassess CPU utilization on Simultaneous Multithreading Enabled Systems, Arm Community](https://developer.arm.com/community/arm-community-blogs/b/servers-and-cloud-computing-blog/posts/reassess-cpu-utilization-on-x86-and-arm)
8. [Netra Data Plane Software Appendix B: Tuning, Sun UltraSPARC T1 architecture, Oracle documentation](https://docs.oracle.com/cd/E19052-01/netra.dp11/820-2374-10/appB_tuning.html)
9. [Intel Hyper-Threading Technology, 12th Generation Intel Core Processors Datasheet, Volume 1 of 2](https://edc.intel.com/content/www/us/en/design/ipla/software-development-platforms/client/platforms/alder-lake-desktop/12th-generation-intel-core-processors-datasheet-volume-1-of-2/003/intel-hyper-threading-technology/)
10. [Game Dev Guide for 12th Gen Intel Core Processor Hybrid Architecture, Intel Developer](https://www.intel.com/content/www/us/en/developer/articles/guide/12th-gen-intel-core-processor-gamedev-guide.html)
11. [Seelam, S. et al. (2011). Experiences in building and scaling an enterprise application on multicore systems. CCPE, IBM Research](https://research.ibm.com/publications/experiences-in-building-and-scaling-an-enterprise-application-on-multicore-systems)
12. [Clabes, J. et al. (2004). Design and implementation of the POWER5 microprocessor. ICICDT 2004, IBM Research](https://research.ibm.com/publications/design-and-implementation-of-the-power5tm-microprocessor--1)
13. [Auto-tuning Spark Big Data Workloads on POWER8: Prediction-Based Dynamic SMT Threading. PACT 2016, IBM Research](https://research.ibm.com/publications/auto-tuning-spark-big-data-workloads-on-power8-prediction-based-dynamic-smt-threading)
14. [Arm Neoverse E1 Core Technical Reference Manual: About the core, Arm Developer](https://developer.arm.com/documentation/101560/latest/Introduction-to-the-Neoverse-E1-core/About-the-core)
15. [Ruan, Y. et al. (2005). Evaluating the impact of simultaneous multithreading on network servers using real hardware. SIGMETRICS 2005, IBM Research](https://research.ibm.com/publications/evaluating-the-impact-of-simultaneous-multithreading-on-network-servers-using-real-hardware)
16. [Li, Y. et al. (2005). Performance, energy, and thermal considerations for SMT and CMP architectures. HPCA 2005, IBM Research](https://research.ibm.com/publications/performance-energy-and-thermal-considerations-for-smt-and-cmp-architectures)
17. [Inoue, H. & Nakatani, T. (2010). Performance of multi-process and multi-thread processing on multi-core SMT processors. IISWC 2010, IBM Research](https://research.ibm.com/publications/performance-of-multi-process-and-multi-thread-processing-on-multi-core-smt-processors)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 计算机硬件 › Processors & processor engineering › Computer architecture theory › Multithreading and parallel architectures

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/multithreading-computer-architecture

English original: https://www.edgepedia.org/multithreading-computer-architecture
