infineon4engi@twitter infineon4engineers infineon@linkedin infineon@youtube
twitter Facebook Linkedin Youtube

Banner_Aurix_Competition Banner_AURIX_Security-Solution Banner_AURIX_Safety_Products ShieldBuddy TC275 Banner_AURIX_OnzerOS Banner_AURIX_DevelopmentStudio


+ Reply to Thread
Results 1 to 5 of 5

Thread: Better a DIV.F or Reciprocal SQRT (QSEED.F) squared ?

  1. #1
    New Member New Member ricCarrozzo is on a distinguished road
    Join Date
    Jun 2020
    Posts
    3
    Points
    40

    Better a DIV.F or Reciprocal SQRT (QSEED.F) squared ?

    Hi All,

    I have a piece of code which makes use of divisions. The fixed-point version was guaranteed to not cause exception, because of the data flow through the algorithm (still required commenting for QA).
    The numerator and denominator come from ADC readings, so absolute precision is limited.

    I'm moving the code to single-precision floating point on Aurix.
    In this case, I see an option in replacing the division (DIV.F) with a multiplication by the square of the reciprocal sqrt, obtained by using QSEED.F, with a single Newton-Raphson iteration.

    Theoretically - from the FPU timing table - the 2 options should have very similar latency, but the repeat rate could favour the reciprocal sqrt, which could be a factor, because there's more than one division to calculate.
    Additionally, the "guaranteed no exception" would not need justification in this case.

    Has anyone tried something similar ?

    Is QSEED.F supported by compilers or should I get down writing assembly code to make use of it ?

  2. #2
    Advanced Advanced UC_wrangler will become famous soon enough
    Join Date
    Jun 2019
    Posts
    281
    Points
    5860
    I don't believe the compilers emit qseed. There is a DSPLib library that has some functions that use qseed, as well as other hand-crafted assembly optimizations.

    It's on MyICP here:
    https://myicp.infineon.com/sites/mic...age%200v83.zip

  3. #3
    Intermediate Intermediate ulrichk is on a distinguished road
    Join Date
    Sep 2017
    Posts
    25
    Points
    292.5
    The TASKING C compiler won't generate the qseed.f instruction. But the sqrtf library function is using this instruction in the flavor using the hardware FPU (libcs_fpu.a). Here it's used in an inline assembly code sequence:

    /* get reciprocal of the square root (6.75 bits accuracy) */
    __asm(" QSEED.F %0,%1 \n": "=d" (xn):"d" (arg): );

    Best regards,
    Ulrich

    TASKING tools support staff

  4. #4
    New Member New Member ricCarrozzo is on a distinguished road
    Join Date
    Jun 2020
    Posts
    3
    Points
    40
    Thx for the prompt reply.

    That is my impression as well - been looking through Tasking libraries and there's no reciprocal sqrt entry there.

  5. #5
    New Member New Member ricCarrozzo is on a distinguished road
    Join Date
    Jun 2020
    Posts
    3
    Points
    40
    Thanks ulrichk.

    That's useful.

+ Reply to Thread

Tags for this 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.