Profiling

Technical questions regarding the XTC tools and programming with XMOS.
Mahagon
Member++
Posts: 24
Joined: Thu Mar 07, 2013 4:24 pm

Profiling

Post by Mahagon »

Hello,

I want to use GPROF for my programm with xTimeComposer. How can i compile with it? Adding the "-pg" option doesnt create my out file. And setting "Enable GPROF Collection" in Run Configurations also doesn't (well, thats quiet clear, because first i have to compile with -pg).

Sadly there's actually nothing about profiling at the xTime Guides and so on; and also not much in the Forum, so i ask you :)

Greetings


User avatar
kris
Experienced Member
Posts: 84
Joined: Mon Jan 18, 2010 2:52 pm

Post by kris »

Hi,

Currently there is no need to compile with the -pg option in order to use gprof. This is because when running on the hardware, the pc sampling is done by xgdb via xtag, thus there is no need to change the binary (making it non-intrusive). However, this only provides the flat gprof profile, i.e. the call graph info is not available.

If running on the simulator however, then the call graph info is also available, as the simulator can (also non-intrusively) log this info in the background.

Note: There are a couple of profiling document/examples available in the xSOFTip Browser view of the xTIMEcomposer:

"How to profile an executable on the hardware"
"How to profile an executable on the simulator"

Hope this helps,
Cheers,
Kris.
Mahagon
Member++
Posts: 24
Joined: Thu Mar 07, 2013 4:24 pm

Post by Mahagon »

Hi Kris,

Thanks for your answer. Actually the Tutorials just explain me the exact things i've already done in my own project. But why there are Profiling Files generated in the Tutorial, but not in my project? Hm, at the moment i have no answer for this^^

Edit: Hm OK, if i run my project on the simulator, some gprofs Files are generated, but actually they cant be correct. Hm

Edit2: Ah ok interesting, the reason was using Xscope. Maybe that was obvious or is intended, but gprof does not work if using Xscope (used it in offline mode). But the gprof files still does not show correct results. They only say that my main function is processed 100% of the time (on hardware and on simulator) ... but that is not true^^ Im sure that my program runs other functions, for example to make the LEDs blinking and so on.

Is it possible that this does not work with .c Files (my main project is written in C) ? If im using it on an XC Project, the Files are generated and seems to be showing correct results.
User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

In a simple program it is likely that everything got inlined into
main(). Disable inlining if you want to see a profile with the
functions as you wrote them; that can in some cases be
misleading though, for example a one-line function that gets
called a lot will show a higher percentage time than it actually
costs when inlined.