硬件多线程和同步多线程(SMT)

Hardware Multithreading and Simultaneous Multithreading(SMT)

我正在阅读 Multithreading (computer architecture) - Wiki,又名硬件线程,我正在尝试理解第二段:

(p2): Where multiprocessing systems include multiple complete processing units in one or more cores, multithreading aims to increase utilization of a single core by using thread-level parallelism, as well as instruction-level parallelism.

而 link 到 线程级并行性 表示:

(Link): Thread-level parallelism (TLP) is the parallelism inherent in an application that runs multiple threads at once. This type of parallelism is found largely in applications written for commercial servers such as ...

这不是很有用...所以我阅读了上面的 任务并行性,因为我猜 TLP 是它的一个子类型:

Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple processors in parallel computing environments. Task parallelism focuses on distributing tasks—concurrently performed by processes or threads—across different processors.

问题:如果线程级并行是任务并行,而任务并行是跨多处理器并行,如何提高单核利用率线程级并行 工作?

猜测:我猜对于TLP,应该是跨多个逻辑处理器,即OS角度的硬件线程,对吗?


另一个小问题是,对于我的第一个 link,多线程:

In computer architecture, multithreading is the ability of a central processing unit (CPU) (or a single core in a multi-core processor) to execute multiple processes or threads concurrently, supported by the operating system.

而在 (p2) 中,它 旨在通过使用线程级 并行性 来提高单核的利用率?好矛盾。

我想我的直觉应该是正确的,要么是:

  1. Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple processors in parallel computing environments.

    应更新为:

    Task parallelism (also known as function parallelism and control parallelism) is a form of parallelization of computer code across multiple logical processors in parallel computing environments.

    包括超线程的可能性。

  2. 无更新,但任务并行性关注跨处理器并行性,而对于 TLP,它应该意味着

    Thread-level parallelism is a form of parallelization of computer code across multiple logical processors in parallel computing environments.

    同样,包括超线程的可能性。


有用的资源:

  • https://en.wikipedia.org/wiki/Hyper-threading
  • https://www.youtube.com/watch?v=wnS50lJicXc
  • https://en.wikipedia.org/wiki/Simultaneous_multithreading

    尤其是this line:

    The name multithreading is ambiguous, because not only can multiple threads be executed simultaneously on one CPU core, but also multiple tasks (with different page tables, different task state segments, different protection rings, different I/O permissions, etc.).

    因此,对于小问题,请参阅 Concurrent computing - #Introduction - p1:

    The concept of concurrent computing is frequently confused with the related but distinct concept of parallel computing,[2][3] although both can be described as "multiple processes executing during the same period of time". In parallel computing, execution occurs at the same physical instant: for example, on separate processors of a multi-processor machine, with the goal of speeding up computations—parallel computing is impossible on a (one-core) single processor, as only one computation can occur at any instant (during any single clock cycle).

我认为我们不应该基于 wiki 定义,那里的措辞不够准确,不值得寻找矛盾。

首先,我将任务并行描述为某些算法或问题所固有的一种并行形式,其中可以将功能分解为具有不同性质的多个任务,这些任务可以 运行 同时进行。并行的替代形式包括例如空间或数据分解,其中问题可以分解为数据或输入布局的不同部分(例如,数组范围、矩阵块、图像部分...)。

线程级并行是一种不同的分类法,它是可以提取供多线程系统使用的任何形式的并行。它要求分解足够粗粒度以允许不同的线程独立 运行 (否则所需的同步开销将使其无用)。 替代方案是例如 ILP(指令级并行性),即单线程上下文可以通过 运行ning 在可以根据准备情况进行调度的深度无序机器上提取代码中的并行性。这通常允许更细粒度的并行性和更少的程序员参与,但将并行性限制在 OOO window.

的深度。

关于相关主题 - 注意不要混淆同时执行和并发执行。

可以通过从代码中提取任务级并行或其他形式的算法分解来使用线程级并行。然后它可以在单核(抢占式)或多线程系统上 运行。后一种类型可以通过多核系统、同步多线程或两者兼而有之(普通处理器通常有很多内核,并且可能在这些内核之上支持 SMT)。