<?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: Wrong Results in Matrix Inversion in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881127#M9595</link>
    <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Hello Sisnett,&lt;BR /&gt;&lt;BR /&gt;First of all, if you plan to use cluster version of MKL LAPACK (ScaLAPACK) your link line should be like this:&lt;BR /&gt;&lt;BR /&gt;$MKLPATH/libmkl_scalapack_ilp64.a $MKLPATH/libmkl_solver_ilp64_sequential.a -Wl,--start-group $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a $MKLPATH/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -lpthread&lt;BR /&gt;&lt;BR /&gt;Here MKLPATH is a full path to MKL lib/em64t directory.&lt;BR /&gt; &lt;BR /&gt;Please try to use this tool to adjust correct linking parameters:&lt;BR /&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/" target="_blank"&gt;http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As I can see from your post you tried to use ILP64 model. In this case you should add -DMKL_ILP64 compiler option for ILP64 interface support in MKL. Also you should use MKL_INT type instead of int.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Art&lt;BR /&gt;</description>
    <pubDate>Sat, 21 Nov 2009 06:35:06 GMT</pubDate>
    <dc:creator>Artem_V_Intel</dc:creator>
    <dc:date>2009-11-21T06:35:06Z</dc:date>
    <item>
      <title>Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881122#M9590</link>
      <description>Hi, I'm trying to invert a very large matrix (625 x 625) using MKL.
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;However I'm getting several problems:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;First of all something as simple as (taken from a previous post):
&lt;PRE&gt;[cpp]#include &lt;MKL.H&gt;
#include &lt;STDIO.H&gt;


int main(){
int SIZE = 3;
double *a = new double [SIZE*SIZE];

for(int i = 0; i &amp;lt; SIZE; i++ ) {
for(int j = 0; j &amp;lt; SIZE; j++ ) {
a[j*SIZE+i] = (double) (i+j+1)*(2*i-j);
}
}

int info = 0;
int lworkspace = SIZE;//-1;    !!!!!!
int *ipiv = new int [SIZE];
dgetrf(&amp;amp;SIZE, &amp;amp;SIZE, a, &amp;amp;SIZE, ipiv, &amp;amp;info);

//double workspace;  !!!!! this is array
double* workspace = new double [lworkspace * sizeof(double)];
dgetri(&amp;amp;SIZE, a, &amp;amp;SIZE, ipiv, workspace, &amp;amp;lworkspace, &amp;amp;info);

for(int i = 0; i &amp;lt; SIZE; i++ ) {
   for(int j = 0; j &amp;lt; SIZE; j++ ) {
      printf(" %lf", a[j*SIZE+i] );
   }
   printf("n");
}


}
[/cpp]&lt;/STDIO.H&gt;&lt;/MKL.H&gt;&lt;/PRE&gt;
keeps giving me segmentation fault.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;The real application, on the other hand is giving me wrong results.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Original Matrix&lt;/DIV&gt;
&lt;DIV&gt;1.51225 -0.488091 0&lt;BR /&gt;-0.0795172 1.44725 -0.367735&lt;BR /&gt;0 -0.192743 1.44582&lt;BR /&gt;&lt;BR /&gt;PIVOTS&lt;/DIV&gt;
&lt;DIV&gt;1 0 2 0 3 0&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Factored after dgetrf&lt;BR /&gt; 0.512247 -0.952843 0&lt;BR /&gt; -0.0795172 0.371484 -0.989907&lt;BR /&gt; 0 -0.192743 0.255018&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Inverse after dgetri&lt;BR /&gt;2.64824 4.484 3.69867&lt;BR /&gt;0.73051 4.70592 3.88172&lt;BR /&gt;0.315827 2.03455 3.9213&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;However this doesn't seems right.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Any pointers will be thanked.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Sisnett&lt;/DIV&gt;</description>
      <pubDate>Thu, 19 Nov 2009 18:29:35 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881122#M9590</guid>
      <dc:creator>rsisnett</dc:creator>
      <dc:date>2009-11-19T18:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881123#M9591</link>
      <description>&lt;DIV style="margin:0px;"&gt;&lt;/DIV&gt;
Hello Sisnett,&lt;BR /&gt;&lt;BR /&gt;Could you please specify platform and architecture you are working on? Also could you specify link line you used?&lt;BR /&gt;&lt;BR /&gt;I tried to build and run example you submitted on Linux Intel64 and doesn't obtain any issues. Please see the results below:&lt;BR /&gt;&lt;BR /&gt;$ make&lt;BR /&gt;icpc -o test main.cpp -I/opt/intel/Compiler/11.1/046/mkl/include -Wl,--start-group /opt/intel/Compiler/11.1/046/mkl/lib/em64t/libmkl_intel_lp64.a /opt/intel/Compiler/11.1/046/mkl/lib/em64t/libmkl_intel_thread.a /opt/intel/Compiler/11.1/046/mkl/lib/em64t/libmkl_core.a -Wl,--end-group -openmp -lpthread&lt;BR /&gt;$ ./test&lt;BR /&gt; 3.750000 -6.500000 2.250000&lt;BR /&gt; -5.000000 9.000000 -3.000000&lt;BR /&gt; 1.500000 -3.000000 1.000000&lt;BR /&gt;&lt;BR /&gt;Also I wrote a simple program that computes the inverse of matrix you submitted:&lt;BR /&gt;
&lt;PRE&gt;[cpp]#include &lt;STDIO.H&gt;
#include &lt;MKL.H&gt;

int main(int argc, char *argv[])
{
	int		n = 3, ipiv[3], info = 0, lwork = 3, i, j;
	double	a[9] = {1.51225, -0.0795172, 0.0, 
					-0.488091, 1.44725, -0.192743,
					0.0, -0.367735, 1.44582};
	double	work[3];

	for(i = 0; i &amp;lt; n; i++)
	{
		for(j = 0; j &amp;lt; n; j++)
		{
			printf("%15.13ft", a[j*n + i]);
		}
		printf("n");
	}
	printf("n");

	dgetrf(&amp;amp;n, &amp;amp;n, a, &amp;amp;n, ipiv, &amp;amp;info);
	if(info)
	{
		printf("info = %dn", info);
		return 1;
	}

	for(i = 0; i &amp;lt; n; i++)
	{
		for(j = 0; j &amp;lt; n; j++)
		{
			printf("%15.13ft", a[j*n + i]);
		}
		printf("n");
	}
	printf("n");

	dgetri(&amp;amp;n, a, &amp;amp;n, ipiv, work, &amp;amp;lwork, &amp;amp;info);
	if(info)
	{
		printf("info = %dn", info);
		return 1;
	}
	
	for(i = 0; i &amp;lt; n; i++)
	{
		for(j = 0; j &amp;lt; n; j++)
		{
			printf("%15.13ft", a[j*n + i]);
		}
		printf("n");
	}
	return 0;
}
[/cpp]&lt;/MKL.H&gt;&lt;/STDIO.H&gt;&lt;/PRE&gt;
I built and ran this on Win32 in sequential mode.&lt;BR /&gt;The result of the program run:&lt;BR /&gt;1.5122500000000 -0.4880910000000 0.0000000000000 &lt;BR /&gt;-0.0795172000000 1.4472500000000 -0.3677350000000 &lt;BR /&gt;0.0000000000000 -0.1927430000000 1.4458200000000 &lt;BR /&gt;&lt;BR /&gt;1.5122500000000 -0.4880910000000 0.0000000000000 &lt;BR /&gt;-0.0525820466193 1.4215851762836 -0.3677350000000 &lt;BR /&gt;0.0000000000000 -0.1355831526774 1.3959613293502 &lt;BR /&gt;&lt;BR /&gt;0.6736309983309 0.2351500961549 0.0598089116277 &lt;BR /&gt;0.0383094079300 0.7285644130096 0.1853056635114 &lt;BR /&gt;0.0051070466674 0.0971252926759 0.7163522219240 &lt;BR /&gt;&lt;BR /&gt;That seems correct.&lt;BR /&gt;&lt;BR /&gt;Also may be this &lt;A href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/" target="_blank"&gt;article&lt;/A&gt; will be useful.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Art&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Nov 2009 12:05:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881123#M9591</guid>
      <dc:creator>Artem_V_Intel</dc:creator>
      <dc:date>2009-11-20T12:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881124#M9592</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/452954"&gt;rsisnett&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;Hi, I'm trying to invert a very large matrix (625 x 625) using MKL.
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;However I'm getting several problems:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;First of all something as simple as (taken from a previous post):
&lt;PRE&gt;[cpp]#include &lt;MKL.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;int main(){&lt;BR /&gt;int SIZE = 3;&lt;BR /&gt;double *a = new double [SIZE*SIZE];&lt;BR /&gt;&lt;BR /&gt;for(int i = 0; i &amp;lt; SIZE; i++ ) {&lt;BR /&gt;for(int j = 0; j &amp;lt; SIZE; j++ ) {&lt;BR /&gt;a[j*SIZE+i] = (double) (i+j+1)*(2*i-j);&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;int info = 0;&lt;BR /&gt;int lworkspace = SIZE;//-1;    !!!!!!&lt;BR /&gt;int *ipiv = new int [SIZE];&lt;BR /&gt;dgetrf(&amp;amp;SIZE, &amp;amp;SIZE, a, &amp;amp;SIZE, ipiv, &amp;amp;info);&lt;BR /&gt;&lt;BR /&gt;//double workspace;  !!!!! this is array&lt;BR /&gt;double* workspace = new double [lworkspace * sizeof(double)];&lt;BR /&gt;dgetri(&amp;amp;SIZE, a, &amp;amp;SIZE, ipiv, workspace, &amp;amp;lworkspace, &amp;amp;info);&lt;BR /&gt;&lt;BR /&gt;for(int i = 0; i &amp;lt; SIZE; i++ ) {&lt;BR /&gt;   for(int j = 0; j &amp;lt; SIZE; j++ ) {&lt;BR /&gt;      printf(" %lf", a[j*SIZE+i] );&lt;BR /&gt;   }&lt;BR /&gt;   printf("n");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;[/cpp]&lt;/STDIO.H&gt;&lt;/MKL.H&gt;&lt;/PRE&gt;
keeps giving me segmentation fault.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;The real application, on the other hand is giving me wrong results.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Original Matrix&lt;/DIV&gt;
&lt;DIV&gt;1.51225 -0.488091 0&lt;BR /&gt;-0.0795172 1.44725 -0.367735&lt;BR /&gt;0 -0.192743 1.44582&lt;BR /&gt;&lt;BR /&gt;PIVOTS&lt;/DIV&gt;
&lt;DIV&gt;1 0 2 0 3 0&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Factored after dgetrf&lt;BR /&gt; 0.512247 -0.952843 0&lt;BR /&gt; -0.0795172 0.371484 -0.989907&lt;BR /&gt; 0 -0.192743 0.255018&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Inverse after dgetri&lt;BR /&gt;2.64824 4.484 3.69867&lt;BR /&gt;0.73051 4.70592 3.88172&lt;BR /&gt;0.315827 2.03455 3.9213&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;However this doesn't seems right.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Any pointers will be thanked.&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Sisnett&lt;/DIV&gt;
&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
Hi there. I am just curious how do you get your codes highlighted? I found the website of syntaxhighlighter but have no idea how to use it. Thanks.&lt;BR /&gt;</description>
      <pubDate>Fri, 20 Nov 2009 15:54:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881124#M9592</guid>
      <dc:creator>yjyincj</dc:creator>
      <dc:date>2009-11-20T15:54:05Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881125#M9593</link>
      <description>&lt;DIV style="margin:0px;"&gt;Hello,&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;There is a special button in editor for this:&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;&lt;span class="lia-inline-image-display-wrapper"&gt;&lt;img src="https://community.intel.com/skins/images/7B13F55A7CE623EF42E69096FA81A3A1/2021_redesign/images/image_not_found.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Thanks,&lt;/DIV&gt;
&lt;DIV style="margin:0px;"&gt;Art&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Nov 2009 16:07:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881125#M9593</guid>
      <dc:creator>Artem_V_Intel</dc:creator>
      <dc:date>2009-11-20T16:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881126#M9594</link>
      <description>&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;My compile Script is: &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
icc $1 -o $2 -g -w -L$MKLPATH $MKLPATH/libmkl_solver_ilp64_sequential.a -Wl,--start-group -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -Wl,--end-group -lpthread -I/share/apps/intel/ict/impi/3.2.1.009/include64 -L/share/apps/intel/ict/impi/3.2.1.009/lib64 -lmpigc4 -Xlinker --enable-new-dtags -Xlinker -rpath -Xlinker $libdir -Xlinker -rpath -Xlinker -lmpi -lmpigf -lmpigi -lrt -lpthread -ldl&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN style="font-family: Verdana, Arial, Helvetica, sans-serif;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;(I'm also using MPI so half of the script links to mpi libraries)&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;The environment I'm running in:&lt;/DIV&gt;
&lt;DIV&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;DIV&gt;Red Hat Linux Enterprise Edition 64-bits Architecture&lt;/DIV&gt;
&lt;DIV&gt;Xeon Cuad Core Processors&lt;/DIV&gt;
&lt;DIV&gt;MKL 10.2.0.013&lt;/DIV&gt;</description>
      <pubDate>Fri, 20 Nov 2009 16:19:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881126#M9594</guid>
      <dc:creator>rsisnett</dc:creator>
      <dc:date>2009-11-20T16:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Wrong Results in Matrix Inversion</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881127#M9595</link>
      <description>&lt;DIV style="margin: 0px; height: auto;"&gt;&lt;/DIV&gt;
&lt;BR /&gt;Hello Sisnett,&lt;BR /&gt;&lt;BR /&gt;First of all, if you plan to use cluster version of MKL LAPACK (ScaLAPACK) your link line should be like this:&lt;BR /&gt;&lt;BR /&gt;$MKLPATH/libmkl_scalapack_ilp64.a $MKLPATH/libmkl_solver_ilp64_sequential.a -Wl,--start-group $MKLPATH/libmkl_intel_ilp64.a $MKLPATH/libmkl_sequential.a $MKLPATH/libmkl_core.a $MKLPATH/libmkl_blacs_intelmpi_ilp64.a -Wl,--end-group -lpthread&lt;BR /&gt;&lt;BR /&gt;Here MKLPATH is a full path to MKL lib/em64t directory.&lt;BR /&gt; &lt;BR /&gt;Please try to use this tool to adjust correct linking parameters:&lt;BR /&gt;&lt;A href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/" target="_blank"&gt;http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;As I can see from your post you tried to use ILP64 model. In this case you should add -DMKL_ILP64 compiler option for ILP64 interface support in MKL. Also you should use MKL_INT type instead of int.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Art&lt;BR /&gt;</description>
      <pubDate>Sat, 21 Nov 2009 06:35:06 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Wrong-Results-in-Matrix-Inversion/m-p/881127#M9595</guid>
      <dc:creator>Artem_V_Intel</dc:creator>
      <dc:date>2009-11-21T06:35:06Z</dc:date>
    </item>
  </channel>
</rss>

