Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
5130 Discussions

Vtune to profile a library called by a mex file

Rohit_G_1
Beginner
1,173 Views

Hi All

 

I have a matlab script that launches a mex function which calls a library which I wish to profile. As of now I am running MATLAB on the login node of my HPC cluster and would ultimately like to run this on one of the compute nodes. My platform is linux 64 bit throughout running on Intel's broadwell processors [all the compute and login nodes are broadwells].

I have previously worked with applications compiled in linux that could be profile by submitting pbspro execute commands in a script and queued using pbspro. However, I am not aware how I can profile the library (a specific function in the library) from inside of matlab.

Can someone comment on if this is possible? Specifically,

1. How to launch the script form inside of matlab when I issue the amplxe-cl command in my pbspro script?

2. Since I wish to profile a specific function inside the library can i attach some kind of API that is like a entry and exit point from where profiling begins and ends? Vtune can listen to the entire process  and then start collecting as soon as it notices the entry and exit points of the profiling API?

Kindly advise.

Rohit

 

0 Kudos
5 Replies
Shailen_Sobhee
Employee
1,173 Views

Hi Rohit,

I have not tried the following since I do not have Matlab installed but I can attempt to give you some hints for you to try and update the community.

First, is your MEX build in C/C++ or Fortran? The mex calls a library that you have coded - how are you doing so? Using callib/loadllibrary?

What you could try is have a look at the VTune Instrumentation and tracing technology (ITT) APIs (link: here) in your library that you coded. Then tell Matlab to launch the MEX file (assuming it is a standalone binary that can execute with the MATLAB engine running). Again, not having Matlab, I cannot guarantee that this will work, but it is worth having a look.

Here is a code snippet with the ITT API in action (for a C++ file):

#include <ittnotify.h>
[...]
void my_function()
{
// Now resume data collecting
__itt_resume();

my_big_computation();

// Pasue data collecting again
__itt_pause();
}

For the above, you need to make sure you are linking statically to the libittnotify.a file located in the lib folder where VTune Amplifier has been installed.

0 Kudos
Rohit_G_1
Beginner
1,173 Views

Hi Shailen

Thanks for your response. I will try to check this out. We are also working on a strategy to profile only C++ code.

The mex library is built using gcc. The file from which the mex file is generated is C code.

The library is called using loadlibrary. 

0 Kudos
Shailen_Sobhee
Employee
1,173 Views

Rohit, do you have an update for us? Were you able to have a look at the ITT APIs? 

0 Kudos
Rohit_G_1
Beginner
1,173 Views

Hi Shailen

I am trying to setup the remote node I have to work with (to  profile). However, while setting up vTune i noticed I do not have all the dependencies taken care of. I am going to fix that first.

Moreover I am also inclined now to NOT use matlab during profiling but instead use Vtune to talk to my compute nodes directly (through SSH). Nonetheless, this doesn't mean I won't use the ITT api because I think that really gives me fine control. It is just going to be my second approach after I try the remote profiling in Vtune.

If you want to close this thread please do not consider my input blocking. I'll need few days to finish the remote profiling task I have taken up and then I would i try the ITT api.

with kind regards

Rohit

 

0 Kudos
Shailen_Sobhee
Employee
1,173 Views

Hi Rohit,

Sure! Go ahead and play around - I know this stuff is fun :) Did you manage to fix the dependencies? What kind of dependency issues did you encounter? Did you have warnings while installing VTune (like unsupported OS etc.? )

Make sure you set up a password-less SSH connection to all your nodes so that VTune is able to properly communicate to these nodes. Also, make sure that the remote bash from the nodes do not output any data, as VTune relies on SCP to transfer data, and SCP fails to work when a remote bash outputs some text (known SCP bug).

Anyway, keep us updated how the process goes and do not hesitate to contact us if you encounter any issues.

Regards,

Shailen

0 Kudos
Reply