5
votes

I am trying to profile a CUDA code that is embedded in a mex file, called from MATLAB. Running on a win7 x64 machine, 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. Test them. They work.
  2. Add exit in the end of test.m.
  3. Launch the 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
  5. Working directory: add the full path of the Matlab .m file. C:\CUDA_MATLABtests\MyToolbox
  6. Arguments: -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?

1
I think in step 4 you have to use C:\Program Files\MATLAB\R2014b\bin\win64\matlab.exe. Alternatively try to use the -wait option.Daniel
@Daniel indeed.... win64 folder, what a silly mistake. Being MATLAB already in Program Files and not in Program Files x86 I thought it was already the 64 bit version. Considern answering this.Ander Biguri

1 Answers

5
votes

A Matlab installation comes with two binaries, a launcher in <matlabroot>\bin and the main application in <matlabroot>\bin\<arch>. The later is the executable which also executes the mex functions in it's address space.

  • When a debugging tool needs to start the application directly, you have to start the one in <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. Seeing the launcher application terminating, debugging tools often stop.

Never use the binary in <matlabroot>\bin\<arch> directly unless you have to.