Recent

Author Topic: Real types  (Read 3554 times)

d.ioannidis

  • Full Member
  • ***
  • Posts: 221
    • Nephelae
Re: Real types
« Reply #15 on: January 15, 2020, 09:51:40 pm »
Hi,

That were the points I actually made.... :P

( ok I'll bite ...   :P )

You said " ... Floats will be very, very slow ... ".

IMHO,  the results doesn't show this. Slower ( as expected ) yes, ( even if there is a case which divi with floats is actually faster that divi with long. Keep in mind that in GCC anyway the timing for float +/-/*/div are VERY sensitive to the input data ) but "... very, very slow ... " ? Sorry I don't see it ...

Could you please clarify which points you made about floats, are proven by my post ? ( I assume from your post that your opinion is that implementing / fixing avr soft float is just wasting fpc dev's time and resources ... )

regards,
« Last Edit: January 15, 2020, 09:56:05 pm by Dimitrios Chr. Ioannidis »

avra

  • Hero Member
  • *****
  • Posts: 2514
    • Additional info
Re: Real types
« Reply #16 on: January 16, 2020, 09:30:05 am »
I have been using single floats on AVRs for more then 20 years. Both with GCC and AvrCo. They work well, but only if your expectations are not real time (like FFT for example). I have also tried several double float implementations for GCC at the time. Only one worked well, but usability is highly questionable because it was so slooooooow and eating flash too much. Since both high speed and high precision were needed, I have implemented 64bit S31.32 fixed point type. It's quite usable, and covers 99% of situations where double was needed and single was not enough (like real time tracking of space object with astronomy telescope with such a precision that object looks still in videos).

Here are the AVR benchmarks at 16MHz using pure pascal and no asm:
Quote
F1 + F2    speed : 7usec
F1 - F2    speed : 8usec
F1 * F2    speed : 250usec
F1 / F2    speed : 500usec
Sqr        speed : 250usec
Sqrt       speed : 0.5msec  result : 5 frac digits
Fix64Sqrt  speed : 2.2msec  result : 9 frac digits
Delphi Sin(3.0) result : 0.14112000806
AVRco  Sin(3.0) result : 0.141120008    5..8msec
https://forum.e-lab.de/topic.php?t=2562

SQRT is very important for trigonometry calculations. If you can live with results having just 5 fractional digits then highly optimized version executes in just 0.5ms. "Complete" version executes in 2.2ms. Also, if you cache last result then you speed lots of calculations where both sin and cos (or tan and ctn) are used.
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018