[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] Trouble with division
From: |
Larry Barello |
Subject: |
Re: [avr-gcc-list] Trouble with division |
Date: |
Sun, 15 Jun 2003 06:42:44 -0700 |
Here is an old email with relative times for various math operations in avr-gcc.
----- Original Message -----
From: "Ulrich Schweitzer" <address@hidden>
...
Yes you are right, the counter is running at full speed. Unfortunatelly I
need the resolution of full speed and also cannot afford to lose
interrupts. If I can't avoid the division (I'm not sure, yet), I could
try to raise the clock frequency (it's only 1Mhz now) and then use the
prescaler to keep the counter at the same rate. How many clock cycles
does the divison of a uint16 through a uint8 take?
----- Original Message -----
From: "Dean Ferreyra" <address@hidden>
To: "Uwe Bonnes" <address@hidden>; <address@hidden>
Sent: Wednesday, May 22, 2002 10:22 AM
Subject: RE: [avr-gcc-list] 10 bit division in AVR-GCC
> Uwe,
>
> About 9 months ago I wrote a small AVR program to time various operations.
> Here are the results I got:
>
> atmega103 at 4 MHz
>
> Hz Cycles
>
> Overhead:
> ; (u): 190378 21
>
> uint8_t:
> x+y (u): 142747 7
> x-y (u): 142762 7
> x<<5 (u): 142762 7
> x*y (o): 46497 65
> x/y (o): 37026 87
> x%y (o): 36686 88
>
> uint16_t:
> x+y (u): 114218 14
> x-y (u): 114225 14
> x<<9 (u): 124927 11
> x*y (o): 19412 185
> x/y (o): 16662 219
> x%y (o): 16802 217
> div (o): 14436 256
>
> uint32_t:
> x+y (u): 81598 28
> x-y (u): 81601 28
> x<<17 (o): 25633 135
> x*y (o): 9214 413
> x/y (o): 6105 634
> x%y (o): 6105 634
> ldiv (o): 5228 744
>
> uint64_t:
> x+y (o): 26481 130
> x-y (o): 26482 130
> x*y (o): 2936 1341
> x<<33 (o): 13510 275
> x/y (o): 1040 3825
> x%y (o): 977 4073
>
> float:
> fabs (u): 105206 17
> floor (o): 7810 491
> ceil (o): 7918 484
> x+y (o): 27578 124
> x-y (o): 22592 156
> x*y (o): 9387 405
> x/y (o): 7310 526
> inverse (o): 7297 527
> square (o): 9566 397
> sqrt (o): 2366 1670
> cos (o): 801 4973
> sin (o): 716 5566
> tan (o): 699 5701
> pow (o): 379 10533
> exp (o): 920 4327
> log (o): 688 5793
> log10 (o): 633 6298
> acos (o): 702 5677
> asin (o): 719 5542
>
> The Hz column is how many of the given operations the AVR was able to do in
> one second. The Cycles column is how many cycles it took to do the
> operation once. The Cycles column takes overhead into account with the
> overhead calculated in the first test (labeled ";", i.e. an empty C line).
> (For example, the test of "tan" above can be performed 699 times in one
> second, so it takes 4 MHz / 699 = 5722 cycles per operation. Since the
> overhead is 21 cycles, the result you see is 5701 cycles.) Each operation
> was run 65536 times or until a timer overflowed, whichever came first. (The
> "u" or "o" in the parentheses indicate whether or not the timer overflowed.)
>
> I did this to get in the ballpark and kept this list handy when making
> descisions on how to implement my algorithms.
>
- [avr-gcc-list] Trouble with division, Ulrich Schweitzer, 2003/06/14
- Re: [avr-gcc-list] Trouble with division, Joerg Wunsch, 2003/06/14
- Re: [avr-gcc-list] Trouble with division, Ulrich Schweitzer, 2003/06/15
- Re: [avr-gcc-list] Trouble with division,
Larry Barello <=
- Re: [avr-gcc-list] Trouble with division, Ulrich Schweitzer, 2003/06/15
- RE: [avr-gcc-list] Trouble with division, Dean Ferreyra, 2003/06/15
- Re: [avr-gcc-list] Trouble with division, Joerg Wunsch, 2003/06/15
- Re: [avr-gcc-list] Trouble with division, Ulrich Schweitzer, 2003/06/16
- Re: [avr-gcc-list] Trouble with division, Neil Johnson, 2003/06/16
- Re: [avr-gcc-list] Trouble with division, Joerg Wunsch, 2003/06/17