This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28377D: “/” and “_divf32()” output result not align, “/“ result accuracy is better

Part Number: TMS320F28377D

Tool/software:

Hi Expert

Customer use the “/“ and “ _divf32()” to calculate the same data below:


but get the different results:

using “/“ the calculation results are:

-1.99986887,

0.999941111,

0.999869108,

0.999927998. 
using “_divf32()” the calculation results are:

-1.99986899,

0.99994117,

0.999869168,

0.999928057. 
Compare with the simulation result, the “/“ result is better.

questions are: why the _divf32() result error is larger than “/“?

How to improve the _divf32() accuracy?

thanks

Joe

  • Hi Joe ,

    The _divf32() is using the FPUfastRTS library but the "/" maybe using the standard RTS library implemented division.

    This FPUfastRTS library is a "fast" supplement to the standard runtime library. It provides optimized assembly-level implementations that deliberately trade a small amount of accuracy for a significant speed increase. It often achieves this by using a more efficient iterative algorithm, which converges quickly but does not guarantee the full precision of the standard library.

    If accuracy is more important standard libs are a better option.

    Regards.

  • Hi Meghana

    what to check if the compiler option set to -relax both _divf32() and / can be compiled use FPU? The differences are the 2 functions call the different libraries?

    Thanks

    Joe

  • Hi Joe,

    Yes the behavior of / is determined by compiler flags.

    With --fp_mode=relaxed, the compiler may perform algebraic reassociation or other shortcuts for speed, approximating the behavior of the intrinsic closer to what the _divf32() should get .If the compiler option is set to relaxed & If the Trigonometric Math Unit (TMU) is enabled (--tmu_support), the compiler replaces math.h library calls with faster, equivalent TMU hardware instructions.
    With --fp_mode=strict, it adheres to precise IEEE 754 standards, potentially leading to a different result than _divf32(). At this time it will call the standard lib.

    Regards.

  • Hi Meghana

    Is there any method to use TMU but reaches the same accuracy as "/"?

    Thanks

    Joe

  • Hi Joe,

    Not directly , they can try to break the math operations into say a/b as a* 1/b but they may need to do an additional step, such as a Newton-Raphson iteration, to refine the result to the desired full precision before the final multiplication which maynot be straight forward.

    Ideally TMU is built for speed so accuracy may not be top notch.

    Regards.