0

This is an old problem as is demonstrated as in https://community.intel.com/t5/Analyzers/Unable-to-view-source-code-when-analyzing-results/td-p/1153210. I have tried all the listed methods, none of them works, and I cannot find any more solutions on the internet. Basically vtune cannot find the custom python source file no matter what is tried. I am using the most recently version as of speaking. Please let me whether there is a solution.

For example, if you run the following program.

def myfunc(*args):
    # Do a lot of things. 

if __name__ = '__main__':
    # Do something and call myfunc

Call this script main.py. Now use the newest vtune version (I have using Ubuntu 18.04), run the vtune-gui and basic hotspot analysis. You will not found any information on this file. However, a huge pile of information on Python and its other codes are found (related to your python environment). In theory, you should be able to find the source of main.py as well as cost on each line in that script. However, that is simply not happening.

Desired behavior: I would really like to find the source file and function in the top-down manual (or any really). Any advice is welcome.

Peter Cordes
  • 286,368
  • 41
  • 520
  • 731
RanWang
  • 107
  • 5
  • CPython is an interpreter. The CPU is never running machine code compiled from this source file, only ever machine code ahead-of-time compiled from CPython's C source files. Your program is *data* in the interpreter. If you want info about time spent by Python function, you need a Python profiler ([How can you profile a Python script?](https://stackoverflow.com/q/582336)), not VTune profiling the Python interpreter as it runs your program. There's no way for VTune to look inside the Python interpreter and know which Python function / line it's on when a perf event fires. – Peter Cordes Dec 26 '20 at 07:38
  • So basically no, you shouldn't be able to find perf samples for `main.py` because it's not running on the CPU, it's just data for another program. – Peter Cordes Dec 26 '20 at 07:39
  • 1
    @PeterCordes If you search Intel Vtune website with the keyword python, they always show that it can profile and find the python file. It also mentions that they can profile mixed language, which includes python. – RanWang Dec 28 '20 at 15:45
  • Ok, maybe I assumed wrong, and VTune can hook into the Python implementation. I haven't used VTune, just simpler tools like Linux `perf` that only do perf counters. Did you check that it's supposed to work with CPython, not a Python implementation like PyPy that JITs to machine code? – Peter Cordes Dec 28 '20 at 22:54
  • @PeterCordes Yes, it actually can only work with CPython. I should all the CPython details except for what I care about. Very peculiar taste indeed. – RanWang Dec 29 '20 at 17:05

0 Answers0