Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: Teensy 3.6 - Looking for a complete list of all FPU accelerated math functions

  1. #1

    Teensy 3.6 - Looking for a complete list of all FPU accelerated math functions

    Hello,

    where can I find a complete list or file showing all the float math functions which can be performed by the FPU?

    So far I came across

    If you use the math functions (sin, cos, log, etc.), you want to use the float versions of these functions (sinf, cosf, logf).
    and floorf. I guess there is more the FPU can do.

    Any hint is welcome. Thanks.
    Last edited by StefanPetrick; 07-13-2017 at 10:42 AM.

  2. #2
    I found this.

    Has this anything to do with the library the Teensy 3.6 uses?

    Code:
    double 	cos (double __x)
     
    double 	sin (double __x)
     
    double 	tan (double __x)
     
    double 	fabs (double __x)
     
    double 	fmod (double __x, double __y)
     
    double 	modf (double __x, double *__iptr)
     
    float 	modff (float __x, float *__iptr)
     
    double 	sqrt (double __x)
     
    float 	sqrtf (float)
     
    double 	cbrt (double __x)
     
    double 	hypot (double __x, double __y)
     
    double 	square (double __x)
     
    double 	floor (double __x)
     
    double 	ceil (double __x)
     
    double 	frexp (double __x, int *__pexp)
     
    double 	ldexp (double __x, int __exp)
     
    double 	exp (double __x)
     
    double 	cosh (double __x)
     
    double 	sinh (double __x)
     
    double 	tanh (double __x)
     
    double 	acos (double __x)
     
    double 	asin (double __x)
     
    double 	atan (double __x)
     
    double 	atan2 (double __y, double __x)
     
    double 	log (double __x)
     
    double 	log10 (double __x)
     
    double 	pow (double __x, double __y)
     
    int 	isnan (double __x)
     
    int 	isinf (double __x)
     
    static int 	isfinite (double __x)
     
    static double 	copysign (double __x, double __y)
     
    int 	signbit (double __x)
     
    double 	fdim (double __x, double __y)
     
    double 	fma (double __x, double __y, double __z)
     
    double 	fmax (double __x, double __y)
     
    double 	fmin (double __x, double __y)
     
    double 	trunc (double __x)
     
    double 	round (double __x)
     
    long 	lround (double __x)
     
    long 	lrint (double __x)
    Can I expect all these functions to work with the suffix f on 32 bit floats using the FPU?

    Sorry in case my question is entirely stupid. I really have no clue where and how I could find the information myself.
    Is the answer so obvious to anyone that I sound like a troll? I assure this is not my intention.

  3. #3
    Is it right that the CMSIS DSP Software Library has nothing to do with the FPU hardware but with the DSP hardware?

    Which way to perform calculations is faster?

    The question was triggered by this thread.

    Im completely confused now.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    22,533
    The FPU provides add, subtract, multiply, divide, square root, absolute value, negation, comparison, multiply-accumulate, multiply-subtract, conversion to/from integers, many ways to move/load/store data with the FPU's 32 special registers, and a few misc instructions for manipulating status bits.

    Logarithms, trig functions, powers are done with library functions. Usually they involve polynomial approximations, which of course are computed with the basic operations the FPU provides.

    The CMSIS-DSP library has some "fast" functions, and it's pretty simple to build your own. Many of the approximations can be done with fewer calculations if you don't require the full accuracy over the entire range. For example, if you're taking the sine of angles and you know you're never going to input numbers close to Pi/2 (90 degrees), maybe just the first few terms of the Taylor series will give you plenty of accuracy.

  5. #5
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    174
    Sorry to bring up an old thread! This is related, though -

    Do you know if Teensy 3.6 has fast reciprocal? I'm doing alpha compositing which requires a divide. Not sure if the compiler would convert the divide to a multiplication by the reciprocal automatically?
    FYI, the equation is:

    OutColor = (SrcColor.SrcAlpha + DestColor.DestAlpha.(1 - SrcAlpha)) / OutAlpha;

    Where Color is uint8_t and Alpha is float 0.0 - 1.0

  6. #6
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,837
    Quote Originally Posted by Projectitis View Post
    Sorry to bring up an old thread! This is related, though -

    Do you know if Teensy 3.6 has fast reciprocal? I'm doing alpha compositing which requires a divide. Not sure if the compiler would convert the divide to a multiplication by the reciprocal automatically?
    FYI, the equation is:

    OutColor = (SrcColor.SrcAlpha + DestColor.DestAlpha.(1 - SrcAlpha)) / OutAlpha;

    Where Color is uint8_t and Alpha is float 0.0 - 1.0
    Typically GCC does not replace divide by a constant with multiply by a reciprocal constant unless either the appropriate fast math option (-Ofast, -ffast-math, -freciprocal-math, ...) is used, or the constant is a power of 2.

  7. #7
    Senior Member Projectitis's Avatar
    Join Date
    Feb 2018
    Location
    New Zealand
    Posts
    174
    Thanks for that. I'll do some benchmarking and see what happens with various options

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •