繁体   English   中英

CUDA:每个多处理器的线程数和每个块的线程区别是什么? [重复]

[英]CUDA: What is the threads per multiprocessor and threads per block distinction? [duplicate]

这个问题在这里已有答案:

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

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

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) >

干杯,詹姆斯。

假设每次只能在每个SM上执行一个块,

这种说法从根本上说是不正确的。 除了资源冲突,并假设内核(即网格)中有足够的线程块,SM通常会分配多个线程块。

执行的基本单位是扭曲 warp由32个线程组成,由指令周期基于指令周期由SM锁定执行。

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

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

因此,SM具有更多可以“驻留”的线程,因为它可以支持多于一个块,即使该块最大程度地配置了线程(在这种情况下为512)。 我们通过使多个线程块驻留来利用超过线程块限制。

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM