使用 NVIDIA 可视化分析器分析 MATLAB mex CUDA 应用程序

Profiling MATLAB mex CUDA applications with the NVIDIA visual profiler

我正在尝试分析嵌入在从 MATLAB 调用的 mex 文件中的 CUDA 代码。 运行 在 win7 x64 机器上,MATLAB r2014b

代码结构如下:

 MATLAB   test.m
    ->contains some standard code generating variables (and calling 1 or 2 minor own MATLAB fucntions)
    -> calls testcuda.mex
        ->contains small, standard, no library C++ code
        -> calls either test1.cu or test2.cu
              ->.cu files end in cudaDeviceReset();
           

我按照网上several places的说法做了以下操作:

  1. 已编译的 mex 文件。测试它们。他们工作。
  2. 在test.m末尾添加exit
  3. 启动 NVIDIA Visual Profiler。文件 -> 新会话。
  4. 添加Matlab可执行文件的完整路径,例如C:\Program Files\MATLAB\R2014b\bin\matlab.exe
  5. 工作目录:添加Matlab.m文件的完整路径。 C:\CUDA_MATLABtests\MyToolbox
  6. 参数:-nojvm -nosplash -r test

然而,当我 运行 分析器时,我得到

======== Warning: No CUDA application was profiled, exiting

仅此而已。

我缺少一些说明?

是否有任何特定的代码结构会使探查器无法进行探查?

Matlab 安装附带两个二进制文件,<matlabroot>\bin 中的启动器和 <matlabroot>\bin\<arch> 中的主应用程序。后者是可执行文件,它还在其地址 space.

中执行 mex 函数
  • 当调试工具需要直接启动应用程序时,您必须启动<matlabroot>\bin\<arch>中的那个。
  • 当调试工具也自动附加到子进程时,通常在 <matlabroot>\bin 中设置 -wait 参数来启动二进制文件就足够了。看到启动器应用程序终止,调试工具经常停止。

切勿直接使用 <matlabroot>\bin\<arch> 中的二进制文件,除非万不得已。