On 10/15/07, Jeremy Larsen <[EMAIL PROTECTED]> wrote:
>
>  I am implementing some video codecs on the DSP and need to get some timing
> measurements on specific areas of the code.  What can I use for this
> measurement?
>
>  Thanks,
>  Jeremy Larsen

I've used STS objects (from DSP/BIOS) to collect timing measurements.

Following the template given in the codec engine examples, here is
what I've done:

1) Edit servers/myserver/myserver.tcf and add one or more stanzas that
look like:

var stsTime0       = bios.STS.create("stsTime0");
stsTime0.comment   = "STS object 0 for execution time measurements";
stsTime0.unitType  = "High resolution time based";
stsTime0.operation = "A * x";

(Note that if you want more than one of these, you could create them
in a loop, or, as I did, copy and paste and change all the stsTime0's
to stsTime1, etc..)

2) Edit codecs/mycodec/mycodec.c (or whatever file contains the call
which you want to profile) and place calls to 'STS_set()' and
'STS_delta()' around the function you wish to profile.  Something like

  {
    extern STS_Obj stsTime0;

    STS_set(&stsTime0, CLK_gethtime());
    function_to_be_timed();
    STS_delta(&stsTime0, CLK_gethtime());
  }

The 'STS_set()' call records the current value of the high resolution
timer (which is incremented at the DSP clock rate on the '64x).  The
'STS_delta()' call accumulates the difference between the current
value of the high resolution timer and the value you recorded
previously.

You will need to include a bunch of BIOS header files (probably
"std.h", "sts.h", and "clk.h") in order to get this to compile, and
you may want to #ifdef it with something that makes sure you are
building for the '6x target (if you still build for multiple targets
the way the examples do).

3) These statistics will be available for viewing through CCS, but if,
like me, your emulator doesn't support the DM6446, or you're too
busy/lazy to hook it up, you can print out the statistics directly
with something like:

  GT_2trace(curTrace, GT_4CLASS, "stats0: %4d, %9d\n", stsTime0.num,
stsTime0.acc);
  STS_reset(&stsTime0

The 'num' field of the 'stsTime0' object contains the number of times
you called 'STS_delta()' above.  The 'acc' field contains the sum of
all of the values.  If you divide the 'acc' field by the 'num' field,
you'll get the average number of cycles spent in
'function_to_be_timed()'.  The 'STS_reset()' call resets the
accumulators to zero.

You have to be a little careful about overflow here.  At 597MHz, the
high resolution timer wraps around every 7.19 seconds.  If what you're
profiling takes longer than 7 seconds, or if you don't reset the
statistics more often than every 7 seconds of accumulated time, you'll
get bogus results.

I hope this helps... some of what I've written might even be accurate
and correct :-)

If you want to add this to the wiki, please feel free to do so.  If I
can remember to do it before you do, I'll try to do so myself.

--wpd
_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to