cuda中关于占用率的计算

简介: cuda中关于占用率的计算

官方文档CUDA C++ Best Practices Guide中提到一个例子:对于7.0的设备,每个multiprocessor有65536个寄存器,且支持最大的并发线程束为64。要想每个multiprocessor达到100%的占用率,意味着每个线程最多能使用32个寄存器。可以使用官方提供的NVIDIA GPU Computing Toolkit\CUDA\v11.1\tools目录下的CUDA_Occupancy_Calculator.xls来计算相关参数。

For purposes of calculating occupancy, the number of registers used by each thread is one of the key factors. For example, on devices of compute capability 7.0 each multiprocessor has 65,536 32-bit registers and can have a maximum of 2048 simultaneous threads resident (64 warps x 32 threads per warp). This means that in one of these devices, for a multiprocessor to have 100% occupancy, each thread can use at most 32 registers. However, this approach of determining how register count affects occupancy does not take into account the register allocation granularity. For example, on a device of compute capability 7.0, a kernel with 128- thread blocks using 37 registers per thread results in an occupancy of 75% with 12 active 128-thread blocks per multi-processor, whereas a kernel with 320-thread blocks using the same 37 registers per thread results in an occupancy of 63% because only four 320-thread blocks can reside on a multiprocessor. Furthermore, register allocations are rounded up to the nearest 256 registers per block on devices with compute capability 7.0.

  1. 如果使用128 size的线程块(每个线程使用37个寄存器),会有12个活跃线程块/SM,从而有12*4(128/32,线程束/SM) = 48活跃线程束/SM,那么占用率为48/64=75%。
  2. 如果使用320 size的线程块(每个线程使用37个寄存器),会有4个活跃线程块/SM, 从而有4*10(320/32,线程束/SM) = 40活跃线程束/SM,那么占用率为40/64=62.5%。

这里最重要的数据是每个SM上的活跃线程块,这个数值受两个方面的资源限制,一个是寄存器资源,一个是共享内存的资源。

每个线程块使用128个线程

每个线程块使用320个线程

目录
打赏
0
0
0
0
3
分享
相关文章
Jetson 学习笔记(八):htop查看CPU占用情况和jtop监控CPU和GPU
在NVIDIA Jetson平台上使用htop和jtop工具来监控CPU、GPU和内存的使用情况,并提供了安装和使用这些工具的具体命令。
357 0
|
9月前
|
详细解读CPUAffinity(CPU亲合力)
详细解读CPUAffinity(CPU亲合力)
131 0
关于cpu的一些知识
关于cpu的一些知识
124 0
CPU和指令周期
转移指令时,需要判别转移是否成功,若成功则 PC 修改为转移指令的目标地址,否则下一条指令的地址仍然为PC自增后的地址
471 1
函数计算中,您可以通过以下几种方式来查看GPU和CPU
函数计算中,您可以通过以下几种方式来查看GPU和CPU
220 0
RTX 3060 相关信息和调整CUDA的使用率
RTX 3060是一款由英伟达(NVIDIA)推出的高性能显卡,是其RTX 30系列产品线的一员。以下是一些RTX 3060的相关信息:
654 0
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等