<?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 Segfault in the dtpmqrt routine in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044355#M20889</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;While testing out MKL Lapack's &lt;EM&gt;dtpqrt&lt;/EM&gt; and &lt;EM&gt;dtpmqrt&lt;/EM&gt; routines, I've stumbled across a &lt;EM&gt;weird&lt;/EM&gt; segfault. I replicated the error in this example (I should mention that I use Eigen just to make my life easier and that populateEigenMat is just creating a random matrix).&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;The problem &lt;/EM&gt;is that for different value of the parameter &lt;EM&gt;m&lt;/EM&gt; (the number of rows of the matrix &lt;EM&gt;B&lt;/EM&gt; in Lapack's reference for &lt;EM&gt;dtpqrt&lt;/EM&gt; and &lt;EM&gt;dtmqrt&lt;/EM&gt;), the code either works (small values of &lt;EM&gt;m&lt;/EM&gt;, and the result is correct)&amp;nbsp; or it creates a segfault (larger values of &lt;EM&gt;m&lt;/EM&gt;).&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
int main()
{

  int m =150;
  int n = 5;
  int nb = 1;
  int l = 0;
  int info;

  MatrixXd a(n,n), b(m,n), t(nb, n);
  populateEigenMat(a), populateEigenMat(b);
  a = a.eval().triangularView&amp;lt;Eigen::Upper&amp;gt;();
  
  info = LAPACKE_dtpqrt(LAPACK_COL_MAJOR, m, n, l, nb, a.data(), a.rows(), 
  		       b.data(), b.rows(), t.data(), t.rows());

  int k = n;
  
  MatrixXd cA(k,n), cB(m,n), c(k+m,n);
  populateEigenMat(cA), populateEigenMat(cB);
  c&amp;lt;&amp;lt;cA,cB;

  cout&amp;lt;&amp;lt;"Still ok!\n";
  // cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;cB&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;c.block(k,0,m,n)&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;endl;
  info = LAPACKE_dtpmqrt(LAPACK_COL_MAJOR, 'L', 'N', m, n, k, l, nb, b.data(), b.rows(), t.data(), t.rows(),
  			 c.data(), c.rows(), c.data()+k, c.rows());

}

&lt;/PRE&gt;

&lt;P&gt;I'm using version of Intel Composer:&amp;nbsp;composer_xe_2013_sp1.2.144 and the following links -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lpthread -std=c++11 -xAVX -DMKL_ILP64.&lt;/P&gt;

&lt;P&gt;Could some please tell me where I've made a mistake?&lt;/P&gt;

&lt;P&gt;Kind regards&lt;/P&gt;</description>
    <pubDate>Thu, 19 Jun 2014 10:01:43 GMT</pubDate>
    <dc:creator>Radu_M_</dc:creator>
    <dc:date>2014-06-19T10:01:43Z</dc:date>
    <item>
      <title>Segfault in the dtpmqrt routine</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044355#M20889</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;While testing out MKL Lapack's &lt;EM&gt;dtpqrt&lt;/EM&gt; and &lt;EM&gt;dtpmqrt&lt;/EM&gt; routines, I've stumbled across a &lt;EM&gt;weird&lt;/EM&gt; segfault. I replicated the error in this example (I should mention that I use Eigen just to make my life easier and that populateEigenMat is just creating a random matrix).&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;The problem &lt;/EM&gt;is that for different value of the parameter &lt;EM&gt;m&lt;/EM&gt; (the number of rows of the matrix &lt;EM&gt;B&lt;/EM&gt; in Lapack's reference for &lt;EM&gt;dtpqrt&lt;/EM&gt; and &lt;EM&gt;dtmqrt&lt;/EM&gt;), the code either works (small values of &lt;EM&gt;m&lt;/EM&gt;, and the result is correct)&amp;nbsp; or it creates a segfault (larger values of &lt;EM&gt;m&lt;/EM&gt;).&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;
int main()
{

  int m =150;
  int n = 5;
  int nb = 1;
  int l = 0;
  int info;

  MatrixXd a(n,n), b(m,n), t(nb, n);
  populateEigenMat(a), populateEigenMat(b);
  a = a.eval().triangularView&amp;lt;Eigen::Upper&amp;gt;();
  
  info = LAPACKE_dtpqrt(LAPACK_COL_MAJOR, m, n, l, nb, a.data(), a.rows(), 
  		       b.data(), b.rows(), t.data(), t.rows());

  int k = n;
  
  MatrixXd cA(k,n), cB(m,n), c(k+m,n);
  populateEigenMat(cA), populateEigenMat(cB);
  c&amp;lt;&amp;lt;cA,cB;

  cout&amp;lt;&amp;lt;"Still ok!\n";
  // cout&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;cB&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;c.block(k,0,m,n)&amp;lt;&amp;lt;endl&amp;lt;&amp;lt;endl;
  info = LAPACKE_dtpmqrt(LAPACK_COL_MAJOR, 'L', 'N', m, n, k, l, nb, b.data(), b.rows(), t.data(), t.rows(),
  			 c.data(), c.rows(), c.data()+k, c.rows());

}

&lt;/PRE&gt;

&lt;P&gt;I'm using version of Intel Composer:&amp;nbsp;composer_xe_2013_sp1.2.144 and the following links -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lpthread -std=c++11 -xAVX -DMKL_ILP64.&lt;/P&gt;

&lt;P&gt;Could some please tell me where I've made a mistake?&lt;/P&gt;

&lt;P&gt;Kind regards&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 10:01:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044355#M20889</guid>
      <dc:creator>Radu_M_</dc:creator>
      <dc:date>2014-06-19T10:01:43Z</dc:date>
    </item>
    <item>
      <title>There is nothing in the code</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044356#M20890</link>
      <description>&lt;P&gt;There is nothing in the code shown above that makes the integer arguments in the call to dtpqrt() to be 8-byte integers, as required if you use the ILP64 libraries. If you do not include any of the MKL header files, the -DMKL_ILP64 compiler option has no effect.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 12:24:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044356#M20890</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-06-19T12:24:00Z</dc:date>
    </item>
    <item>
      <title>I included the the MKL header</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044357#M20891</link>
      <description>&lt;P&gt;I included the the MKL header. But I should mention that I get a segfault using the parameters shown in the code above. If i put &lt;EM&gt;m&lt;/EM&gt; lower than 122 and I keep the same value for &lt;EM&gt;n&lt;/EM&gt; then the code works.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;mecej4 wrote:&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;There is nothing in the code shown above that makes the integer arguments in the call to dtpqrt() to be 8-byte integers, as required if you use the ILP64 libraries. If you do not include any of the MKL header files, the&amp;nbsp;-DMKL_ILP64 compiler option has not effect.&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 12:41:53 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044357#M20891</guid>
      <dc:creator>Radu_M_</dc:creator>
      <dc:date>2014-06-19T12:41:53Z</dc:date>
    </item>
    <item>
      <title>Without a reproducer</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044358#M20892</link>
      <description>&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE&gt;I included the the MKL header.&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;

&lt;P&gt;There are nearly forty header files in the MKL directory. Which one(s) did you include?&lt;/P&gt;

&lt;P&gt;Without a reproducer (complete code with instructions to build the example, and input data, if needed) it is unlikely that your problem can be diagnosed and solved.&lt;/P&gt;

&lt;P&gt;Secondly, you are using a third party template package ("Eigen"?), so information on the version of that package is needed.&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 15:07:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044358#M20892</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-06-19T15:07:00Z</dc:date>
    </item>
    <item>
      <title>Here's the complete code (Ive</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044359#M20893</link>
      <description>&lt;P&gt;Here's the complete code (Ive modified it so that you won't have to use Eigen -i.e. it is self contained - and it still produces the same segfault when &lt;EM&gt;m&lt;/EM&gt; is large (in this particular case &lt;EM&gt;m&lt;/EM&gt; &amp;gt;= 125, for &lt;EM&gt;m&lt;/EM&gt; it works okay):&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#include &amp;lt;random&amp;gt;
#include &amp;lt;iostream&amp;gt;

#include "mkl.h"
using namespace std;


mt19937 rng(0);
normal_distribution&amp;lt;double&amp;gt; dist(0., 1.);
void populateMat(double* mat, int rows, int cols)
{
  for (auto i = 0; i &amp;lt; rows*cols; ++i){
    mat&lt;I&gt; = dist(rng);
  }
}
int main()
{

  int m =125;
  int n = 5;
  int nb = 1;
  int l = 0;
  int info;

  double* a = new double[n*n];
  double* b = new double[m*n];
  double* t = new double[nb*n];
  populateMat(a, n, n), populateMat(b, m, n);
  
  info = LAPACKE_dtpqrt(LAPACK_COL_MAJOR, m, n, l, nb, a, n, b, m, t, nb);

  int k = n;

  double* c = new double[(k+m)*n]; 

  populateMat(c, k+m, n);

  cout&amp;lt;&amp;lt;"Still ok!\n";

  info = LAPACKE_dtpmqrt(LAPACK_COL_MAJOR, 'L', 'N', m, n, k, l, nb, b, m, t, nb, c, k+m, c+k, k+m);
  
  delete[] a;
  delete[] b;
  delete[] c;
  delete[] t;
  
}
&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;To compile it I've used the following libraries/compiler flags/includes: &lt;EM&gt;-L $MKLROOT/lib/intel64 -lmkl_intel_ilp64 -lmkl_core -lmkl_sequential -lpthread -std=c++11 -DMKL_ILP64 -I $MKLROOT/include.&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Since I'm new to MKL, I've used MKL Library Link Advisor.&lt;/P&gt;

&lt;P&gt;Thank you very much for your patience.&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, 19 Jun 2014 16:32:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044359#M20893</guid>
      <dc:creator>Radu_M_</dc:creator>
      <dc:date>2014-06-19T16:32:26Z</dc:date>
    </item>
    <item>
      <title>I have no experience with the</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044360#M20894</link>
      <description>&lt;P&gt;I have no experience with the Lapack routines dtpqrt and dtpmqrt, but I have one observation based on the documentation: matrix A is supposed to be upper triangular and matrix B is supposed to be pentagonal (see&amp;nbsp;https://software.intel.com/en-us/node/469004). Since you fill the entire matrices A and B, you are assuming that the Lapack routines will ignore the non-zero values that you placed into those places where the routines expect zero. I would not make such assumptions without the presence of statements in the documentation that those values will not be accessed or will be overwritten by zeros before the decomposition algorithm is started.&lt;/P&gt;

&lt;P&gt;Nevertheless, you have provided a short reproducer and so the Intel personnel will have something to work with when they turn to this problem report.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 22:09:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044360#M20894</guid>
      <dc:creator>mecej4</dc:creator>
      <dc:date>2014-06-19T22:09:00Z</dc:date>
    </item>
    <item>
      <title>They perform the QR</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044361#M20895</link>
      <description>&lt;P&gt;They perform the QR factorisation (and multiply Q) of matrices that have a very specific structure. These matrices are the building blocks of the QR factorisation of tall and skinny matrices and more generally in communication-avoiding QR decompositions. These routines are fairly recent.&lt;/P&gt;

&lt;P&gt;I filled up the matrices so I can simplify this short example but I don't think that has an influence on this bug. (in fact when I found this error I had zeros in the correct places).&lt;/P&gt;

&lt;P&gt;I don't think I've made any obvious mistake in that code, so I'll chalk it up to an &lt;STRONG&gt;MKL bug&lt;/STRONG&gt;. &amp;nbsp;&lt;/P&gt;

&lt;P&gt;Thank you very much for the time you've spent on my problem.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Jun 2014 23:27:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segfault-in-the-dtpmqrt-routine/m-p/1044361#M20895</guid>
      <dc:creator>Radu_M_</dc:creator>
      <dc:date>2014-06-19T23:27:05Z</dc:date>
    </item>
  </channel>
</rss>

