[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] 10 bit division in AVR-GCC
From: |
Dean Ferreyra |
Subject: |
RE: [avr-gcc-list] 10 bit division in AVR-GCC |
Date: |
Wed, 22 May 2002 10:22:46 -0700 |
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.
Dean
-----Original Message-----
From: address@hidden [mailto:address@hidden
Behalf Of Uwe Bonnes
Sent: Wednesday, May 22, 2002 1:31 AM
To: address@hidden
Subject: [avr-gcc-list] 10 bit division in AVR-GCC
Hallo,
does a 10(16) bit divide work out of the box with AVR-GCC and avr-lib?
Approx how long does it take with 8 MHz? Is the Hardware Multiplier
(recent AtMegas) of help for the division?
Thanks
--
Uwe Bonnes address@hidden
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
avr-gcc-list at http://avr1.org
avr-gcc-list at http://avr1.org