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.

CCS/TMS320F280025: How to use FPU to accelerate code efficiency

Part Number: TMS320F280025

Tool/software: Code Composer Studio

My customer has port their firmware from F28035 to F280025, their firmware include many calculation algorithm base on IQ_MATH and can also run ok in F280025. 

Now customer would like to enable F280025 hardware FPU to accelerate their algorithm calculation timing, so we do below action:

1, enable --fpu32 in CCS project configuration -> processor option; 

2, set --fp_mode as relaxed in CCS project configuration -> Optimization 

3, replace IQmath.lib by IQmath_fpu32.lib

4, modify #define   MATH_TYPE  to be  FLOAT_MATH  in IQmathlib.h

The project can be compiled succeeded on above setting, however the firmware algorithm calculation timing become even longer than original IQ_MATH fix point.

May I ask if we can accelerate the algorithm calculation timing by using IQmath functions with FLOAT_MATH_TYPE setting?  Or we have to modify all IQmath function code to be replaced by true/pure floating instruction? 

  • Terry,

    The approach seems correct. Now you will use the FPU32, TMU for computation as opposed to the IQMath library. I would advise checking that this is the case, by looking at the disassembly - to verify that FPU and TMU instructions are being used, and not IQMath function calls, or any RTS library calls.

    Thanks,

    Sira

  • Hi Sira

    Thanks your advice. I have double check the disassembly that FPU instruction should be enable used. I try to copy parts of disassembly as below:

    However the customer firmware execution time after enable FPU, is longer than IQmath fix point format.

    I am not sure now if FPU instruction really can help for accelerate algorithm timing than fix point IQmath?

    0824f0:   FE02        ADDB         SP, #2
     39         if (x < 0) { __raise_invalid(); return NAN; }
    0824f1:   E5A0        CMPF32       R0H, #0.0
    0824f2:   AD14        MOVST0       NF,ZF
    0824f3:   6308        SB           $C$L1, GEQ
    0824f4:   761F0280    MOVW         DP, #0x280
    0824f6:   E803FE00    MOVIZ        R0, #0x7fc0  
    0824f8:   56BF210A    MOVB         @0xa, #0x21, UNC
    0824fa:   6F1B        SB           $C$L4, UNC  
     41         if (x == 0) return x;
            $C$L1:
    0824fb:   E5A0        CMPF32       R0H, #0.0
    0824fc:   AD14        MOVST0       NF,ZF
    0824fd:   6118        SB           $C$L4, EQ
    0824fe:   BE02        MOVB         XAR6, #0x02
     55         float x0 = __eisqrtf32(x);
    0824ff:   E6920001    EISQRTF32    R1H, R0H
    082501:   E84FC003    MPYF32       R3H, #0x3f00, R0H
     58         for (i = 0; i < 3; i++)
    082503:   B50D00A6    RPTB         $C$L3, @AR6
     59           x0 *= (1.5f - x * 0.5f * x0 * x0);
            $C$L2:
    082505:   E70000CA    MPYF32       R2H, R1H, R3H
    082507:   7700        NOP              
    082508:   E700008A    MPYF32       R2H, R1H, R2H
    08250a:   7700        NOP              
    08250b:   E8CFF012    SUBF32       R2H, #0x3fc0, R2H
    08250d:   7700        NOP              
    08250e:   E7000051    MPYF32       R1H, R2H, R1H
    082510:   7700        NOP              
    082511:   7700        NOP              
     62         return x * x0;
            $C$L3:
    082512:   E7000040    MPYF32       R0H, R0H, R1H
    082514:   7700        NOP          
            $C$L4:
    082515:   FE82        SUBB         SP, #2
    082516:   0006        LRETR    
  • Terry,

    Thanks. Could you profile a section of code that runs faster with IQMath.lib than with FPU, and send the corresponding disassembly? That can help us narrow down the problem.

    I am also attaching a picture of some benchmarking I did on F28002x, comparing fixed-pt vs floating-pt. In general, you can see the speed up with floating-pt operations. The last row is Floating-pt, and the one above it is Fixed-pt.

    Thanks,

    Sira

  • Hi Sira

    I found the reason, because fix point IQmath use Look-Up table for Sin/Cos/Sqrt.....functions, however Float Point IQmath use many instructions to calculate the Sin/Cos/Sqrt algorithm, so that the customer algorithm run more longer timing after enable Float Point IQmath. 

    Now I ask customer enable TMU instructions to replace IQmath functions, and confirm that can accelerate the customer firmware execution timing. 

  • Terry,

    The LUT is a good finding. With the project settings you mentioned, TMU instructions should already be in use. So does it mean FPU/TMU instructions are slower than fixed-pt LUT approach?

    Thanks,

    Sira

  • Hi Sira

    At beginning, I only enable the FPU without enable TMU, so performance result is that FPU(without TMU) IQmath is slower than LUT IQmath.

    Then after I find out this reason,  I try to enable TMU and use TMU instructions to replace IQmath functions, the result is that FPU/TMU instructions is fast than LUT IQmath.

  • Terry,

    That makes sense. Thanks!

    Sira