<?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>topic Re: FP16 math functions not getting inlined in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632324#M4099</link>
    <description>&lt;P&gt;I'm discussing this problem with another team and trying to find if we have other solutions.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Sep 2024 00:00:03 GMT</pubDate>
    <dc:creator>Alex_Y_Intel</dc:creator>
    <dc:date>2024-09-20T00:00:03Z</dc:date>
    <item>
      <title>FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1631461#M4091</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;icx 2024.2.0&lt;/P&gt;&lt;P&gt;-Ofast -xSAPPHIRERAPIDS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;#include &amp;lt;immintrin.h&amp;gt;
#include &amp;lt;mathimf.h&amp;gt;

_Float16 test_fp16(_Float16 x, _Float16 y)
{
    return sqrtf16(x) + sqrtf16(y);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;generates the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="none"&gt;test_fp16(_Float16, _Float16):
        push    rax
        vmovsh  word ptr [rsp + 4], xmm1
        call    sqrtf16
        vmovsh  word ptr [rsp], xmm0
        vmovsh  xmm0, word ptr [rsp + 4]
        call    sqrtf16
        vaddsh  xmm0, xmm0, word ptr [rsp]
        pop     rax
        ret&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a compiler flag I can use to make it generate the expected code instead?&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="none"&gt;test_fp16(_Float16, _Float16):
        vsqrtsh xmm0, xmm0, xmm0
        vsqrtsh xmm1, xmm1, xmm1
        vaddsh  xmm0, xmm1, xmm0
        ret&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See &lt;A href="https://godbolt.org/z/xWsqW8djE" target="_blank" rel="noopener"&gt;https://godbolt.org/z/xWsqW8djE&lt;/A&gt; for more details.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2024 07:25:13 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1631461#M4091</guid>
      <dc:creator>rabbits</dc:creator>
      <dc:date>2024-09-16T07:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1631854#M4094</link>
      <description>&lt;P&gt;I've escalated your issue to our internal team for further investigation, thanks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2024 00:27:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1631854#M4094</guid>
      <dc:creator>Alex_Y_Intel</dc:creator>
      <dc:date>2024-09-18T00:27:04Z</dc:date>
    </item>
    <item>
      <title>Re:FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632166#M4096</link>
      <description>&lt;P&gt;In order for a function to be inlined, it has to have the header/source file when compiling. If you take a look at the "inline report" with: icx test.c -Ofast -xSAPPHIRERAPIDS -c&amp;nbsp;-qopt-report=3&amp;nbsp;-qopt-report-file=stderr&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Global optimization report for : test_fp32&lt;/P&gt;&lt;P&gt;=================================================================&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Global optimization report for : test_fp16&lt;/P&gt;&lt;P&gt;=================================================================&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Global optimization report for : test_fp16_fix&lt;/P&gt;&lt;P&gt;=================================================================&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;---- Begin Inlining Report ----&lt;/P&gt;&lt;P&gt;Option Values:&lt;/P&gt;&lt;P&gt;&amp;nbsp;inline-threshold: 225&lt;/P&gt;&lt;P&gt;&amp;nbsp;inlinehint-threshold: 325&lt;/P&gt;&lt;P&gt;&amp;nbsp;inlinecold-threshold: 45&lt;/P&gt;&lt;P&gt;&amp;nbsp;inlineoptsize-threshold: 15&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DEAD STATIC FUNC: _mm_set_sh&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DEAD STATIC FUNC: _mm_setzero_ph&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DEAD STATIC FUNC: _mm_sqrt_sh&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;DEAD STATIC FUNC: sqrtf16_fast&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;COMPILE FUNC: test_fp32&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; llvm.sqrt.f32 test.c (6,12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; llvm.sqrt.f32 test.c (6,23)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;COMPILE FUNC: test_fp16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; EXTERN: sqrtf16 test.c (11,12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; EXTERN: sqrtf16 test.c (11,25)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;COMPILE FUNC: test_fp16_fix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: sqrtf16_fast test.c (21,12) (-30&amp;lt;=487)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_sqrt_sh test.c (16,12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_setzero_ph test.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; llvm.sqrt.f16 test.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_setzero_ph test.c (16,24)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_set_sh test.c (16,42)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: sqrtf16_fast test.c (21,30) (-30&amp;lt;=487)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_sqrt_sh test.c (16,12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_setzero_ph test.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; llvm.sqrt.f16 test.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_setzero_ph test.c (16,24)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;-&amp;gt; INLINE: _mm_set_sh test.c (16,42)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;---- End Inlining Report ------&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Please note that sqrtf16 uses an external function:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;COMPILE FUNC: test_fp16&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; EXTERN: sqrtf16 test.c (11,12)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;-&amp;gt; EXTERN: sqrtf16 test.c (11,25)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In fact, this sqrtf16 is actually extracted from libimf.a and linked by the linker, and libimf.a is a library object, not a header/source file. &lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;In conclusion, icx does not provide the source code for sqrtf16 to be inlined. &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 19 Sep 2024 07:09:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632166#M4096</guid>
      <dc:creator>Alex_Y_Intel</dc:creator>
      <dc:date>2024-09-19T07:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: Re:FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632194#M4097</link>
      <description>&lt;P&gt;&amp;gt; In conclusion, icx does not provide the source code for sqrtf16 to be inlined.&lt;/P&gt;&lt;P&gt;swell!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 09:05:42 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632194#M4097</guid>
      <dc:creator>rabbits</dc:creator>
      <dc:date>2024-09-19T09:05:42Z</dc:date>
    </item>
    <item>
      <title>Re: FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632324#M4099</link>
      <description>&lt;P&gt;I'm discussing this problem with another team and trying to find if we have other solutions.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 00:00:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632324#M4099</guid>
      <dc:creator>Alex_Y_Intel</dc:creator>
      <dc:date>2024-09-20T00:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: FP16 math functions not getting inlined</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632399#M4100</link>
      <description>&lt;P&gt;Let me turn Gordon in his grave for you.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2024 10:05:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/FP16-math-functions-not-getting-inlined/m-p/1632399#M4100</guid>
      <dc:creator>rabbits</dc:creator>
      <dc:date>2024-09-20T10:05:37Z</dc:date>
    </item>
  </channel>
</rss>

