Measure/Guess Execution Time of C/C++ Methods

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
rweickelt
Member++
Posts: 16
Joined: Tue Sep 02, 2014 8:38 pm

Measure/Guess Execution Time of C/C++ Methods

Post by rweickelt »

Hi,

I want to determine the execution time of some methods in a program written in C++. The program runs in the simulator.

My first attempt was xta. While this works for some methods, xta gives up in some cases.

xta script:

Code: Select all

load <binary>
analyze function <mangled-method-name>
set required - 10 ms
print summary
exit
command line

Code: Select all

>xta -source script.xta
>Route(1) function: <mangled-method-name>
    Fail (timing violation), Num Paths: 4, Violation: Unresolved, Required: 100,0 ms, Worst: Unresolved, Min Core Frequency: Unresolved
So I gave up on that. My second attempt was then, to perform a run-time analysis. I've executed xsim and run the output through gprof:

Code: Select all

>xsim --gprof --max-cycles 100000 <binary>
>xobjdump --split <binary>
>gprof image_n0c0_2.elf tile\[0\]_core0.gprof  --demangle > profile
># repeat for each core
The output looks like

Code: Select all

Each sample counts as 2e-06 milliseconds.
  %   cumulative   self              self     total           
 time milliseco  millisec    calls  um/call  um/call  name    
 47.08      0.00     0.00        1   288.13   288.13  <mangled-method-name>
What does um mean here? In comparison xta produces for the same method:

Code: Select all

Route(1) function: _ZN11Transformer15run_processDataEv
    Fail (missing loop iterations) with 36 unknowns, Num Paths: 128, Slack: 10,0 ms, Required: 10,0 ms, Worst: 4,2 us, Min Core Frequency: 0 MHz
Since this method calls a xc-method which then transfers data via an xlink channel, it would make sense, if the profiled time is much higher than the estimated time. But I'm confused, if um in the gprof output means microseconds. Does anybody know?


User avatar
segher
XCore Expert
Posts: 844
Joined: Sun Jul 11, 2010 1:31 am

Post by segher »

"milliseconds" and "m" are taken from the gmon file (the
gprof input file); they are the name of the unit the histogram
is counted in, and its abbreviation. "um" means a millionth
of that unit, a micro-millisecond, that is a nanosecond.

No idea why xsim uses such a strange unit, but there you
have it :-)
User avatar
rweickelt
Member++
Posts: 16
Joined: Tue Sep 02, 2014 8:38 pm

Post by rweickelt »

Thank You. Indeed very strange.