代码检查:内存空间局部变量必须为 'extern' 或 'static'
此检查会报告使用 CUDA 内存空间说明符 __device__、 __constant__、 __managed__ 或 __tile__ 之一声明的自动局部变量。 带有这些说明符的局部变量需要为 extern 或 static。
示例
__device__ void process()
{
__device__ int cache;
}
__device__ void process()
{
static __device__ int cache;
}
如果需要在设备代码中由块的所有线程共享的局部变量,请使用 __shared__。
2026年 11月 6日