- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have a setup where I have c++ class which is exported to python using c++ boost library. I have python wrapper script that calls these boost functions which in turn call c++ functions.
I have an executable applicaion that takes the python script as an argument. I intend to analyse the python script using vtune. So I set application as my application executable and the python script as the application parameters. I specify the search directories correctly. But I dont see python function names in the hotspot analysis. Instead I see boost wrappers with C++ function handles. I need to profile both python and c++ functions becuase there are some python functions that are standalone and do not use c++ internally. How do I achieve this? I use linux as my OS.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Did you try to specify the mrte mode to mixed as below? And you can simplify your application to reproduce the issue.
vtune -collect hotspots -mrte-mode=mixed xxxxx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @yuzhang3_intel,
Though I can see some python files, I don't see all the python files. Besides, the python function names are replaced by <module> placeholder. Please note, If I profile a standalone python project, then I can see all the function names. But if I use a setup were C++ functions/Classes are exported to python using boost c++ library, then I face the issue highlighted above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Could you provide one simple reproducer? Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please compile the c++ code using the below command and run the python file.
Make sure to install boost python libraries and make sure to include the right include and lib paths.
g++ -shared -fPIC -I/usr/include/python3.8 -I/usr/include/boost example.cpp -o example.so -lboost_python3.8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for providing the reproducer. I just added one more zero in your source code below. You can see VTune can profile Python code.
23 # Call the Python function
24 start_time = time.time()
25 square_sum = sum_of_squares(100000000) # You can adjust this limit if it runs too fast
yuzhang3@yuzhang3-10710:~/workspace/isvc_jira_ips/python_wraper$ vtune -collect hotspots python ./sample.py
.........
Top Hotspots
Function Module CPU Time % of CPU Time(%)
------------------- ---------- -------- ----------------
is_prime example.so 38.556s 83.6%
sum_of_squares sample.py 2.548s 5.5%
PyNumber_InPlaceAdd python3.10 1.602s 3.5%
PyNumber_Multiply python3.10 1.332s 2.9%
func@0x15e224 python3.10 0.884s 1.9%
[Others] N/A 1.218s 2.6%

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page