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.

Compiler/TMS320F28069: IQ math and 64bit long doubles performance

Part Number: TMS320F28069


Tool/software: TI C/C++ Compiler

I'm using the TMS320F28069 with the FPU enabled. As such I decided to turn on the warning to tell me if I'm using any 64bit floating point math anywhere ( #1558-D 64-bit floating point operations are not allowed )

What I see is that in all the IQ math conversion functions:

#define   _IQ24(A)      (long) ((A) * 16777216.0L)

When I pass

float_t value;

x = _IQ24(value);

Then the value is getting extended to a 64bit long double and multiplied by the long double constant 16777216.0L.  The result is then converted back to a 32bit integer type.

This is giving me the warning above and is obviously much much slower than using the 32bit FPU multiplication.

If I change the macro to:

#define   _IQ24(A)      (long) ((A) * 16777216.0F)

Then everything stays in 32bit floating point and the warning is gone which is nice and quick.

Is there really a risk here that the multiplication will overflow the precision of a 32bit float and cause significantly more error in the already imperfect fixed point conversion?

How do I quantify this error?

  • Hi,

    We have directed your query to the IQMath expert. The response might be delayed since US sites are closed due to Thanksgiving holiday.

    Thanks and Regards,
    Veena
  • Thomas,

    The code which gets executed depends on the setting of MATH_TYPE defined in the "IQmathLib.h" header file.  When this is set to IQ_MATH, you get the integer product describe, and the use of 64-bit intermediate data preserves accuracy in the result, otherwise bits will be lost in the left shift when restoring the result to IQ24 format.

    If you set the MATH_TYPE definition to FLOAT_MATH, the compiler will use the RTS library or (if available) the FPU to implement the multiply with floating point data.  You do not need to change the macro for this to happen.

    I recommend you leave the macro as it is and select which data type you want to work with by changing MATH_TYPE.

    Regards,

    Richard

  • Thomas,

    You are correct in your understanding.

    We do have a tracked request in the queue to fix this. In the meanwhile, you can change the way you have mentioned in your post. 

    regards
    Manish Bhardwaj