<?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: DGEMM inconsistent result in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321270#M32180</link>
    <description>&lt;P&gt;Dear Vidya,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the detailed answer and test. I am able to obtain correct result using cblas_dgemm as you suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 06:59:10 GMT</pubDate>
    <dc:creator>Viet-Duc</dc:creator>
    <dc:date>2021-10-12T06:59:10Z</dc:date>
    <item>
      <title>DGEMM inconsistent result</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1320287#M32165</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Library version: 2021.3&lt;/LI&gt;
&lt;LI&gt;OS info and version: CentOS 7.9.2009&lt;/LI&gt;
&lt;LI&gt;Compiler verison: icc version 2021.3.0 (gcc version 4.8.5 compatibility)&lt;/LI&gt;
&lt;LI&gt;MKL linking command:&lt;/LI&gt;
&lt;/UL&gt;
&lt;LI-CODE lang="markup"&gt;icc -O2 -std=c11 -mkl=sequential -L$MKLROOT/lib/intel64 dgemm.c -o dgemm.x&lt;/LI-CODE&gt;
&lt;UL&gt;
&lt;LI&gt;Reference: &lt;A href="https://software.intel.com/content/www/us/en/develop/documentation/mkl-tutorial-c/top/multiplying-matrices-using-dgemm.html" target="_blank"&gt;https://software.intel.com/content/www/us/en/develop/documentation/mkl-tutorial-c/top/multiplying-matrices-using-dgemm.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dear Support Team,&lt;/P&gt;
&lt;P&gt;I am measuring performance of matrix multiplication using dgemm().&lt;/P&gt;
&lt;P&gt;The code to reproduce the issue is attached. dgemm() was invoked as following:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dgemm("N", "N", &amp;amp;m, &amp;amp;n, &amp;amp;p, &amp;amp;alpha, A, &amp;amp;p, B, &amp;amp;n, &amp;amp;beta, C, &amp;amp;n);&lt;/LI-CODE&gt;
&lt;P&gt;The example is a simple 3x3 multiplication. In the source code, there are two ways to initialize A and B. I marked these two methods with approriate comments in the file.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Double casting of interger: this gives correct C &lt;/LI&gt;
&lt;LI&gt;Random number between (0,1]: this gives incorrect C&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;To rule out the possibility of thread interference, I linked with the sequential version of the library.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The file 'correct.txt' is the expected output for randomized input matrices.&lt;/P&gt;
&lt;P&gt;The file 'incorrect.txt' is the result I obtained with dgemm() for randomized input matrices&lt;/P&gt;
&lt;P&gt;I appreciate if you can point me to the origin of this inconsistency.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;dgemm.c: &lt;A href="https://justpaste.it/7zhsb" target="_blank"&gt;https://justpaste.it/7zhsb&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;correct.txt: &lt;A href="https://justpaste.it/6mizg" target="_blank"&gt;https://justpaste.it/6mizg&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;incorrect.txt: &lt;A href="https://justpaste.it/5g7bi" target="_blank"&gt;https://justpaste.it/5g7bi&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;(For some reason, I could not attach the files using forum, I appologize for the inconvenience)&lt;/P&gt;</description>
      <pubDate>Fri, 08 Oct 2021 07:55:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1320287#M32165</guid>
      <dc:creator>Viet-Duc</dc:creator>
      <dc:date>2021-10-08T07:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: DGEMM inconsistent result</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321257#M32179</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for reaching out to us.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We tried the provided code from our end and could reproduce the results which you are getting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But here are some observations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To check the results we used cblas_dgemm where you will get an option to change the matrix layout (Row Major or Col Major)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the function call&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, m, n, p, alpha, A, p, B, n, beta, C, n);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By using the above function call, we observed it is giving the correct result (matches with your expected result)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, m, n, p, alpha, A, p, B, n, beta, C, n);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;whereas the above function call gives the output which matches with your incorrect result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VidyalathaB_Intel_0-1634017870163.png" style="width: 400px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/19892iB43BF8BB8DF60B7F/image-size/medium?v=v2&amp;amp;px=400&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="VidyalathaB_Intel_0-1634017870163.png" alt="VidyalathaB_Intel_0-1634017870163.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;I&gt;&amp;gt;&amp;gt;dgemm("N", "N", &amp;amp;m, &amp;amp;n, &amp;amp;p, &amp;amp;alpha, A, &amp;amp;p, B, &amp;amp;n, &amp;amp;beta, C, &amp;amp;n);&lt;/I&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default dgemm follows the matrix layout as column-major, hence there is a mismatch in your expected and actual results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find the attached file for the code snippet we have tried.&lt;/P&gt;
&lt;P&gt;Hope the provided information helped.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Vidya.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:15:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321257#M32179</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-10-12T06:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: DGEMM inconsistent result</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321270#M32180</link>
      <description>&lt;P&gt;Dear Vidya,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the detailed answer and test. I am able to obtain correct result using cblas_dgemm as you suggested.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 06:59:10 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321270#M32180</guid>
      <dc:creator>Viet-Duc</dc:creator>
      <dc:date>2021-10-12T06:59:10Z</dc:date>
    </item>
    <item>
      <title>Re:DGEMM inconsistent result</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321272#M32181</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for accepting our solution.&lt;/P&gt;&lt;P&gt;As this issue is resolved, we are closing this thread. Please post a new question if you need any additional information from Intel as this thread will no longer be monitored.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Have a Good Day!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vidya.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:07:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/DGEMM-inconsistent-result/m-p/1321272#M32181</guid>
      <dc:creator>VidyalathaB_Intel</dc:creator>
      <dc:date>2021-10-12T07:07:37Z</dc:date>
    </item>
  </channel>
</rss>

