Forums

overhead in timer

Started by Sri April 27, 2006
Hi,
I am having a doubt about Timer in the DSP/BIOS 5.2.
I am profiling some piece of code on C6416, for profiling I am using the
Timer 1( Timer count Register address 0x01980008).
I have configured the Timer control register (0x01980000) as CPU clock/ 8.
to check the possiblity of reading the overhead in the reading the timer
register, I used following dummy reads of timer register.

start_profile = *(volatile Uint32 *) TIMER_CNT_REG;
stop_profile = *(volatile Uint32 *) TIMER_CNT_REG;
over_head = 8 * (stop_profile - start_profile);

the value of overhead comes around 40 cycles on each run of above code.
I have a doubt that if this value can be this much ??
Is it vaild or there is something wrong with my settings, as I guessed it
should be much lesser.

--
Regards
Sri
Sri,

--- Sri wrote:

> Hi,
> I am having a doubt about Timer in the DSP/BIOS 5.2.
> I am profiling some piece of code on C6416, for
> profiling I am using the
> Timer 1( Timer count Register address 0x01980008).
> I have configured the Timer control register
> (0x01980000) as CPU clock/ 8.
> to check the possiblity of reading the overhead in
> the reading the timer
> register, I used following dummy reads of timer
> register.
>
> start_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> stop_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> over_head = 8 * (stop_profile - start_profile);
>
> the value of overhead comes around 40 cycles on each
> run of above code.
> I have a doubt that if this value can be this much
> ??
look and see what is really happening -
Look at the actual c64x code in CCS [load program,
open source file, select mixed mode]. At a minimum,
you are performing a read [6 clock cycles] and a write
[internal or external memory??]. Are you experiencing
any cache misses??
You also have the 'prescaling factor' - 5 counter
ticks could be as many as 47 or as few as 33 clock
cycles!!

mikedunn
> Is it vaild or there is something wrong with my
> settings, as I guessed it
> should be much lesser.
>
> --
> Regards
> Sri
>
Hi sri,
Try out this piece of code, i'm sure it works.

// before ur code

hTimer = TIMER_open(TIMER_DEV0,0);
TIMER_reset(hTimer);
TIMER_configArgs (hTimer, 0x000003C0, 0xffffffff, 0x00000000);
TIMER_start(hTimer);

// after ur code

cnt = TIMER_getCount(hTimer);
TIMER_close(hTimer);
cycles = cnt*8;

hope this helps u out.

Regards,
srinidhi.

On 4/27/06, Sri wrote:
>
> Hi,
> I am having a doubt about Timer in the DSP/BIOS 5.2.
> I am profiling some piece of code on C6416, for profiling I am using the
> Timer 1( Timer count Register address 0x01980008).
> I have configured the Timer control register (0x01980000) as CPU clock/ 8.
> to check the possiblity of reading the overhead in the reading the timer
> register, I used following dummy reads of timer register.
>
> start_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> stop_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> over_head = 8 * (stop_profile - start_profile);
>
> the value of overhead comes around 40 cycles on each run of above code.
> I have a doubt that if this value can be this much ??
> Is it vaild or there is something wrong with my settings, as I guessed it
> should be much lesser.
>
> --
> Regards
> Sri
>
>
> ------------------------------
>
Hi Srinidhi,
I have verified it with your code, the result is same........however there
is no diffrenece in your appeoach and mine.
I was direcltly configuring the timer control register and reading timer
count register., you are doing the same using the CSL API's, so it actually
doesn't make any difference...:o)
On 4/28/06, srinidhi simha wrote:
>
> Hi sri,
> Try out this piece of code, i'm sure it works.
>
> // before ur code
>
> hTimer = TIMER_open(TIMER_DEV0,0);
> TIMER_reset(hTimer);
> TIMER_configArgs (hTimer, 0x000003C0, 0xffffffff, 0x00000000);
> TIMER_start(hTimer);
>
> // after ur code
>
> cnt = TIMER_getCount(hTimer);
> TIMER_close(hTimer);
> cycles = cnt*8;
>
> hope this helps u out.
>
> Regards,
> srinidhi.
>
> On 4/27/06, Sri wrote:
>
> > Hi,
> > I am having a doubt about Timer in the DSP/BIOS 5.2.
> > I am profiling some piece of code on C6416, for profiling I am using the
> > Timer 1( Timer count Register address 0x01980008).
> > I have configured the Timer control register (0x01980000) as CPU clock/
> > 8.
> > to check the possiblity of reading the overhead in the reading the timer
> > register, I used following dummy reads of timer register.
> >
> > start_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> > stop_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> > over_head = 8 * (stop_profile - start_profile);
> >
> > the value of overhead comes around 40 cycles on each run of above code.
> > I have a doubt that if this value can be this much ??
> > Is it vaild or there is something wrong with my settings, as I guessed
> > it should be much lesser.
> >
> > --
> > Regards
> > Sri
> >
> >
> >
> >
> >
> >
> >
> >
> > ------------------------------
>
--
Regards
Sri
Hi Mike,
I have looked at the assembly code in mixed mode, there is nothing unusual
in it.
still I am not able to understand why it gives 40 cycles the value of
overhead, I am just reading the CPU register two times in a row.
all my program and data are in the internal memory.

On 4/27/06, Mike Dunn wrote:
>
> Sri,
>
> --- Sri wrote:
>
> > Hi,
> > I am having a doubt about Timer in the DSP/BIOS 5.2.
> > I am profiling some piece of code on C6416, for
> > profiling I am using the
> > Timer 1( Timer count Register address 0x01980008).
> > I have configured the Timer control register
> > (0x01980000) as CPU clock/ 8.
> > to check the possiblity of reading the overhead in
> > the reading the timer
> > register, I used following dummy reads of timer
> > register.
> >
> > start_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> > stop_profile = *(volatile Uint32 *) TIMER_CNT_REG;
> > over_head = 8 * (stop_profile - start_profile);
> >
> > the value of overhead comes around 40 cycles on each
> > run of above code.
> > I have a doubt that if this value can be this much
> > ??
> look and see what is really happening -
> Look at the actual c64x code in CCS [load program,
> open source file, select mixed mode]. At a minimum,
> you are performing a read [6 clock cycles] and a write
> [internal or external memory??]. Are you experiencing
> any cache misses??
> You also have the 'prescaling factor' - 5 counter
> ticks could be as many as 47 or as few as 33 clock
> cycles!!
>
> mikedunn
> > Is it vaild or there is something wrong with my
> > settings, as I guessed it
> > should be much lesser.
> >
> > --
> > Regards
> > Sri
> >
--
Regards
Sri
Sri,

--- Sri wrote:

> Hi Mike,
> I have looked at the assembly code in mixed mode,
> there is nothing unusual
> in it.
> still I am not able to understand why it gives 40
> cycles the value of
> overhead, I am just reading the CPU register two
> times in a row.
Without seeing the asm code generated, I don't know -
of course I may not know after seeing your code :-)

Actually your statement is incorrect. The Timer is a
peripheral and is not on the CPU bus, it is on a
peripheral bus that requires a minimum of 6 cycles to
access. In order to perform the access, you must also
have a physical address in a CPU register. After you
read the count, you must have the address of the
variable in a CPU register. Then you can perform the
write. There is quite a bit going on - I don't know
if it should be 33-47 clocks.

mikedunn
> all my program and data are in the internal memory.
>
> On 4/27/06, Mike Dunn
> wrote:
> >
> > Sri,
> >
> > --- Sri wrote:
> >
> > > Hi,
> > > I am having a doubt about Timer in the DSP/BIOS
> 5.2.
> > > I am profiling some piece of code on C6416, for
> > > profiling I am using the
> > > Timer 1( Timer count Register address
> 0x01980008).
> > > I have configured the Timer control register
> > > (0x01980000) as CPU clock/ 8.
> > > to check the possiblity of reading the overhead
> in
> > > the reading the timer
> > > register, I used following dummy reads of timer
> > > register.
> > >
> > > start_profile = *(volatile Uint32 *)
> TIMER_CNT_REG;
> > > stop_profile = *(volatile Uint32 *)
> TIMER_CNT_REG;
> > > over_head = 8 * (stop_profile - start_profile);
> > >
> > > the value of overhead comes around 40 cycles on
> each
> > > run of above code.
> > > I have a doubt that if this value can be this
> much
> > > ??
> > look and see what is really happening -
> > Look at the actual c64x code in CCS [load program,
> > open source file, select mixed mode]. At a
> minimum,
> > you are performing a read [6 clock cycles] and a
> write
> > [internal or external memory??]. Are you
> experiencing
> > any cache misses??
> > You also have the 'prescaling factor' - 5 counter
> > ticks could be as many as 47 or as few as 33 clock
> > cycles!!
> >
> > mikedunn
> > > Is it vaild or there is something wrong with my
> > > settings, as I guessed it
> > > should be much lesser.
> > >
> > > --
> > > Regards
> > > Sri
> > >
> >
> >
> --
> Regards
> Sri
>
Mike:

I figure it out after talking to TI support.
according to them Peripheral accesses go through a specific bus (CFG_BUS),
which is slow. A single access takes around 17 CPU cycles!!!
so my results are correct.
Thanks..

On 4/28/06, Mike Dunn wrote:
>
> Sri,
>
> --- Sri wrote:
>
> > Hi Mike,
> > I have looked at the assembly code in mixed mode,
> > there is nothing unusual
> > in it.
> > still I am not able to understand why it gives 40
> > cycles the value of
> > overhead, I am just reading the CPU register two
> > times in a row.
> Without seeing the asm code generated, I don't know -
> of course I may not know after seeing your code :-)
>
> Actually your statement is incorrect. The Timer is a
> peripheral and is not on the CPU bus, it is on a
> peripheral bus that requires a minimum of 6 cycles to
> access. In order to perform the access, you must also
> have a physical address in a CPU register. After you
> read the count, you must have the address of the
> variable in a CPU register. Then you can perform the
> write. There is quite a bit going on - I don't know
> if it should be 33-47 clocks.
>
> mikedunn
> > all my program and data are in the internal memory.
> >
> >
> >
> > On 4/27/06, Mike Dunn
> > wrote:
> > >
> > > Sri,
> > >
> > > --- Sri wrote:
> > >
> > > > Hi,
> > > > I am having a doubt about Timer in the DSP/BIOS
> > 5.2.
> > > > I am profiling some piece of code on C6416, for
> > > > profiling I am using the
> > > > Timer 1( Timer count Register address
> > 0x01980008).
> > > > I have configured the Timer control register
> > > > (0x01980000) as CPU clock/ 8.
> > > > to check the possiblity of reading the overhead
> > in
> > > > the reading the timer
> > > > register, I used following dummy reads of timer
> > > > register.
> > > >
> > > > start_profile = *(volatile Uint32 *)
> > TIMER_CNT_REG;
> > > > stop_profile = *(volatile Uint32 *)
> > TIMER_CNT_REG;
> > > > over_head = 8 * (stop_profile - start_profile);
> > > >
> > > > the value of overhead comes around 40 cycles on
> > each
> > > > run of above code.
> > > > I have a doubt that if this value can be this
> > much
> > > > ??
> > > look and see what is really happening -
> > > Look at the actual c64x code in CCS [load program,
> > > open source file, select mixed mode]. At a
> > minimum,
> > > you are performing a read [6 clock cycles] and a
> > write
> > > [internal or external memory??]. Are you
> > experiencing
> > > any cache misses??
> > > You also have the 'prescaling factor' - 5 counter
> > > ticks could be as many as 47 or as few as 33 clock
> > > cycles!!
> > >
> > > mikedunn
> > > > Is it vaild or there is something wrong with my
> > > > settings, as I guessed it
> > > > should be much lesser.
> > > >
> > > > --
> > > > Regards
> > > > Sri
> > > >
> > >
> > >
> >
> >
> > --
> > Regards
> > Sri
> >
--
Regards
Sri