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

Performance analysis of C/C++ application which executes via Python as an extension

Saeed_S_
Beginner
519 Views

Hi all,

I want to analyse a C++ application which compiled as a Python extension. A Python script feeds data and executes the application. I am wondering how can I analyse the C++ module via Inspector. 

For example, I had the same issue with GDB in Eclipse, but when I made another application which executes the Python file from C++, it can get the breakpoint, when the control goes to Python and turns to the extension. But, this trick is not working for Inspector.

I appreciate any clue.

Thanks,

0 Kudos
7 Replies
Peter_W_Intel
Employee
519 Views

Inspector XE can only monitor one (target) process, cannot monitor multiple process. In general speaking, target process is launching process, but some cases it is not. If you use python to launch application, I suppose to use:

 "inspxe-cl -collect mi3 -executable-of-interest c++application -- python script.py" - for example. Also you can filter all non-interest of module like this, "inspxe-cl -collect mi3  -module-filter-mode=include -module-filter=c++module -executable-of-interest c++application -- python script.py" . Thus, only your interest of module in C++ application will be monitored.

For debugging to stop when meet errors detected by Inspector, use:

"inspxe-cl -collect mi3 -appdebug=on-error -executable-of-interest c++application -- python script.py" - for example.

 

0 Kudos
Saeed_S_
Beginner
519 Views

Thank you Peter, 

I have tried as you described, but it seems that collector can not gather information. I have tried to change some parameters and in any case I see the below error message:

Error: Cannot find analysis results. Suggestion: Make sure that the application launched your executable of interest c++application.

I do not know what is the reason. Do you think the python should support something to let the Inspector get information?

0 Kudos
Peter_W_Intel
Employee
519 Views

It seemed a real problem when I used python to launch. My test cases are simple: 

1. a.py

import os

os.system("./test_memory")

# inspxe-cl -collect mi3 -executable-of-interest test_memory -- python a.py

Error: Cannot find analysis results. Suggestion: Make sure that application launched your executable of interest test_memory

However, shell script works and it generated expected result.

2. a.sh

#inspxe-cl -collect mi3 -executable-of-interest test_memory -- ./a.sh

So using shell script is a workaround, let me check with developer to know if this is a limitation.

 

0 Kudos
Peter_W_Intel
Employee
519 Views

The developer told me a workaround, that is to use the subprocess module instead of using os.system, for example:

c.py:

import subprocess

subprocess.call("./test_memory") 

0 Kudos
Peter_W_Intel
Employee
519 Views

The root-cause is that launched python script and target application should stay same layer of shell.

For example, b.sh - doesn't work when using Inspector.

#!/bin/sh
./test_memory

 

"#!/bin/sh" should be removed as a workaround. 

 

0 Kudos
Peter_W_Intel
Employee
519 Views

This issue will be completely fixed in future release, I mean Inspector XE 2015 Update 1 or later.

Please put your feedback, if you still see this problem then.

0 Kudos
Saeed_S_
Beginner
519 Views

Dear Peter Wang,

Thank you for the information. Very good news. I'm going to have a look.

0 Kudos
Reply