<?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 Hi Johannes, in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123062#M25084</link>
    <description>&lt;P&gt;I think the issue is related to&amp;nbsp;the control mode set in&amp;nbsp;the MXCSR register&amp;nbsp;at runtime. By default, it's set to 0x9fc0 (i.e. FTZ and DAZ on) on Windows, that may have caused the hardware&amp;nbsp;instructions used by vmsExp to set the underflow exceptions unexpectedly. If you change MXCSR value to 0x1f80, that should solve your problem. Here is my test program and results:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;mkl.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;immintrin.h&amp;gt;

int main() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; float testData[] = {-88.77909088}; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("input&amp;nbsp; = %f = 0x%08x\n", testData[0], ((int*)testData)[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; errno = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("errno&amp;nbsp; = %d\n", errno);
&amp;nbsp;&amp;nbsp;&amp;nbsp; //_mm_setcsr(0x1f80);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("mxcsr&amp;nbsp; = %x\n", _mm_getcsr());
&amp;nbsp;&amp;nbsp;&amp;nbsp; vmsExp (1, testData, testData, VML_HA | VML_FTZDAZ_ON | VML_ERRMODE_IGNORE);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("result = %f = 0x%08x\n", testData[0], ((int*)testData)[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("errno&amp;nbsp; = %d\n", errno);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("mxcsr&amp;nbsp; = %x\n", _mm_getcsr());
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}&lt;/PRE&gt;

&lt;P&gt;Default result:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;input&amp;nbsp; = -88.779091 = 0xc2b18ee5
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 9fc0
result = 0.000000 = 0x00000000
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 9ff1&lt;/PRE&gt;

&lt;P&gt;If $MXCSR is set to 0x1f80:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;input&amp;nbsp; = -88.779091 = 0xc2b18ee5
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 1f80
result = 0.000000 = 0x00000000
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 1f80&lt;/PRE&gt;

&lt;P&gt;Please let me know if this helps.&lt;/P&gt;</description>
    <pubDate>Thu, 12 May 2016 16:46:31 GMT</pubDate>
    <dc:creator>Jingwei_Z_Intel</dc:creator>
    <dc:date>2016-05-12T16:46:31Z</dc:date>
    <item>
      <title>Underflow exception when using vmsExp</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123061#M25083</link>
      <description>&lt;P&gt;The following code generates an exception, although I set the error mode to VML_ERRMODE_IGNORE. Is there a way to use high accuracy (VML_HA) computations without raising underflow exceptions when computing exp (-88.) ?&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;float testData[1] = {-88.77909088};
vmsExp (1, testData, testData, VML_HA | VML_FTZDAZ_ON | VML_ERRMODE_IGNORE);
&lt;/PRE&gt;

&lt;P&gt;&lt;BR /&gt;
	I am using the Intel MKL version 11.3.2 with Visual Studio 2013, statically linking mkl_intel_c.lib, mkl_core.lib and mkl_sequential.lib into my project.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 08:01:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123061#M25083</guid>
      <dc:creator>Johannes_B_1</dc:creator>
      <dc:date>2016-05-11T08:01:36Z</dc:date>
    </item>
    <item>
      <title>Hi Johannes,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123062#M25084</link>
      <description>&lt;P&gt;I think the issue is related to&amp;nbsp;the control mode set in&amp;nbsp;the MXCSR register&amp;nbsp;at runtime. By default, it's set to 0x9fc0 (i.e. FTZ and DAZ on) on Windows, that may have caused the hardware&amp;nbsp;instructions used by vmsExp to set the underflow exceptions unexpectedly. If you change MXCSR value to 0x1f80, that should solve your problem. Here is my test program and results:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;mkl.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;immintrin.h&amp;gt;

int main() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; float testData[] = {-88.77909088}; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("input&amp;nbsp; = %f = 0x%08x\n", testData[0], ((int*)testData)[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; errno = 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("errno&amp;nbsp; = %d\n", errno);
&amp;nbsp;&amp;nbsp;&amp;nbsp; //_mm_setcsr(0x1f80);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("mxcsr&amp;nbsp; = %x\n", _mm_getcsr());
&amp;nbsp;&amp;nbsp;&amp;nbsp; vmsExp (1, testData, testData, VML_HA | VML_FTZDAZ_ON | VML_ERRMODE_IGNORE);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("result = %f = 0x%08x\n", testData[0], ((int*)testData)[0]);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("errno&amp;nbsp; = %d\n", errno);
&amp;nbsp;&amp;nbsp;&amp;nbsp; printf("mxcsr&amp;nbsp; = %x\n", _mm_getcsr());
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;
}&lt;/PRE&gt;

&lt;P&gt;Default result:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;input&amp;nbsp; = -88.779091 = 0xc2b18ee5
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 9fc0
result = 0.000000 = 0x00000000
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 9ff1&lt;/PRE&gt;

&lt;P&gt;If $MXCSR is set to 0x1f80:&lt;/P&gt;

&lt;PRE class="brush:bash;"&gt;input&amp;nbsp; = -88.779091 = 0xc2b18ee5
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 1f80
result = 0.000000 = 0x00000000
errno&amp;nbsp; = 0
mxcsr&amp;nbsp; = 1f80&lt;/PRE&gt;

&lt;P&gt;Please let me know if this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 12 May 2016 16:46:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123062#M25084</guid>
      <dc:creator>Jingwei_Z_Intel</dc:creator>
      <dc:date>2016-05-12T16:46:31Z</dc:date>
    </item>
    <item>
      <title>Thank you very much! The</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123063#M25085</link>
      <description>&lt;P&gt;Thank you very much!&lt;/P&gt;

&lt;P&gt;The solution works, although I figured out after a while, that the FTZ and DAZ flags do not seem to have something to do with it. I rather have to set the "invalid operation mask" to get the code working, using the following instructions:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;_mm_setcsr (_mm_getcsr() | _MM_MASK_INVALID);&lt;/PRE&gt;

&lt;P&gt;Also, in my case, the default value of the MXCSR register seems to be 0x1920 instead of 0x9FC0 and may have something to do with the compiler optimization options.&lt;/P&gt;</description>
      <pubDate>Fri, 13 May 2016 09:25:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Underflow-exception-when-using-vmsExp/m-p/1123063#M25085</guid>
      <dc:creator>Johannes_B_1</dc:creator>
      <dc:date>2016-05-13T09:25:00Z</dc:date>
    </item>
  </channel>
</rss>

