CUDA无法在Nsight调试中看到共享内存值

时间:2012-10-02 17:50:11

标签: debugging cuda shared-memory nsight

我一直在努力解决一个我似乎无法找到解决方案的问题。 问题是,当我尝试在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名都这样做。 Watch window from Visual Studio

我认为它可能与所有不同时执行的warp有关。所以我尝试了同步它们。我在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指示。 Watch window from Nsight

我必须提到跨步__syncthreads()需要很多步骤,所以当我到达它时,我只是跳到断点2.发生什么事了!?


编辑有关系统/启动配置的信息

系统

  • 命名Intel(R)Core(TM)2 Duo CPU E7300 @ 2.66GHz
  • Architecture 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
  • Compute Capability 1.1
  • SM数量4
  • 帧缓冲区物理大小(MB)512
  • 帧缓冲带宽(GB / s)16
  • 帧缓冲总线宽度(位)128
  • Frame Buffer Location Dedicated
  • 图形时钟(Mhz)812
  • 内存时钟(Mhz)500
  • 处理器时钟(Mhz)1625
  • RAM类型DDR2

IDE

  • Microsoft Visual Studio Team System 2008
  • NVIDIA Nsight Visual Studio Edition,2.2版本号2.2.0.12255

编译器命令

1&GT; “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}

1 个答案:

答案 0 :(得分:1)

您在分配值后是否尝试过 __ syncthreads()

template<typename T>
__device__
T integrate()
{
   extern __shared__ T s_test[]; // Dynamically allocated shared memory
   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 */
   }
   __syncthreads();
   /**** Breakpoint (1) here ****/
   return v;
}

尝试在此断点处查看值。