每个线程的 Cuda 寄存器 [英] Cuda registers per thread

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

问题描述

据我了解,对于 2.x 计算能力设备,每个线程有 63 个寄存器限制.您知道计算能力为 1.3 的设备的每个线程的寄存器限制是多少吗?

As I understand correctly for the 2.x compute capability devices there's a 63 register limit per thread. Do you know which is the register limit per thread for devices of compute capability 1.3?

我有一个大内核,正在 GTX260 上进行测试.我很确定我使用了很多寄存器,因为内核非常复杂并且我需要很多局部变量.根据 Cuda 分析器,我的寄存器使用量是 63(静态 Smem 是 68,虽然我不太确定这意味着什么,动态 Smem 是 0),虽然我很确定我有超过 63 个局部变量,所以我想编译器正在重用寄存器或将它们溢出到本地内存中.

I have a big kernel which I'm testing on a GTX260. I'm pretty sure I'm using a lot of registers since the kernel is very complex and I need a lot of local variables. According to the Cuda profiler my register usage is 63 (Static Smem is 68 although I'm not so sure what that means and dynamic Smem is 0), although I'm pretty sure I have more than 63 local variables, so I figured the compiler is reusing registers or spilling them into local memory.

现在我认为计算能力 1.3 的设备每个线程的寄存器限制高于 2.x 设备.我的猜测是编译器选择了 63 个限制,因为我使用的是 256 个线程块,在这种情况下,256*63 是 16128,而 256*64 是 16384,这是该设备的 SM 的寄存器限制数量.所以我的猜测是,如果我降低每个块的线程数,我可以增加正在使用的寄存器数量.所以我用 196 个线程块运行内核.但是即使 63*192 是 12096 并且 64*192 是 12288,这在 SM 的 16384 限制之内,分析器也会再次显示 63 个寄存器.

Now I thought the devices of compute capability 1.3 had a higher limit of registers per thread than the 2.x devices. My guess was that the compiler was choosing the 63 limit because I'm using using blocks of 256 threads in which case 256*63 is 16128 while 256*64 is 16384 which is the limit number of registers for a SM of this device. So my guess was that if I lower the number of threads per block I can increase the number of registers in use. So I ran the kernel with blocks of 196 threads. But again the profiler shows 63 registers even though 63*192 is 12096 and 64*192 is 12288 which is way inside the 16384 limit of the SM.

那么知道为什么编译器仍将自身限制为 63 个寄存器吗?可能是因为寄存器重用还是仍然溢出寄存器?

So any idea why the compiler is limiting itself still to 63 registers? Could it be all because of register reuse or is it still spilling registers?

推荐答案

记录了每个线程的最大寄存器 这里

max registers per thread is documented here

cc 2.x 和 3.0 为 63,cc 1.x 为 128,cc 3.5 为 255

It is 63 for cc 2.x and 3.0, 128 for cc 1.x and 255 for cc 3.5

编译器可能已经决定 63 个寄存器就足够了,并且没有用于额外的寄存器.寄存器可以重复使用,所以你有很多局部变量,并不一定意味着每个线程的寄存器必须很高.

The compiler may have decided that 63 registers is enough, and doesn't have use for additional registers. Registers can be reused, so just because you have a lot of local variables, doesn't necessarily mean that the registers per thread has to be high.

我的建议是使用 nvcc -maxrregcount option 指定各种限制,然后使用-Xptxas -v option 拥有编译器告诉你它在创建 PTX 时使用了多少个寄存器.

My suggestion would be to use the nvcc -maxrregcount option to specify various limits, and then use the -Xptxas -v option to have the compiler tell you how many registers it is using when it creates the PTX.

这篇关于每个线程的 Cuda 寄存器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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