<?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 please help, thanks! in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072247#M22336</link>
    <description>please help, thanks!</description>
    <pubDate>Tue, 13 Sep 2016 00:28:08 GMT</pubDate>
    <dc:creator>ado</dc:creator>
    <dc:date>2016-09-13T00:28:08Z</dc:date>
    <item>
      <title>incorrect dgemm results</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072246#M22335</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I was using random matrix to test some code. I found dgemm gave wrong results sometimes. If I use truncated precision as copied from the console display, the results can be correct again. So I saved the generated matrix to a binary file and attached it (I changed the file extension to .cpp so I could upload it to this post). Could you take a look and let me know what went wrong?&lt;/P&gt;

&lt;P&gt;output is incorrect:&lt;/P&gt;

&lt;P&gt;&amp;nbsp;A=[&lt;BR /&gt;
	&amp;nbsp;7064610704830808.00000000 -2571117317297868.50000000 371407000938997.87500000&lt;BR /&gt;
	&amp;nbsp;6397257092471370.00000000 -2328238480630291.00000000 336322292936225.12500000&lt;BR /&gt;
	&amp;nbsp;-29483308061538568.00000000 10730250695401230.00000000 -1550022709306368.50000000&lt;BR /&gt;
	&amp;nbsp;-14929918819165514.00000000 5433643044981792.00000000 -784908978650044.00000000&lt;BR /&gt;
	]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;B=[&lt;BR /&gt;
	&amp;nbsp;-0.20072837 -0.01530215&lt;BR /&gt;
	&amp;nbsp;-0.57723645 -0.10924951&lt;BR /&gt;
	&amp;nbsp;-0.17790418 -0.46522968&lt;BR /&gt;
	]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;Out=[&lt;BR /&gt;
	&amp;nbsp;-2.00000000 -0.53125000&lt;BR /&gt;
	&amp;nbsp;0.27343750 1.50000000&lt;BR /&gt;
	&amp;nbsp;0.81250000 1.12500000&lt;BR /&gt;
	&amp;nbsp;-0.26562500 -2.68750000&lt;BR /&gt;
	]&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;iostream&amp;gt;
#include &amp;lt;fstream&amp;gt;
#include &amp;lt;iomanip&amp;gt;
#include &amp;lt;mkl.h&amp;gt;

using namespace std;

void print_matrix( char* desc, MKL_INT m, MKL_INT n, double* a, MKL_INT lda );

int main()
{
		int m=4, n=3,k=2;                                
        double * A= new double [m*n];
        double * B= new double [n*k];                                                      
        double * out= new double [m*k];

		ifstream infile;
		infile.open("matrix3.cpp", ios::binary | ios::in);
        infile.read((char *)&amp;amp;A[0], m*n*sizeof(double));
        infile.read((char *)&amp;amp;B[0], n*k*sizeof(double));
        infile.close();

		cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, 
                m, k, n, 1.0, A, n, B, k, 0.0, out, k);

		print_matrix("A=[",m,n,A,n);  
        print_matrix("B=[",n,k,B,k);
        print_matrix("Out=[",m,k,out,k);       

		delete[] A;
		delete[] B;
		delete[] out;
		return 0;

}

void print_matrix( char* desc, MKL_INT m, MKL_INT n, double* a, MKL_INT lda ) {
        MKL_INT i, j;
        printf( "\n %s\n", desc );
        for( i = 0; i &amp;lt; m; i++ ) {
                for( j = 0; j &amp;lt; n; j++ ) printf( " %6.8f", a[i*lda+j] );
                printf( "\n" );
        }
                printf( "]\n" );
}
&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Sep 2016 12:38:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072246#M22335</guid>
      <dc:creator>ado</dc:creator>
      <dc:date>2016-09-11T12:38:37Z</dc:date>
    </item>
    <item>
      <title>please help, thanks!</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072247#M22336</link>
      <description>please help, thanks!</description>
      <pubDate>Tue, 13 Sep 2016 00:28:08 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072247#M22336</guid>
      <dc:creator>ado</dc:creator>
      <dc:date>2016-09-13T00:28:08Z</dc:date>
    </item>
    <item>
      <title>Hi arth,</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072248#M22337</link>
      <description>&lt;P&gt;Hi arth,&lt;/P&gt;

&lt;P&gt;Please see our reply in&amp;nbsp;&lt;A href="https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/685034"&gt;https://software.intel.com/en-us/forums/intel-math-kernel-library/topic/685034&lt;/A&gt;, I will close this post that is same question with above link. Thank you.&lt;/P&gt;

&lt;P&gt;Best regards,&lt;BR /&gt;
	Fiona&lt;/P&gt;</description>
      <pubDate>Tue, 13 Sep 2016 03:13:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/incorrect-dgemm-results/m-p/1072248#M22337</guid>
      <dc:creator>Zhen_Z_Intel</dc:creator>
      <dc:date>2016-09-13T03:13:54Z</dc:date>
    </item>
  </channel>
</rss>

