Jos*_*ola 44 cpu multi-core hyper-threading
在与网络管理员的交谈中,我提到我的机器是双核的。他告诉我不是。我调出任务管理器,转到性能选项卡,向他展示有两个独立的 CPU 使用率图表。我家里有一台四核机器,它有四个图形。他说,由于超线程,这台特定机器上有两个图。以前我曾经有一个超线程奔腾 4 处理器,但我从来没有完全理解它的意思。那么超线程和双核有什么区别呢?你怎么知道你有哪一个?
rob*_*rob 23
超线程为单个物理CPU 内核公开多个逻辑内核。简单来说,超线程使每个 CPU 内核的上下文切换更加高效。
另一方面,双核芯片实际上有两个物理 CPU 内核,可以同时执行不同的进程。
还有其他多核芯片具有两个以上的内核,而且——正如 Svish 提到的——英特尔最新的多核产品也支持所有内核上的超线程。
您可以使用CPU-Z等 CPU 识别实用程序来确定您拥有多少个内核。正如您在屏幕截图底部附近看到的,本例中的 CPU 有 2 个物理内核。如果线程数大于核心数,则启用超线程。迄今为止,所有具有超线程的面向消费者的 CPU 每个内核都有 2 个线程,因此如果启用 HT,线程数将是内核数的 2 倍。

如果您有 Intel CPU,则可以下载Intel 的 CPU ID 实用程序。
超线程是比多核更便宜、更慢的替代方案
英特尔手册第 3 卷系统编程指南 - 325384-056US 2015 年 9 月8.7“英特尔超线程技术架构”简要介绍了 HT。它包含以下图表:
TODO 在实际应用中平均慢了多少百分比?
Hyperthreading is possible because modern single CPUs cores already execute multiple instructions at once with the instruction pipeline https://en.wikipedia.org/wiki/Instruction_pipelining
The instruction pipeline is a separation of functions inside of a single core to ensure that each part of the circuit is used at any given time: reading memory, decoding instructions, executing instructions, etc.
Hyperthreading separates functions further by using:
a single backend, which actually runs the instructions with its pipeline.
Dual core has two backends, which explains the greater cost and performance.
two front-ends, which take two streams of instructions and order them in a way to maximize pipelining usage of the single backend by avoiding hazards.
Dual core would also have 2 front-ends, one for each backend.
There are edge cases where instruction reordering produces no benefit, making hyperthreading useless. But it produces a significant improvement in average.
Two hyperthreads in a single core share further cache levels (TODO how many? L1?) than two different cores, which share only L3, see:
The interface that each hyperthread exposes to the operating system is similar to that of an actual core, and both can be controlled separately. Thus cat /proc/cpuinfo shows me 4 processors, even though I only have 2 cores with 2 hyperthreads each.
Operating systems can however take advantage of knowing which hyperthreads are on the same core to run multiple threads of a given program on a single core, which might improve cache usage.
This LinusTechTips video contains a light-hearted non-technical explanation: https://www.youtube.com/watch?v=wnS50lJicXc
"Simultaneous multithreading" is a more general/less Intel-specific name for this type of technique.
| 归档时间: |
|
| 查看次数: |
28590 次 |
| 最近记录: |