超线程和多核有什么区别?

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 实用程序

  • UltraSparc T2+ 有 8 个内核,每个内核支持 8 个线程,使其成为单个芯片上的 64 个虚拟 CPU:http://en.wikipedia.org/wiki/UltraSPARC_T2 (3认同)

Ear*_*rlz 18

超线程是您的处理器假装有 2 个物理处理器内核,但只有 1 个和一些额外的垃圾。

超线程的要点在于,当您在处理器中执行代码时,很多时候处理器的某些部分是空闲的。通过包含一组额外的 CPU 寄存器,处理器可以像拥有两个内核一样运行,从而并行使用处理器的所有部分。当两个核心都需要使用处理器的一个组件时,当然一个核心最终会等待。这就是为什么它不能替代双核之类的处理器。

另见:这个问题


Cir*_*郝海东 8

超线程是比多核更便宜、更慢的替代方案

英特尔手册第 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.

  • @pacoverflow 如果有一天我知道答案,或者有人会为我编辑答案:-) (2认同)

归档时间:

查看次数:

28590 次

最近记录:

5 年,9 月 前