Tutorial - How To Generate A Call Graph Using xSIM and gprof

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
johned
XCore Addict
Posts: 185
Joined: Tue Mar 26, 2013 12:10 pm

Tutorial - How To Generate A Call Graph Using xSIM and gprof

Post by johned »

The combination of xSIM and gprof provides a powerful combination for analyzing the runtime performance of an application.

Notes :
gprof2dot (https://github.com/jrfonseca/gprof2dot) is a python application. I downloaded the zip and extracted to the folders :

Code: Select all

Windows : %HOMEPATH%\python\
Linux : ~/python/gprof2dot
You may wish to change this path to suit.
XCORE-200-EXPLORER.xn can be found in the xTIMEcomposer targets folder.
When you run the xsim command, hit <ctrl>-C after a few seconds to halt the simulation.

The attached example can be analyzed using the following commands :

Windows

Code: Select all

xcc SimpleTimerBiDi.xc XCORE-200-EXPLORER.xn -o SimpleTimerBiDi.xe
xsim --gprof SimpleTimerBiDi.xe
xobjdump --split SimpleTimerBiDi.xe
xgprof image_n0c0_2.elf tile[0]_core0.gprof | python %HOMEPATH%\python\gprof2dot\gprof2dot.py > SimpleTimerBiDi.dot
dot -Tpng -oSimpleTimerBiDi.png SimpleTimerBiDi.dot
Linux

Code: Select all

xcc SimpleTimerBiDi.xc XCORE-200-EXPLORER.xn -o SimpleTimerBiDi.xe
xsim --gprof SimpleTimerBiDi.xe
xobjdump --split SimpleTimerBiDi.xe
xgprof image_n0c0_2.elf tile\[0\]_core0.gprof | ~/python/gprof2dot/gprof2dot.py > SimpleTimerBiDi.dot
dot -Tpng -oSimpleTimerBiDi.png SimpleTimerBiDi.dot
You will now see the call graph in the file : SimpleTimerBiDi.png.
You do not have the required permissions to view the files attached to this post.
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

Hi John,

Really helpful to share this. Would you mind adding the .png output as well so that people can see what they might expect if they follow these steps. Thanks.

Also, if anyone is interested in having absolute times in their output I've found a way of tweaking gprof2dot to do it. I've added a comment on how to get absolute times here

Peter
User avatar
johned
XCore Addict
Posts: 185
Joined: Tue Mar 26, 2013 12:10 pm

Post by johned »

Here's the png

Cheers,
John
You do not have the required permissions to view the files attached to this post.
peter
XCore Addict
Posts: 230
Joined: Wed Mar 10, 2010 12:46 pm

Post by peter »

I've produced a very basic test application:

Code: Select all

int main()
{
  double x = 1.2;
  double y = 1.5;
  double z = 19.5;
  for (unsigned i = 0; i < 100; i++) {
    y *= x;
    z += y;
  }

  return (y+z < 100.0) ? 0 : 1;
}
and produced the call graph.
You do not have the required permissions to view the files attached to this post.