设备软件

CUDA 线程块CUDA Thread Block

线程块是 CUDA 编程模型 线程层次结构中的中间层级(左图)。一个线程块在单个 流式多处理器 (Streaming Multiprocessor) 上执行(右图,中间)。改编自 NVIDIA 的 CUDA 复习:CUDA 编程模型 和 NVIDIA CUDA C++ 编程指南 中的图表。

线程块是 CUDA 编程模型 (CUDA programming model)线程层次结构 (thread hierarchy) 的一个层级,位于 网格 (grid) 之下但在 线程 (thread) 之上。它是 CUDA 编程模型 中的抽象概念,对应于 PTX (Parallel Thread Execution)/SASS (Streaming Assembler) 中具体的 协作线程数组 (cooperative thread array) 抽象概念。

CUDA 编程模型 中,线程块是向程序员暴露的最小线程协作单元。线程块必须独立执行,因此任何线程块的执行顺序都是有效的,既可以是完全串行的(以任意顺序),也可以是所有可能的交错执行方式。

单个 CUDA 内核 (kernel) 启动会产生一个或多个线程块(以 线程块网格 (thread block grid) 的形式),每个线程块包含一个或多个 线程束 (warp)。线程块的大小可以是任意的,但通常是 线程束 大小的倍数(在所有当前的 CUDA GPU 上为 32)。

英文原文(Modal GPU Glossary)

(left). A thread block executes on a single Streaming Multiprocessor (right, middle). Modified from diagrams in NVIDIA's CUDA Refresher: The CUDA Programming Model and the NVIDIA CUDA C++ Programming Guide.](themed-image://cuda-programming-model.svg)

A thread block is a level of the CUDA programming model's thread hierarchy below a grid but above a thread. It is the CUDA programming model's abstract equivalent of the concrete cooperative thread arrays in PTX/SASS.

Blocks are the smallest unit of thread coordination exposed to programmers in the CUDA programming model. Blocks must execute independently, so that any execution order for blocks is valid, from fully serial in any order to all interleavings.

A single CUDA kernel launch produces one or more thread blocks (in the form of a thread block grid), each of which contains one or more warps. Blocks can be arbitrarily sized, up to a limit of 1024 on current devices, but they are typically multiples of the warp size (32 on current devices).

相关词条

本词条改编自 Modal GPU Glossary(CC BY 4.0)· 中文翻译 miter6/gpu-glossary-zh,MAE 整理排版。