提高指令级并行性 使用共享内存(shared memory)减少全局内存访问 合理分配寄存器,避免寄存器溢出 使用 PTX 的特殊指令优化热点代码 四、将 PTX 转换为机器代码 使用 ptxas 工具 NVIDIA 提供的 ptxas 工具可以将 PTX 代码编译为特定 GPU 架构的机器代码。 例如: ptxas my_kernel.ptx -o my_kernel.o -gencode arch=compute_86,code=sm_86 这里,-gencode
continue using __ballot(), specify virtual architecture compute_60 when targeting sm_70 and above ptxas Instruction 'vote' without '.sync' may produce unpredictable results on sm_70 and later architectures ptxas
include/python2.7 -c nms/nms_kernel.cu -o build/temp.linux-x86_64-2.7/nms/nms_kernel.o -arch=sm_35 –ptxas-options =-v -c –compiler-options ‘-fPIC’ ptxas info : 0 bytes gmem ptxas info : Compiling entry function ‘_Z10nms_kernelifPKfPy’ for ‘sm_35’ ptxas info : Function properties for _Z10nms_kernelifPKfPy 0 bytes stack frame, 0 bytes spill stores, 0 bytes spill loads ptxas info : Used 25 registers
编译器ptxas会把所有调度决策直接编译进二进制,硬件拿到就按写好的流程跑。 AMD 指令只有32 位或 64 位,不带任何调度信息。 五、编译器:闭源黑盒 vs 开源透明 NVIDIA ptxas 编译器完全闭源。 延迟表、调度策略都是商业机密,你看不到它对你的代码做了什么。 AMD 整套编译器基于开源 LLVM。
同时,可以在build目录下去检查对应的三个bin tool: triton-opt, triton-reduce, triton-translate 然后将本机下的ptxas复制到该build目录下, 我的ptxas在(/usr/local/cuda-11.6/bin)下。
deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning). ptxas warning : For profile sm_86 adjusting per thread register count of 16 to lower bound of 24 ptxas warning : For profile sm_75 adjusting per thread register count of 16 to lower bound of 24 ptxas warning : For profile sm_70 adjusting per thread register count of 16 to lower bound of 24 ptxas warning : For profile
答复:将选项“--ptxas-options=-v”添加到nvcc命令行。编译时,这些信息将输出到控制台。 12 问:CUDA kernel的最大长度是多少?
GPU 后端现在使用 ptxas 以编译生成的 PTX。 BufferAssignment 的协议缓存转储(protocol buffer dump)现在已确定。
Also, the compiler reports total local memory usage per kernel (lmem) when compiling with the --ptxas-options 本章节还提到了cuobjdump以及, 编译时刻的--ptxas-options=v参数, 这些都很有用.
GPU后端现在使用ptxas编译生成的PTX。 BufferAssignment的协议缓冲区转储现在是确定性的。 将嵌入操作更改为使用DynamicStitch的并行版本。
还能使用–ptxas-options=-v这个选项来看Local到底用了多少。 9.2.4.
Wno-unused-function"], 'nvcc': ['-arch=sm_52', '--ptxas-options
Register usage is reported by the --ptxas options=-v compiler option.
而这些是手册不说的,本表格是直接的一手信息来源(NV),使用该表格需要知道一些信息,例如kernel使用了多少寄存器,这个信息可以在编译的时候通过ptxas的详细输出得到,手册的后面会提到如何得到这个信息
cuobjdump nsys nvlink ptxas
Register and shared memory usage are reported by the compiler when compiling with the -ptxas-options=
从 CUDA 12.4 开始,-pic当编译模式为整个程序编译时,PTXAS 默认启用位置无关代码 ( )。-pic=false用户可以通过指定PTXAS 选项来选择退出。
关于 Occupancy 的计算我们可以通过在编译时添加 --ptxas-options=-v 参数,使编译器在编译时输出每个 kernel 所花费的寄存器数量和 shared memory,然后通过随