简体   繁体   English

使用NVIDIA Visual Profiler对MATLAB mex CUDA应用程序进行性能分析

[英]Profiling MATLAB mex CUDA applications with the NVIDIA visual profiler

I am trying to profile a CUDA code that is embedded in a mex file, called from MATLAB. 我正在尝试分析嵌入在从MATLAB调用的mex文件中的CUDA代码。 Running on a win7 x64 machine, MATLAB r2014b 在Win7 x64计算机上运行,​​MATLAB R2014B

The code is structured as follows: 该代码的结构如下:

 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();

I did the following, as stated in several places on the internet: 正如互联网上多个地方所述,我做了以下工作:

  1. Compiled mex files. 编译的mex文件。 Test them. 测试他们。 They work. 他们工作。
  2. Add exit in the end of test.m. 在test.m的末尾添加exit
  3. Launch the NVIDIA Visual Profiler. 启动NVIDIA Visual Profiler。 File -> New Session. 文件->新会话。
  4. add the full path of the Matlab executable file, for example C:\\Program Files\\MATLAB\\R2014b\\bin\\matlab.exe 添加Matlab可执行文件的完整路径,例如C:\\Program Files\\MATLAB\\R2014b\\bin\\matlab.exe
  5. Working directory: add the full path of the Matlab .m file. 工作目录:添加Matlab .m文件的完整路径。 C:\\CUDA_MATLABtests\\MyToolbox
  6. Arguments: -nojvm -nosplash -r test 参数: -nojvm -nosplash -r test

However, when I run the profiler,I get 但是,当我运行探查器时,我得到

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

And nothing more. 仅此而已。

I am missing some instruction? 我缺少指导吗?

Is there any particular code structure that would make the profiler not to profile? 是否有任何特定的代码结构会使分析器无法进行分析?

A Matlab installation comes with two binaries, a launcher in <matlabroot>\\bin and the main application in <matlabroot>\\bin\\<arch> . Matlab安装附带两个二进制文件,一个是<matlabroot>\\bin的启动器,另一个是<matlabroot>\\bin\\<arch>的主应用程序。 The later is the executable which also executes the mex functions in it's address space. 后者是可执行文件,它还在其地址空间中执行mex函数。

  • When a debugging tool needs to start the application directly, you have to start the one in <matlabroot>\\bin\\<arch> . 当调试工具需要直接启动应用程序时,您必须在<matlabroot>\\bin\\<arch>启动一个。
  • When a debugging tool automatically attaches to child processes as well, it is typically sufficient to start the binary in <matlabroot>\\bin setting the -wait parameter. 当调试工具也自动附加到子进程时,通常只需在<matlabroot>\\bin设置-wait参数即可启动二进制文件。 Seeing the launcher application terminating, debugging tools often stop. 看到启动器应用程序终止,调试工具通常会停止。

Never use the binary in <matlabroot>\\bin\\<arch> directly unless you have to. 除非必须,否则请勿直接在<matlabroot>\\bin\\<arch>使用二进制文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM