<?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 LU factorization problem in C/C++ in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816708#M4333</link>
    <description>Thanks Gennady,&lt;BR /&gt;&lt;BR /&gt;As you suggest I modified the command line as :&lt;BR /&gt;&lt;B&gt;icc main.cpp -L/opt/intel/Compiler/11.0/083/mkl/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -openmp -lpthread -lm -I/opt/intel/Compiler/11.0/083/mkl/include -O0&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;but the problem remain the same. It segfaults when not using "&lt;B&gt;-O0&lt;/B&gt;". &lt;BR /&gt;&lt;BR /&gt;Matt.</description>
    <pubDate>Fri, 03 Feb 2012 12:45:49 GMT</pubDate>
    <dc:creator>mpbl</dc:creator>
    <dc:date>2012-02-03T12:45:49Z</dc:date>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816706#M4331</link>
      <description>Hello,&lt;BR /&gt;I messed around for a while now and I can't find the solution to a strange bug that I have.&lt;BR /&gt;I use the 10.1.1 version of the mkl and the 11.0 version of icc. I wrote a mock-up for LU factorization (?gttrf / ? gttrs).&lt;BR /&gt;When compiling with the "-O0" option, all works fine.&lt;BR /&gt;&lt;B&gt;icc main.cpp -lmkl_lapack -lmkl -lmkl_intel_thread -liomp5 -lpthread -lm -O0&lt;/B&gt;&lt;BR /&gt;But when compiling without optimization indication or with "-O1", "-O2", or "-O3"&lt;BR /&gt;&lt;B&gt;icc main.cpp -lmkl_lapack -lmkl -lmkl_intel_thread -liomp5 -lpthread -lm&lt;BR /&gt;&lt;/B&gt;I've got a segfault. Did I missed something ?&lt;BR /&gt;I've attached the code below.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Matt.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;[cpp]#include &lt;IOSTREAM&gt;
#include &lt;IOMANIP&gt;
#include &lt;CMATH&gt;
#include &lt;CSTRING&gt;

#include "mkl_types.h"
#include "mkl_lapack.h"

int main(int argc, char **argv) {
  MKL_INT n = 5;
  double *dl  = new double[4];
  double *d   = new double[5];
  double *du  = new double[4];
  double *du2 = new double[3];
  MKL_INT *ipiv  = new MKL_INT[5]; 
  double *t   = new double[5];
  double tmin, tmax;

  double alpha = 1.e-6f;
  double dt    = 0.001f;
  double dx    = 1.0e-2f;
  double lambda = dt/(dx*dx);

  for (int i = 0; i &amp;lt; 4; ++i) {
    dl&lt;I&gt; = -alpha*lambda;
    du&lt;I&gt; = -alpha*lambda;
  }
  for (int i = 0; i &amp;lt; 5; ++i) {
    d&lt;I&gt; = 1.f + 2*alpha*lambda;
  }

  for (int i = 0; i &amp;lt; 5; ++i) {
    t&lt;I&gt; = 1.f;
  }

  MKL_INT info;
  MKL_INT ldb = 5;
  char trans='N';
  MKL_INT nrhs = 5;
  double error = 1.f;

  // LU factorization of a tridiagonal matrix
  dgttrf(&amp;amp;n, dl, d, du, du2, ipiv, &amp;amp;info);
  if (info != 0) {
    std::cerr &amp;lt;&amp;lt; "Error in the LU factorization." &amp;lt;&amp;lt; std::endl;
    return -1;
  }

  for (int i = 0; i &amp;lt; 5; ++i) {
    std::cout &amp;lt;&amp;lt; t&lt;I&gt; &amp;lt;&amp;lt; " ";
  }
  std::cout &amp;lt;&amp;lt; std::endl;
  // Solve the tridiag LU system
  dgttrs(&amp;amp;trans, &amp;amp;n, &amp;amp;nrhs, dl, d, du, du2, ipiv, t, &amp;amp;ldb, &amp;amp;info);
  if (info != 0) {
    std::cerr &amp;lt;&amp;lt; "Error in the LU solver." &amp;lt;&amp;lt; std::endl;
    return -1;
  }

  for (int i = 0; i &amp;lt; 5; ++i) {
    std::cout &amp;lt;&amp;lt; t&lt;I&gt; &amp;lt;&amp;lt; " ";
  }
  std::cout &amp;lt;&amp;lt; std::endl;
  std::cout &amp;lt;&amp;lt; std::endl;

  delete [] dl;
  delete [] d;
  delete [] du;
  delete [] du2;
  delete [] ipiv;
  delete [] t;

  return 0;
}
[/cpp]&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/CSTRING&gt;&lt;/CMATH&gt;&lt;/IOMANIP&gt;&lt;/IOSTREAM&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Feb 2012 11:28:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816706#M4331</guid>
      <dc:creator>mpbl</dc:creator>
      <dc:date>2012-02-03T11:28:23Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816707#M4332</link>
      <description>Hello Matt,&lt;DIV&gt;I cannot seelibmkl_core linked with these examples. Please check with &lt;A href="http://software.intel.com/en-us/articles/intel-mkl-link-line-advisor/"&gt;Linker Adviser&lt;/A&gt; how to select recommended libraries for linking with mkl 10.1.&lt;/DIV&gt;&lt;DIV&gt;--Gennady&lt;/DIV&gt;</description>
      <pubDate>Fri, 03 Feb 2012 12:29:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816707#M4332</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2012-02-03T12:29:54Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816708#M4333</link>
      <description>Thanks Gennady,&lt;BR /&gt;&lt;BR /&gt;As you suggest I modified the command line as :&lt;BR /&gt;&lt;B&gt;icc main.cpp -L/opt/intel/Compiler/11.0/083/mkl/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -openmp -lpthread -lm -I/opt/intel/Compiler/11.0/083/mkl/include -O0&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;but the problem remain the same. It segfaults when not using "&lt;B&gt;-O0&lt;/B&gt;". &lt;BR /&gt;&lt;BR /&gt;Matt.</description>
      <pubDate>Fri, 03 Feb 2012 12:45:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816708#M4333</guid>
      <dc:creator>mpbl</dc:creator>
      <dc:date>2012-02-03T12:45:49Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816709#M4334</link>
      <description>Did you check your stack settings and other usual suspects, such as data overruns or uninitialized data? Why would you use an older MKL installation than the one provided with your compiler?&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Feb 2012 15:40:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816709#M4334</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2012-02-03T15:40:07Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816710#M4335</link>
      <description>Thanks TimP,&lt;BR /&gt;&lt;BR /&gt;The stack size looks ok.&lt;BR /&gt;stack size (kbytes, -s) unlimited&lt;BR /&gt;&lt;BR /&gt;$ versionquery/_results/intel_lp64_parallel_em64t_so/getversionstring_c.out &lt;BR /&gt;Intel Math Kernel Library Version 10.1.1 Product Build 082212.12 for Intel 64 architecture applications&lt;BR /&gt;&lt;BR /&gt;That's the version I found in: /opt/intel/Compiler/11.0/083/mkl&lt;BR /&gt;&lt;BR /&gt;I changed it for the version in /opt/intel/mkl/10.1.2.024/lib/em64t, but it gives the same error.&lt;BR /&gt;&lt;BR /&gt;I tried to use valgrind memcheck on the output. For this, i changed the mkl to sequential:&lt;BR /&gt;&lt;B&gt;icc main.cpp -L/opt/intel/mkl/10.1.2.024/lib/em64t -lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread -lm -I/opt/intel/mkl/10.1.2.024/include -O0&lt;/B&gt;&lt;BR /&gt;&lt;BR /&gt;when the following line is commented (only dgttrf is executed) (line 54)&lt;BR /&gt;&lt;B&gt;dgttrs(&amp;amp;trans, &amp;amp;n, &amp;amp;nrhs, dl, d, du, du2, ipiv, t, &amp;amp;ldb, &amp;amp;info);&lt;/B&gt;&lt;BR /&gt;valgrind says there is 0 errors.&lt;BR /&gt;&lt;BR /&gt;when using &lt;B&gt;dgttrs &lt;/B&gt;in addition with the "-O0" option, memcheck gives 52 errors but no conditionnal jump depends on ...().&lt;BR /&gt;&lt;B&gt;Address 0x6704280 is not stack'd, malloc'd or (recently) free'd&lt;/B&gt;&lt;BR /&gt;where the dgttrs occures.&lt;BR /&gt;&lt;BR /&gt;Is this observation relevant ?&lt;BR /&gt;&lt;BR /&gt;Matt&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Feb 2012 16:10:30 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816710#M4335</guid>
      <dc:creator>mpbl</dc:creator>
      <dc:date>2012-02-03T16:10:30Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816711#M4336</link>
      <description>The seg-fault is caused by this bug in your program: you are solving with a &lt;B&gt;single&lt;/B&gt; RHS vector, yet you give&lt;BR /&gt;&lt;BR /&gt; MKL_INTnrhs=5; &lt;BR /&gt;&lt;BR /&gt;When you make the call to dgttrs, the library routine will try to use 5 X 5 matrices for X and B in&lt;BR /&gt;&lt;BR /&gt; A X = B&lt;BR /&gt;&lt;BR /&gt;instead of, as you probably intended, 5 X 1 vectors x and b such that&lt;BR /&gt;&lt;BR /&gt; A x = b&lt;BR /&gt;&lt;BR /&gt;Change the value of &lt;B&gt;nrhs&lt;/B&gt; from 5 to 1.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Feb 2012 18:29:38 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816711#M4336</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2012-02-03T18:29:38Z</dc:date>
    </item>
    <item>
      <title>LU factorization problem in C/C++</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816712#M4337</link>
      <description>Thanks mecej4,&lt;BR /&gt;&lt;BR /&gt;It works and I am going to buy a 1st grade reading book.&lt;BR /&gt;&lt;BR /&gt;Matt.</description>
      <pubDate>Sun, 05 Feb 2012 10:33:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/LU-factorization-problem-in-C-C/m-p/816712#M4337</guid>
      <dc:creator>mpbl</dc:creator>
      <dc:date>2012-02-05T10:33:39Z</dc:date>
    </item>
  </channel>
</rss>

