<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: powf() function in Redlib using double precision instructions</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898109#M36053</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both the Redlib and Newlib implementations of powf still make some use of double precision math - so you will see some calls like this into the double precision FP library code when linking regardless of which&amp;nbsp;C library you have selected. However a lot of the math is still single precision, so if you look further through the disassembly you will see quite a lot of single precision FP instructions being used - as long as you are building with FP enabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may want to consider implementing your own bespoke "fast" version of the function - though whether this is possible may depend upon the actual values you expect to pass into it (as such algorithms will often have restrictions on inputs or accuracy). I would suggest you do an internet search for "fast powf C function", or similar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MCUXpresso IDE Support&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 03 May 2019 07:44:44 GMT</pubDate>
    <dc:creator>lpcxpresso_supp</dc:creator>
    <dc:date>2019-05-03T07:44:44Z</dc:date>
    <item>
      <title>powf() function in Redlib using double precision instructions</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898108#M36052</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm working on an LPC4357 with MCUXpresso v10.2.1, using Redlib and the single precision floating point unit.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The code I'm working on makes extensive use of powf(), but unfortunately it is causing problems because the current implementation of this function uses double precision instructions, e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1a00b4ce:&amp;nbsp;&amp;nbsp; bl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1a00be70 &amp;lt;&lt;STRONG&gt;__aeabi_f2d&lt;/STRONG&gt;&amp;gt;&lt;BR /&gt;1a00b4d2:&amp;nbsp;&amp;nbsp; add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r3, pc, #484&amp;nbsp;&amp;nbsp;&amp;nbsp; ; (adr r3, 0x1a00b6b8 &amp;lt;powf+648&amp;gt;)&lt;BR /&gt;1a00b4d4:&amp;nbsp;&amp;nbsp; ldrd&amp;nbsp;&amp;nbsp;&amp;nbsp; r2, r3, [r3]&lt;BR /&gt;1a00b4d8:&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r7, r1&lt;BR /&gt;1a00b4da:&amp;nbsp;&amp;nbsp; mov&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; r6, r0&lt;BR /&gt;1a00b4dc:&amp;nbsp;&amp;nbsp; bl&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x1a00bdbc &amp;lt;&lt;STRONG&gt;__aeabi_dcmple&lt;/STRONG&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This means that the computation doesn't go through the FPU, creating unacceptable delays.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can't switch to Newlib easily as the system is already in production.&lt;/P&gt;&lt;P&gt;Does anyone know of any fix or workaround?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 May 2019 17:04:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898108#M36052</guid>
      <dc:creator>stefanopietrosa</dc:creator>
      <dc:date>2019-05-01T17:04:59Z</dc:date>
    </item>
    <item>
      <title>Re: powf() function in Redlib using double precision instructions</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898109#M36053</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Both the Redlib and Newlib implementations of powf still make some use of double precision math - so you will see some calls like this into the double precision FP library code when linking regardless of which&amp;nbsp;C library you have selected. However a lot of the math is still single precision, so if you look further through the disassembly you will see quite a lot of single precision FP instructions being used - as long as you are building with FP enabled.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may want to consider implementing your own bespoke "fast" version of the function - though whether this is possible may depend upon the actual values you expect to pass into it (as such algorithms will often have restrictions on inputs or accuracy). I would suggest you do an internet search for "fast powf C function", or similar.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;MCUXpresso IDE Support&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2019 07:44:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898109#M36053</guid>
      <dc:creator>lpcxpresso_supp</dc:creator>
      <dc:date>2019-05-03T07:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: powf() function in Redlib using double precision instructions</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898110#M36054</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I checked and, indeed, the Newlib implementation of &lt;STRONG&gt;powf&lt;/STRONG&gt;() uses double precision maths as well.&lt;/P&gt;&lt;P&gt;Fortunately, both &lt;STRONG&gt;logf &lt;/STRONG&gt;and &lt;STRONG&gt;expf&lt;/STRONG&gt; use single precision instructions, so I was able to write my crude implementation of powf by exploiting the fact that a^b = exp(log(a) * b).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problematic routine is now an order of magnitude faster with the help of the single precision FPU.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 May 2019 15:27:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/powf-function-in-Redlib-using-double-precision-instructions/m-p/898110#M36054</guid>
      <dc:creator>stefanopietrosa</dc:creator>
      <dc:date>2019-05-03T15:27:45Z</dc:date>
    </item>
  </channel>
</rss>

