CUDA:每个多处理器和每个块的线程有多少线程? [英] CUDA: What is the threads per multiprocessor and threads per block distinction?

查看:2735
本文介绍了CUDA:每个多处理器和每个块的线程有多少线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个工作站安装了两个Nvidia Quadro FX 5800卡。运行deviceQuery CUDA示例显示每个多处理器(SM)的最大线程数为1024,而每个块的最大线程数为512.

We have a workstation with two Nvidia Quadro FX 5800 cards installed. Running the deviceQuery CUDA sample reveals that the maximum threads per multiprocessor (SM) is 1024, while the maximum threads per block is 512.

由于只能执行一个块在每个SM一次,为什么最大线程/处理器是最大线程/块的两倍?我们如何利用每个SM的其他512个线程?

Given that only one block can be executed on each SM at a time, why is max threads / processor double the max threads / block? How do we utilise the other 512 threads per SM?

Device 1: "Quadro FX 5800"
  CUDA Driver Version / Runtime Version          5.0 / 5.0
  CUDA Capability Major/Minor version number:    1.3
  Total amount of global memory:                 4096 MBytes (4294770688 bytes)
  (30) Multiprocessors x (  8) CUDA Cores/MP:    240 CUDA Cores
  GPU Clock rate:                                1296 MHz (1.30 GHz)
  Memory Clock rate:                             800 Mhz
  Memory Bus Width:                              512-bit
  Max Texture Dimension Size (x,y,z)             1D=(8192), 2D=(65536,32768), 3D=(2048,2048,2048)
  Max Layered Texture Size (dim) x layers        1D=(8192) x 512, 2D=(8192,8192) x 512
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       16384 bytes
  Total number of registers available per block: 16384
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1024
  Maximum number of threads per block:           512
  Maximum sizes of each dimension of a block:    512 x 512 x 64
  Maximum sizes of each dimension of a grid:     65535 x 65535 x 1
  Maximum memory pitch:                          2147483647 bytes
  Texture alignment:                             256 bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     No
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  Device supports Unified Addressing (UVA):      No
  Device PCI Bus ID / PCI location ID:           4 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

干杯,
詹姆斯。

Cheers, James.

推荐答案


由于每次只能对每个SM执行一个块,

Given that only one block can be executed on each SM at a time,

此语句根本不正确。除去资源冲突,并且假设在内核(即网格)中有足够的线程块,SM通常将具有分配给它的多个线程块。

This statement is fundamentally incorrect. Barring resource conflicts, and assuming enough threadblocks in a kernel (i.e. the grid), an SM will generally have multiple threadblocks assigned to it.

执行的基本单位是 warp 。一个warp由32个线程组成,在一个指令周期的指令周期的基础上由SM一起锁定执行。

The basic unit of execution is the warp. A warp consists of 32 threads, executed together in lockstep by an SM, on an instruction-cycle by instruction-cycle basis.

因此,即使在单个线程块中, SM通常将具有多于单个翘曲在飞行中。这对于允许机器隐藏延迟的良好性能至关重要。

Therefore, even within a single threadblock, an SM will generally have more than a single warp "in flight". This is essential for good performance to allow the machine to hide latency.

在从同一线程块中选择要执行的线程或来自不同线程块的线程之间没有概念上的区别。 SM可以具有驻留在其上的多个线程块(即,具有诸如寄存器和分配给每个驻留线程块的共享存储器的资源),并且warp调度器将从所有驻留线程块中的所有warp中选择,以选择下一个warp以用于执行任何给定的指令周期。

There is no conceptual difference between choosing warps from the same threadblock to execute, or warps from different threadblocks. SMs can have multiple threadblocks resident on them (i.e. with resources such as registers and shared memory assigned to each resident threadblock), and the warp scheduler will choose from amongst all the warps in all the resident threadblocks, to select the next warp for execution on any given instruction cycle.

因此,SM具有更多的可以是驻留的线程数,因为它可以支持多于一个块,即使该块最大地配置有线程(在这种情况下为512)。

Therefore, the SM has a greater number of threads that can be "resident" because it can support more than a single block, even if that block is maximally configured with threads (512, in this case). We utilize more than the threadblock limit by having multiple threadblocks resident.

您可能还想研究GPU程序中占用率的概念

You may also want to research the idea of occupancy in GPU programs.

这篇关于CUDA:每个多处理器和每个块的线程有多少线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆