Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution Banner_AURIX_Security-Solution


+ Reply to Thread
Results 1 to 6 of 6

Thread: Performance Comparison Between int and float for TC297

  1. #1
    Beginner Beginner icework is on a distinguished road
    Join Date
    Sep 2019
    Posts
    16
    Points
    135

    Performance Comparison Between int and float for TC297

    I test the performance difference between int and float through "dotp"(res += a[i]*b[i]).
    I found the speed of int is slower than float, about half.
    Why?I want to know.

  2. #2
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    128
    Points
    2527.5

    Hi Shaquille,

    Can you list the sample code for the integer and float sample case? Just so that we get a better understanding of what you're doing.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

  3. #3
    Beginner Beginner icework is on a distinguished road
    Join Date
    Sep 2019
    Posts
    16
    Points
    135
    float test:
    IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_no rmal) ;
    for(i = 0 ; i < iTryCnt ; i ++)
    pDotpResF[i] = Test_float_dotp(pAF, pBF, iDataCnt) ;
    perfCounts = IfxCpu_stopCounters() ;

    int test:
    IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_no rmal) ;
    for(i = 0 ; i < iTryCnt ; i ++)
    pDotpResI[i] = Test_int_divp(pAI, pBI, iDataCnt) ;
    perfCounts = IfxCpu_stopCounters() ;

    implementation of Test_float_dotp:
    float Test_float_dotp(const float* pVecA, const float* pVecB, int iDataCnt)
    {
    int i = 0 ;
    float fResult = 0.0f ;
    for(i = 0 ; i < iDataCnt ; i ++)
    fResult += pVecA[i] * pVecB[i] ;

    return fResult ;
    }

    implementation of Test_int_dotp
    int Test_int_dotp(const int* pVecA, const int* pVecB, int iDataCnt)
    {
    int i = 0 ;
    int iResult = 0 ;
    for(i = 0 ; i < iDataCnt ; i ++)
    iResult += pVecA[i] * pVecB[i] ;

    return iResult ;
    }

    result is:
    float dotp cost(64*64): 17689tick
    int dotp cost(64*64): 34008tick


    Is there something wrong in above code?

  4. #4
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    128
    Points
    2527.5

    Hi Shaquille,

    Code looks OK to me. I used the attached sample case, using parts of your code. To build it I used:

    Code:
    tricore-gcc -O2 -mcpu=tc39xx main.c dotint.c dotflt.c -o benchmark.elf
    I then simulated it as below:

    Code:
    tsim16p_e -MConfig MConfig -disable-watchdog -H -g -s -x 0 -o benchmark.elf
    Which then generates the following output:

    Code:
    Integers: 0x000000E9 cycles
    Floats: 0x000000E8 cycles
    So floats are still faster, as in your case, but only by 1 cycle. What command line options have you been using?

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software
    ?????

  5. #5
    Beginner Beginner icework is on a distinguished road
    Join Date
    Sep 2019
    Posts
    16
    Points
    135
    sorry, I make a mistake again, divp instead of dotp for int-test

  6. #6
    Advanced Advanced HIGHTEC.henk-piet.glas is on a distinguished road
    Join Date
    May 2017
    Posts
    128
    Points
    2527.5

    Hi Shaquille,

    No problem. If there's anything else I can help you with, just let me know.

    Best regards,

    Henk-Piet Glas

    Principal Technical Specialist
    Embedded Software

+ Reply to Thread
Disclaimer

All content and materials on this site are provided “as is“. Infineon makes no warranties or representations with regard to this content and these materials of any kind, whether express or implied, including without limitation, warranties or representations of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. No license, whether express or implied, is granted by Infineon. Use of the information on this site may require a license from a third party, or a license from Infineon.


Infineon accepts no liability for the content and materials on this site being accurate, complete or up- to-date or for the contents of external links. Infineon distances itself expressly from the contents of the linked pages, over the structure of which Infineon has no control.


Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Usage Terms of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Usage Terms of this site. Infineon reserves the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.