<?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: Detecting Floating Point Exceptions in Intel® Integrated Performance Primitives</title>
    <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911236#M14283</link>
    <description>&lt;P&gt;Many thanks for the response, but this raisesa few further questions:-&lt;/P&gt;
&lt;P&gt;Presumably, you only pay the performance penalty if the exceptions do occur and IPP chooses to threshold the values and explicitly set 0 or inffor values outside the bounds you mention.&lt;/P&gt;
&lt;P&gt;99.99% of our datashould be within range so really we just want to flag that at least one item was out of range on the rare occasion that this does happen.&lt;/P&gt;
&lt;P&gt;The ippsExp_32f_A24() routine does appear to allow us to do this. However, it does not mention whether we can call it with in place data i.e. p_src == p_dest. It appears to work with the one test I did but can I guarantee that it will work in the future?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
    <pubDate>Sun, 17 Sep 2006 04:05:08 GMT</pubDate>
    <dc:creator>davidrobb</dc:creator>
    <dc:date>2006-09-17T04:05:08Z</dc:date>
    <item>
      <title>Detecting Floating Point Exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911234#M14281</link>
      <description>We are writing a cross platform library consisting of a mixture of optimised C routines and and IPP math functions.&lt;BR /&gt;&lt;BR /&gt;We wish to be able to detect whether various floating point exceptions have occurred, namely FPE_INVALID, FPE_DIVBYZERO and FPE_OVERFLOW.&lt;BR /&gt;&lt;BR /&gt;Browsing on the net suggests that we should be able to use the services provided by &lt;FENV.H&gt; to provide this. This works well in most cases, but we run into problems when we call various IPP routines. These appear to mask any results that we might expect to find via the fegetexception() calls. One solution is to interpret the IPP return status and raise the appropriate exception. e.g. raise FPE_INVALID when ippsSqrt returns ippStsSqrtNegArg. This OK for a number of cases but breaks down with ippsExp_32f_I() which does not return a code for overflow ( example source below). Checking the fixed precision versions of the same I see I can call ippsExp_32f_A23() and get the overflow reported via ippStsOverflow (and strangely the FPE_OVERFLOW flag is set already). However, this routine does not appear to have an in-place flavour. Can I call it with src and dest pointing to the same thing?&lt;BR /&gt;&lt;BR /&gt;Is there a recommended method for achieving what I want?&lt;BR /&gt;&lt;BR /&gt;I have had a brief look at handling the exceptions using sigaction() but have been quickly scared off when discovering that doing so would require manual dissasembly of the code causing the exception and manipulation of the PC counter to recover.&lt;BR /&gt;&lt;BR /&gt;Code snippet below:-&lt;BR /&gt;





&lt;PRE&gt;&lt;SPAN style="color: rgb(225, 77, 27);"&gt;#include &lt;STDIO.H&gt;&lt;/STDIO.H&gt;&lt;/SPAN&gt;
&lt;SPAN style="color: rgb(225, 77, 27);"&gt;#include &lt;FENV.H&gt;&lt;/FENV.H&gt;&lt;/SPAN&gt;

&lt;SPAN style="color: rgb(225, 77, 27);"&gt;#include "ipp.h"&lt;/SPAN&gt;

&lt;SPAN style="color: rgb(128, 0, 0);"&gt;void&lt;/SPAN&gt; printFPE()
{
  &lt;B&gt;if&lt;/B&gt;( fetestexcept(FE_OVERFLOW))
  {
     printf(&lt;SPAN style="color: rgb(221, 0, 0);"&gt;" Floating point overflow&lt;/SPAN&gt;&lt;SPAN style="color: rgb(255, 0, 255);"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: rgb(221, 0, 0);"&gt;"&lt;/SPAN&gt;);
  }
  &lt;B&gt;if&lt;/B&gt;( fetestexcept(FE_INVALID))
  {
     printf(&lt;SPAN style="color: rgb(221, 0, 0);"&gt;" Floating point invalid&lt;/SPAN&gt;&lt;SPAN style="color: rgb(255, 0, 255);"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: rgb(221, 0, 0);"&gt;"&lt;/SPAN&gt;);
  }
  &lt;B&gt;if&lt;/B&gt;( fetestexcept(FE_DIVBYZERO))
  {
     printf(&lt;SPAN style="color: rgb(221, 0, 0);"&gt;" Floating point div by zero&lt;/SPAN&gt;&lt;SPAN style="color: rgb(255, 0, 255);"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: rgb(221, 0, 0);"&gt;"&lt;/SPAN&gt;);
  }
}

&lt;SPAN style="color: rgb(128, 0, 0);"&gt;int&lt;/SPAN&gt; main()
{
&lt;SPAN style="color: rgb(38, 170, 51);"&gt;&lt;I&gt;// #pragma STDC FENV_ACCESS ON&lt;/I&gt;&lt;/SPAN&gt;

   feclearexcept( FE_ALL_EXCEPT);
   &lt;SPAN style="color: rgb(128, 0, 0);"&gt;float&lt;/SPAN&gt; f = &lt;SPAN style="color: rgb(128, 0, 128);"&gt;90.0f&lt;/SPAN&gt;;
   &lt;SPAN style="color: rgb(128, 0, 0);"&gt;const&lt;/SPAN&gt; IppStatus st = ippsExp_32f_I( &amp;amp;f, &lt;SPAN style="color: rgb(0, 0, 255);"&gt;1&lt;/SPAN&gt;);

   printFPE();

   printf(&lt;SPAN style="color: rgb(221, 0, 0);"&gt;" f is %g.  Ipp returned %d&lt;/SPAN&gt;&lt;SPAN style="color: rgb(255, 0, 255);"&gt;
&lt;/SPAN&gt;&lt;SPAN style="color: rgb(221, 0, 0);"&gt;"&lt;/SPAN&gt;, f, st);

&lt;SPAN style="color: rgb(38, 170, 51);"&gt;&lt;I&gt;// #pragma STDC FENV_ACCESS OFF&lt;/I&gt;&lt;/SPAN&gt;
}
&lt;/PRE&gt;&lt;SPAN style="font-family: monospace;"&gt;&lt;/SPAN&gt;&lt;/FENV.H&gt;</description>
      <pubDate>Tue, 12 Sep 2006 20:55:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911234#M14281</guid>
      <dc:creator>davidrobb</dc:creator>
      <dc:date>2006-09-12T20:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Floating Point Exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911235#M14282</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;please take a look on our expert's comment&lt;/P&gt;&lt;FONT color="#000080" size="2"&gt;
&lt;P&gt;IPP does not mask any results. In case of Exp_32  it is known that all input values&lt;BR /&gt;above 88.72284&lt;BR /&gt;and below -87.33654&lt;BR /&gt;lead to overflow and underflow  therefore there is no any reason to do calculations for these inputs. &lt;/P&gt;
&lt;P&gt;Note, that processing of FP exceptions in FPU is very slow, you will loose performance benefits provided by IPP in that case.&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Regards,&lt;BR /&gt; Vladimir&lt;/P&gt;</description>
      <pubDate>Sat, 16 Sep 2006 02:09:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911235#M14282</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2006-09-16T02:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Floating Point Exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911236#M14283</link>
      <description>&lt;P&gt;Many thanks for the response, but this raisesa few further questions:-&lt;/P&gt;
&lt;P&gt;Presumably, you only pay the performance penalty if the exceptions do occur and IPP chooses to threshold the values and explicitly set 0 or inffor values outside the bounds you mention.&lt;/P&gt;
&lt;P&gt;99.99% of our datashould be within range so really we just want to flag that at least one item was out of range on the rare occasion that this does happen.&lt;/P&gt;
&lt;P&gt;The ippsExp_32f_A24() routine does appear to allow us to do this. However, it does not mention whether we can call it with in place data i.e. p_src == p_dest. It appears to work with the one test I did but can I guarantee that it will work in the future?&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;David&lt;/P&gt;</description>
      <pubDate>Sun, 17 Sep 2006 04:05:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911236#M14283</guid>
      <dc:creator>davidrobb</dc:creator>
      <dc:date>2006-09-17T04:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Floating Point Exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911237#M14284</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;there is comment from our experts&lt;/P&gt;&lt;FONT color="#0000ff" size="2"&gt;
&lt;P&gt;all fixed accuracy math functions (including &lt;/P&gt;&lt;/FONT&gt;&lt;FONT face="Arial CYR" size="2"&gt;ippsExp_32f_A24()&lt;/FONT&gt;&lt;FONT color="#0000ff" size="2"&gt;) support in-place prcossing, and during the product validation we test for in-place operations. Thankyou for bringing this documentation issue up. We will try to make the documentation clearer re the in-place support in fixed accuracy math functions.&lt;P&gt;&lt;/P&gt;&lt;/FONT&gt;
&lt;P&gt;Regards,&lt;BR /&gt; Vladimir&lt;/P&gt;</description>
      <pubDate>Wed, 20 Sep 2006 02:06:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911237#M14284</guid>
      <dc:creator>Vladimir_Dudnik</dc:creator>
      <dc:date>2006-09-20T02:06:01Z</dc:date>
    </item>
    <item>
      <title>Re: Detecting Floating Point Exceptions</title>
      <link>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911238#M14285</link>
      <description>Hi Vladimir,&lt;BR /&gt;&lt;BR /&gt;Thanks for that. That's good news about the in-place functionality. We should have a way forward with detecting the FP exceptions in that case.&lt;BR /&gt;&lt;BR /&gt;As an aside, I'm now puzzled by the behaviour of the behaviour of std::sqrt( float f). This produces a NaN and FP_INVALID for sqrt( inf) but a NaN and no exception for sqrt( -1.0f)!&lt;BR /&gt;&lt;BR /&gt;Also, a 1.0f / 0.0f produces FP_INVALID rather than FP_DIVBYZERO when vectorised!&lt;BR /&gt;&lt;BR /&gt;I need to do some more testing to establish whether it's just with this P4 SSE3 CPU or common to other CPU types.&lt;BR /&gt;&lt;BR /&gt;Questions to go and tackle the compiler writers with rather than here!&lt;BR /&gt;&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Dave Robb&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 20 Sep 2006 03:17:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Integrated-Performance/Detecting-Floating-Point-Exceptions/m-p/911238#M14285</guid>
      <dc:creator>davidrobb</dc:creator>
      <dc:date>2006-09-20T03:17:02Z</dc:date>
    </item>
  </channel>
</rss>

