【发布时间】:2012-09-23 14:47:06
【问题描述】:
一段时间以来,我一直在为一个似乎找不到解决方案的问题苦苦挣扎。 问题是当我尝试在 Visual Studio 2008 下使用 Nvidia Nsight 调试我的 CUDA 代码时,使用共享内存时会得到奇怪的结果。
我的代码是:
template<typename T>
__device__
T integrate()
{
extern __shared__ T s_test[]; // Dynamically allocated shared memory
/**** Breakpoint (1) here ****/
int index = threadIdx.x + threadIdx.y * blockDim.x; // Local index in block. Column major ordering
if(index < 64 && blockIdx.x==0) { // Only work on a few values. Just testing
s_test[index] = (T)index;
/* Some other irelevant code here */
}
return v;
}
当我到达断点 1 并检查 Visual Studio Watch 窗口中的共享内存时,只有数组的前 8 个值发生变化,其他值保持为空。我希望所有前 64 人都这样做。
我认为这可能与所有经线没有同时执行有关。所以我尝试同步它们。我在integrate()中添加了这段代码
template<typename T>
__device__
T integrate()
{
/* Old code is still here */
__syncthreads();
/**** Breakpoint (2) here ****/
if(index < 64 && blockIdx.x==0) {
T tmp = s_test[index]; // Write to tmp variable so I can inspect it inside Nsight Watch window
v = tmp + index; // Use `tmp` and `index` somehow so that the compiler doesn't optimize it out of existence
}
return v;
}
但问题仍然存在。此外,tmp 中的其余值不是0,正如监视窗口窗体 VS 所指示的那样。
我必须提到,跨越__syncthreads()需要很多步骤,所以当我到达它时,我只是跳到断点2。到底是怎么回事!?
编辑有关系统/启动配置的信息
系统
- 名称 Intel(R) Core(TM)2 Duo CPU E7300 @ 2.66GHz
- 架构 x86
- 频率 2.666 MHz
- 核心数 2
- 页面大小 4.096
- 总物理内存 3.582,00 MB
- 可用物理内存 1.983,00 MB
- 版本名称 Windows 7 Ultimate
- 版本号 6.1.7600
设备 GeForce 9500 GT
- 驱动程序版本 301.42
- 驱动模型 WDDM
- CUDA 设备索引 0
- GPU 系列 G96
- 计算能力 1.1
- SM 数量 4
- 帧缓冲区物理大小 (MB) 512
- 帧缓冲带宽 (GB/s) 16
- 帧缓冲区总线宽度(位)128
- 帧缓冲区位置专用
- 图形时钟 (Mhz) 812
- 内存时钟 (Mhz) 500
- 处理器时钟 (Mhz) 1625
- 内存类型 DDR2
IDE
- Microsoft Visual Studio 团队系统 2008
- NVIDIA Nsight Visual Studio 版,版本 2.2 内部版本号 2.2.0.12255
编译器命令
1> "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin\nvcc.exe" -G -gencode=arch=compute_10,code=\"sm_10,compute_10\" --machine 32 -ccbin "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin" -D_NEXUS_DEBUG -g -D_DEBUG -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd "-I"inc" -I "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\include" -maxrregcount=0 --compile -o "Debug/process_f2f.cu.obj" process_f2f.cu
启动配置。共享内存大小似乎并不重要。我试过几个版本。我合作最多的一个是:
- 共享内存 2048 字节
- 网格/块大小:{101、101、1}、{16、16、1}
【问题讨论】:
-
能否提供设备信息、nsight 版本、驱动版本、启动尺寸和动态共享内存大小?如果您提供完整的可重现性,包括编译器开关,那么团队可以调查该问题。
-
我已经添加了所有信息。非常感谢您的帮助。
-
@Iam,我无法重现这个问题。你介意和我联系吗?您可以通过 nvidia dot com 的 devtools-support 向我发送电子邮件。谢谢!
-
我投票决定将此问题作为离题结束,因为该问题无法重现,并且似乎已经变成了与供应商的 Stack Overflow 错误报告
标签: debugging cuda shared-memory nsight