Analyzers
Talk to fellow users of Intel Analyzer tools (Intel VTune™ Profiler, Intel Advisor)
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
5255 Discussions

Cannot see python functions in VTune

kbhat
Novice
1,766 Views

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. 

 

 

Labels (1)
0 Kudos
5 Replies
yuzhang3_intel
Moderator
1,659 Views

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

0 Kudos
kbhat
Novice
1,588 Views

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.


0 Kudos
yuzhang3_intel
Moderator
1,582 Views

Could you provide one simple reproducer? Thanks.

0 Kudos
kbhat
Novice
1,350 Views

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

0 Kudos
yuzhang3_intel
Moderator
1,264 Views

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%

0 Kudos
Reply