Cuda NVCC设备功能中的寄存器使用情况报告
我正在尝试使用NVCC optionCuda NVCC设备功能中的寄存器使用情况报告,cuda,gpu,nvcc,ptxas,Cuda,Gpu,Nvcc,Ptxas,我正在尝试使用NVCC option--ptxas options=v获取有关CUDA内核中寄存器使用情况的信息,虽然使用全局函数一切正常,但自从 ptxas信息:已使用N个寄存器 输出中缺少行。我尝试使用noinline关键字并将它们保存在另一个文件中,与调用全局函数有关,因为我认为NVCC正在报告全局函数的完整寄存器使用情况,包括内联后被调用的设备,但没有任何更改。我只能将设备函数定义为全局函数,才能获得有关设备函数的寄存器使用情况的信息 你有什么建议吗 谢谢 据我所知,ptxas(设备汇编
--ptxas options=v
获取有关CUDA内核中寄存器使用情况的信息,虽然使用全局函数一切正常,但自从
ptxas信息:已使用N个寄存器
输出中缺少行。我尝试使用noinline关键字并将它们保存在另一个文件中,与调用全局函数有关,因为我认为NVCC正在报告全局函数的完整寄存器使用情况,包括内联后被调用的设备,但没有任何更改。我只能将设备函数定义为全局函数,才能获得有关设备函数的寄存器使用情况的信息
你有什么建议吗
谢谢 据我所知,
ptxas
(设备汇编器)只输出它链接的代码上的寄存器计数。独立的\uuuuu设备\uuuu
函数不由汇编程序链接,它们只被编译。因此,汇编程序不会为设备函数发出寄存器计数值。我不相信有解决这个问题的办法
但是,通过使用cuobjdump
从汇编程序输出转储elf数据,仍然可以获得\uuu设备
函数的寄存器占用空间。您可以按如下方式执行此操作:
$ cat vdot.cu
__device__ __noinline__ float vdot(float v1, float v2) {
return (v1 * v2);
}
__device__ __noinline__ float vdot(float2 v1, float2 v2) {
return (v1.x * v2.x) + (v1.y * v2.y);
}
__device__ __noinline__ float vdot(float4 v1, float4 v2) {
return (v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z) + (v1.w * v2.w);
}
$ nvcc -std=c++11 -arch=sm_52 -dc -Xptxas="-v" vdot.cu
ptxas info : 0 bytes gmem
ptxas info : Function properties for cudaDeviceGetAttribute
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for _Z4vdotff
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for cudaOccupancyMaxActiveBlocksPerMultiprocessor
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for _Z4vdot6float4S_
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for cudaMalloc
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for cudaGetDevice
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for _Z4vdot6float2S_
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for cudaOccupancyMaxActiveBlocksPerMultiprocessorWithFlags
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
ptxas info : Function properties for cudaFuncGetAttributes
0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads
在这里,我们在一个设备对象文件中分别编译了一组三个\uuuu device\uuu
函数。在其上运行cuobjdump
将发出大量输出,但在其中,您将获得每个函数的寄存器计数:
$ cuobjdump -elf ./vdot.o
Fatbin elf code:
================
arch = sm_52
code version = [1,7]
producer = cuda
host = linux
compile_size = 64bit
compressed
<---Snipped--->
.text._Z4vdotff
bar = 0 reg = 6 lmem=0 smem=0
0xfec007f1 0x001fc000 0x00570003 0x5c980780
0x00470000 0x5c980780 0x00370004 0x5c680000
0xffe007ff 0x001f8000 0x0007000f 0xe3200000
0xff87000f 0xe2400fff 0x00070f00 0x50b00000
$cuobjdump-elf./vdot.o
Fatbin elf代码:
================
arch=sm_52
代码版本=[1,7]
制作人=cuda
主机=linux
编译大小=64位
压缩的
.text.\u Z4vdotff
bar=0 reg=6 lmem=0 smem=0
0xfec007f1 0x001fc000 0x00570003 0x5c980780
0x00470000 0x5c980780 0x00370004 0x5c680000
0xffe007ff 0x001f8000 0x0007000f 0xe3200000
0xff87000f 0xe2400fff 0x00070f00 0x50b00000
在设备功能输出的第二行
dot(float,float)
中,您可以看到该功能使用了6个寄存器。这是我知道的检查设备功能寄存器封装外形的唯一方法。我不知道它是何时添加的,但我的CUDA 10cuobjdump
具有-res usage
标志,显示如下内容:
$ cuobjdump -res-usage .../cuda_compile_1_generated_VisualOdometry.cu.o
Fatbin elf code:
================
arch = sm_61
code version = [1,7]
producer = cuda
host = linux
compile_size = 64bit
identifier = /home/mad/automy-system/vision/src/VisualOdometry.cu
Resource usage:
Common:
GLOBAL:0 CONSTANT[3]:24
Function _Z17vo_compute_systemPfS_P6float4S_jS0_S0_f:
REG:39 STACK:32 SHARED:168 LOCAL:0 CONSTANT[0]:404 CONSTANT[2]:80 TEXTURE:0 SURFACE:0 SAMPLER:0
Function _Z13vo_pre_filterP6float4PfPjPK5uint2iijff:
REG:16 STACK:0 SHARED:8 LOCAL:0 CONSTANT[0]:372 TEXTURE:0 SURFACE:0 SAMPLER:0
我还有一个问题,与我的代码分析有关。我试图使用nvvp/nvprof,但我只获得全局函数的输出。是否有任何工具、编译标志等。。我应该使用它来获取内核调用的每个设备函数的详细分析结果?到目前为止,我提出的唯一解决方案是将设备功能更改为全局功能,并分别调用它们。你认为有更好的策略吗?cuobjdump-elf./vdot.o | c++filt怎么样?