如何禁用有关无法确定堆栈大小的 ptxas 警告?

How can I disable the ptxas warning about indeterminable stack size?

在编译CUDA设备代码时,可能会报错(换行以方便阅读):

ptxas warning : Stack size for entry function '_ZN7kernels11print_stuffIiEEvv' 
cannot be statically determined

这可以 several reasons, like dynamic memory allocation or use of recursion, but those don't matter right now. I want to disable the warning, within some function at least. The thing is, I don't know which token to use to do so. It's no use searching this list (following the suggestion here SO 关于禁用特定警告)- 因为这些是 NVCC 的 C/C++ 前端中的警告,而不是汇编器中的警告。

那么我如何禁用此警告?

需要注意的重要一点是,这是一个 汇编程序 警告,因此 none 通常的前端警告抑制选项是相关的。

ptxas 仅支持非常有限的警告控制选项。在 CUDA 9 之前,仅支持以下内容:

--suppress-double-demote-warning                    (-suppress-double-demote-warning)
        Suppress the warning that is otherwise emitted when a double precision instruction
        is encountered in PTX that is targeted for an SM version that does not have
        double precision support

--disable-warnings                                  (-w)                        
        Inhibit all warning messages.

--warn-on-double-precision-use                      (-warn-double-usage)        
        Warning if double(s) are used in an instruction.

--warn-on-local-memory-usage                        (-warn-lmem-usage)          
        Warning if local memory is used.

--warn-on-spills                                    (-warn-spills)              
        Warning if registers are spilled to local memory.

--warning-as-error                                  (-Werror)                   
        Make all warnings into errors.

在你的情况下,唯一的选择是禁止显示所有警告。将 -Xptxas='-w' 添加到任何 nvcc 调用应该可以实现这一点。

CUDA 9 和更新版本添加了另一个选项 ptxas 来抑制您询问的警告:

--suppress-stack-size-warning                       (-suppress-stack-size-warning)
        Suppress the warning that otherwise is printed when stack size cannot be
        determined.

在这种情况下,将 -Xptxas='-suppress-stack-size-warning' 添加到任何 nvcc 调用应该消除警告。