<?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 Gustafsson, bengt in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153590#M27371</link>
    <description>&lt;P&gt;Hi Gustafsson, bengt&lt;/P&gt;

&lt;P&gt;Thank you for raising the question.&amp;nbsp; So&amp;nbsp;as i understand, that&amp;nbsp;&amp;nbsp;the original problem&amp;nbsp;is &amp;nbsp;the code won't work&amp;nbsp;in release mode, the possible reason is XMM7-8 registers (and possibly more) are not preserved.&amp;nbsp; As. &lt;A href="https://stackoverflow.com/questions/262162/why-did-windows-64-choose-to-require-xmm6-and-xmm7-to-be-saved-restored"&gt;https://stackoverflow.com/questions/262162/why-did-windows-64-choose-to-require-xmm6-and-xmm7-to-be-saved-restored&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Could you please tell what kind of CPU you are using? does the code work for other machine?&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Mar 2018 02:44:03 GMT</pubDate>
    <dc:creator>Ying_H_Intel</dc:creator>
    <dc:date>2018-03-20T02:44:03Z</dc:date>
    <item>
      <title>DNN convolution does not preserve XMM registers as it should.</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153588#M27369</link>
      <description>&lt;P&gt;When running a MKL_DNN operation previously created using&amp;nbsp;dnnConvolutionCreateForwardBias_F32() the XMM7-8 registers (and possibly more) are not preserved.&lt;/P&gt;

&lt;P&gt;I have code similar to this (but of course much more elaborate) which does not work in relase mode:&lt;/P&gt;

&lt;PRE class="brush:;"&gt;
void RunConvolution() {
    dnnPrimitive_t handle;

    dnnConvolutionCreateForwardBias_F32(&amp;amp;handle, --- other pars ---);

    void* resources[dnnResourceNumber];
    --- fill in pointers to buffers, kernel and bias ---

    dnnExecute_F32(handle, resources);
}


void main()
{
    Timer timer;
    for (o =0; o &amp;lt; 10; o++) {
        for (int i = 0; i &amp;lt; 10; i++)
            RunConvolution();

        cout &amp;lt;&amp;lt; timer.Elapsed() / 10.0 &amp;lt;&amp;lt; endl;
    }
}

&lt;/PRE&gt;

&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;I am using the Visual Studio 2017 compiler and I noted it uses XMM7 to store the constant 10.0 _over_ the entire loops which calls RunConvolution(). I tracked the contents of the register and noted that it is destroyed by&amp;nbsp;dnnExecute_F32() but that's just a thin wrapper so the actual problem is probably in some assembly code in the function redirected to when the handle&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em;"&gt;refers to a structure created by&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 13.008px;"&gt;dnnConvolutionCreateForwardBias_F32().&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;According to Microsoft documentation XMM6 and up are to be preserved over function calls, so the numbers printed are bogus. I can't see any other explanation for this than that the calling convention has been breached by the MKL DNN code.&lt;/P&gt;

&lt;P&gt;I am using MKL 2018.1 version, 64 bit, static linking with intel threading (not TBB).&lt;/P&gt;

&lt;P&gt;I have not tested other operations except&amp;nbsp;&lt;SPAN style="font-size: 13.008px;"&gt;dnnConvolutionCreateForwardBias_F32.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 13:36:50 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153588#M27369</guid>
      <dc:creator>gustafsson__bengt</dc:creator>
      <dc:date>2018-03-14T13:36:50Z</dc:date>
    </item>
    <item>
      <title>dnnConversionExecute_F32()</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153589#M27370</link>
      <description>&lt;P&gt;dnnConversionExecute_F32() also does not preserve registers properly.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 14:26:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153589#M27370</guid>
      <dc:creator>gustafsson__bengt</dc:creator>
      <dc:date>2018-03-19T14:26:56Z</dc:date>
    </item>
    <item>
      <title>Hi Gustafsson, bengt</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153590#M27371</link>
      <description>&lt;P&gt;Hi Gustafsson, bengt&lt;/P&gt;

&lt;P&gt;Thank you for raising the question.&amp;nbsp; So&amp;nbsp;as i understand, that&amp;nbsp;&amp;nbsp;the original problem&amp;nbsp;is &amp;nbsp;the code won't work&amp;nbsp;in release mode, the possible reason is XMM7-8 registers (and possibly more) are not preserved.&amp;nbsp; As. &lt;A href="https://stackoverflow.com/questions/262162/why-did-windows-64-choose-to-require-xmm6-and-xmm7-to-be-saved-restored"&gt;https://stackoverflow.com/questions/262162/why-did-windows-64-choose-to-require-xmm6-and-xmm7-to-be-saved-restored&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Could you please tell what kind of CPU you are using? does the code work for other machine?&lt;/P&gt;

&lt;P&gt;Best Regards,&lt;/P&gt;

&lt;P&gt;Ying&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 02:44:03 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153590#M27371</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2018-03-20T02:44:03Z</dc:date>
    </item>
    <item>
      <title>The issue is, as you presumed</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153591#M27372</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 13.008px;"&gt;The issue is, as you presumed, that you violate the register saving convention that XMM6-7 have to be preserved, and that Microsoft compilers (both 2013 and 2017) rely on these registers actually being preserved.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;I'm running a Intel i7-8700.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Mar 2018 14:35:36 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153591#M27372</guid>
      <dc:creator>gustafsson__bengt</dc:creator>
      <dc:date>2018-03-20T14:35:36Z</dc:date>
    </item>
    <item>
      <title>Hi Gustafssion,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153592#M27373</link>
      <description>Hi Gustafssion, 

Yeah, there is such a problem.
We fixed it in Intel MKL 2018 U2 and above, which is supposed to be available soon. You may check the forum announcement

Thank you
Ying</description>
      <pubDate>Wed, 21 Mar 2018 01:05:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153592#M27373</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2018-03-21T01:05:23Z</dc:date>
    </item>
    <item>
      <title>I tested this with MKL2018.2</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153593#M27374</link>
      <description>&lt;P&gt;I tested this with MKL2018.2 and it fixed the problem.&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em;"&gt;Thanks for the good work!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 07:25:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153593#M27374</guid>
      <dc:creator>gustafsson__bengt</dc:creator>
      <dc:date>2018-03-29T07:25:11Z</dc:date>
    </item>
    <item>
      <title>Hi Gustafsson,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153594#M27375</link>
      <description>&lt;P&gt;Hi Gustafsson,&lt;/P&gt;

&lt;P&gt;Thank you a lot for the&amp;nbsp;confirmation!&lt;BR /&gt;
	&lt;BR /&gt;
	Thanks,&lt;BR /&gt;
	​Ying&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Mar 2018 07:52:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DNN-convolution-does-not-preserve-XMM-registers-as-it-should/m-p/1153594#M27375</guid>
      <dc:creator>Ying_H_Intel</dc:creator>
      <dc:date>2018-03-29T07:52:33Z</dc:date>
    </item>
  </channel>
</rss>

