技术开发 频道

使用CUDA profiler探索全局存储器

  配置结果

  让我们使用profiler看一下reverseArray_multiblock.cu和reverseArray_multiblock_fast.cu。在本例中,我们将在Linux下的bash shell中对环境变量和配置文件进行如下设置:

  export CUDA_PROFILE=1

  export CUDA_PROFILE_CONFIG=$HOME/.cuda_profile_config

  在Linux下使用bash比较Profiler配置与环境变量

  gld_coherent

  gld_incoherent

  gst_coherent

  gst_incoherent

  CUDA_PROFILE_CONFIG文件的内容

  运行reverseArray_multiblock.cu可执行文件,在./cuda_profile.log中生成以下配置报告:

  method,gputime,cputime,occupancy,gld_incoherent,gld_coherent,gst_incoherent,gst_coherent

  method=[ memcopy ] gputime=[ 438.432 ]

  method=[ _Z17reverseArrayBlockPiS_ ] gputime=[ 267.520 ] cputime=[ 297.000 ] occupancy=[ 1.000 ] gld_incoherent=[ 0 ] gld_coherent=[ 1952 ] gst_incoherent=[ 62464 ] gst_coherent=[ 0 ]

  method=[ memcopy ] gputime=[ 349.344 ]

  reverseArray_multiblock.cu配置报告

  类似地,运行reverseArray_multiblock_fast.cu可执行文件生成以下输出,这些输出会覆盖.cuda_profile.log中以前的输出。

  method,gputime,cputime,occupancy,gld_incoherent,gld_coherent,gst_incoherent,gst_coherent

  method=[ memcopy ] gputime=[ 449.600 ]

  method=[ _Z17reverseArrayBlockPiS_ ] gputime=[ 50.464 ] cputime=[ 108.000 ] occupancy=[ 1.000 ] gld_incoherent=[ 0 ] gld_coherent=[ 2032 ] gst_incoherent=[ 0 ] gst_coherent=[ 8128 ]

  method=[ memcopy ] gputime=[ 509.984 ]

  reverseArray_multiblock_fast.cu配置报告

  比较这两个配置结果可以发现,reverseArray_multiblock_fast.cu不包含不连贯的存储,而reverseArray_multiblock.cu却相反,它包含很多不连贯存储。看一下reverseArray_multiblock.cu的源,并看一下是否可以修复不连贯存储的性能问题。修复之后,测量一下这两个程序彼此的相对速度。

  为了方便比较,将reverseArray_multiblock.cu和reverseArray_multiblock_fast.cu的清单列在下面:

  <在此处插入reverseArray_multiblock.cu>

  reverseArray_multiblock.cu源

  <在此处插入reverseArray_multiblock_fast.cu>

  reverseArray_multiblock_fast.cu源

0
相关文章