<?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 Segmentation fault in gesv when matrices are too large in Intel® oneAPI Math Kernel Library</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912197#M12232</link>
    <description>Thank you Valodya, that was very helpful and educational too.</description>
    <pubDate>Mon, 18 Jan 2010 14:26:09 GMT</pubDate>
    <dc:creator>scriabin3</dc:creator>
    <dc:date>2010-01-18T14:26:09Z</dc:date>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912192#M12227</link>
      <description>&lt;P&gt;The following Fortran program uses gesv to solve the equation A x = b for random complex matrices. I have set A to be a 1600 x 1600 matrix and b to be 1600 x 160 (i.e there are 160 right hand sides in the equation). As is, the program runs correctly, but when I increase the 160 to 170I get a segmentation fault. Is this a bug or have I hit some limit I'm not aware of?&lt;/P&gt;
&lt;P&gt;
&lt;/P&gt;&lt;DIV id="_mcePaste"&gt;! Example program that uses the Intel MKL subroutine library to solve the matrix&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! equation&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;!             A x = b&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;!&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! for random complex matrices: A is n x n, while x and b are n x nrhs.&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;!&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! To call routines from the LAPACK one needs to "use lapack95" module&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! For 64 bit computing:&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! export FPATH=/opt/intel/Compiler/11.1/080/Frameworks/mkl/include/em64t/lp64&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;! ifort -r8 test.f90 -lmkl_core -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_lapack95_lp64&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;program main&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;use lapack95, only: gesv&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;implicit none&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;integer :: n, nrhs&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;complex, allocatable :: a(:,:), aa(:,:), b(:,:), bb(:,:)&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;real, allocatable :: ar(:,:),ai(:,:),br(:,:),bi(:,:)&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;n=1600; nrhs=170&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;allocate( ar(n,n),ai(n,n),a(n,n), aa(n,n), br(n,nrhs), bi(n,nrhs), b(n,nrhs), bb(n,nrhs) )&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;call random_number(ar)    ! n x n real matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;call random_number(ai)    ! n x n real matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;call random_number(br)    ! n x nrhs real matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;call random_number(bi)    ! n x nrhs real matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;aa=ar+(0.,1.)*ai       ! n x n complex matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;bb=br+(0.,1.)*bi       ! n x n complex matrix of random numbers&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;a=aa; b=bb          ! make copies&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;call gesv(a,b)        ! solve a x = b&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;write(*,*) matmul(aa,b)-bb  ! check the result: output should be a zero matrix&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;end program main&lt;/DIV&gt;
&lt;DIV id="_mcePaste"&gt;&lt;/DIV&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2010 04:15:25 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912192#M12227</guid>
      <dc:creator>scriabin3</dc:creator>
      <dc:date>2010-01-15T04:15:25Z</dc:date>
    </item>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912193#M12228</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The first suspicion would be that you didn't give attention to the stack limit setting in your shell, or to the KMP_STACKSIZE (thread stack size limit) environment variable, which defaults to 4MB in the intel64 library.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2010 14:07:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912193#M12228</guid>
      <dc:creator>TimP</dc:creator>
      <dc:date>2010-01-15T14:07:45Z</dc:date>
    </item>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912194#M12229</link>
      <description>&lt;P&gt;- the simialr symptoms may happened when you linked ilp64 libs without /4I8 compiler options&lt;/P&gt;
&lt;P&gt;--Gennady&lt;/P&gt;</description>
      <pubDate>Fri, 15 Jan 2010 15:37:43 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912194#M12229</guid>
      <dc:creator>Gennady_F_Intel</dc:creator>
      <dc:date>2010-01-15T15:37:43Z</dc:date>
    </item>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912195#M12230</link>
      <description>&lt;P&gt;Thank you gentlemen. Unfortunately I have never been educated about stacks. Looking on the web, I found that for OSX one can increase stack size up to the "hard limit" with&lt;/P&gt;
&lt;P&gt;$ ulimit -s hard&lt;/P&gt;
&lt;P&gt;I tried this, and indeed it worked, allowing me to increase nrhs from 160 to 1300. But with nrhs=1400, the program bombs with an "illegal instruction" message. I guess it's reached the hard limit? To go beyond the hard limit I read that one needs to modify and recompile the Mac OSX kernel. Now that's going beyond the call of duty for me. Is there are an easier way? I know I can get around the problem simply by solving Ax = b multiple times with different b's in order to keep nrhs small, but that seems like an ugly solution. Is there are better way? Is there even a recommended way from the MKL team?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jan 2010 01:57:14 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912195#M12230</guid>
      <dc:creator>scriabin3</dc:creator>
      <dc:date>2010-01-16T01:57:14Z</dc:date>
    </item>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912196#M12231</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Try to avoid temporary matrices that are placed on the stack.&lt;/P&gt;
&lt;P&gt;Replace&lt;/P&gt;
&lt;P style="padding-left: 20pt;"&gt;write(*,*) matmul(aa,b)-bb  ! check the result: output should be a zero matrix&lt;/P&gt;
&lt;P&gt;With a few explicit assignments:&lt;/P&gt;
&lt;P style="padding-left: 20pt;"&gt;mm = matmul(aa,b)&lt;BR /&gt;mm2 = mm - bb&lt;BR /&gt;&lt;B&gt;write&lt;/B&gt;(*,*) mm2 ! check the result: output should be a zero matrix&lt;/P&gt;
&lt;P&gt;Of course, declare:&lt;/P&gt;
&lt;P style="padding-left: 20pt;"&gt;&lt;B&gt;complex&lt;/B&gt;, &lt;B&gt;allocatable&lt;/B&gt; :: mm(:,:), mm2(:,:)&lt;/P&gt;
&lt;P&gt;and allocate:&lt;/P&gt;
&lt;P style="padding-left: 20pt;"&gt;&lt;B&gt;allocate&lt;/B&gt;( mm(n,nrhs), mm2(n,nrhs) )&lt;/P&gt;
&lt;P&gt;The following code passes without changing thestack size (not needed: $ ulimit -s hard):&lt;/P&gt;
&lt;P&gt;&lt;B&gt;program&lt;/B&gt; main&lt;BR /&gt;&lt;B&gt;use&lt;/B&gt; lapack95, &lt;B&gt;only&lt;/B&gt;: gesv&lt;BR /&gt;&lt;B&gt;implicit none&lt;BR /&gt;&lt;/B&gt;&lt;B&gt;integer&lt;/B&gt; :: n, nrhs&lt;BR /&gt;&lt;B&gt;complex&lt;/B&gt;, &lt;B&gt;allocatable&lt;/B&gt; :: a(:,:), aa(:,:), b(:,:), bb(:,:)&lt;BR /&gt;&lt;B&gt;complex&lt;/B&gt;, &lt;B&gt;allocatable&lt;/B&gt; :: mm(:,:), mm2(:,:)&lt;BR /&gt;&lt;B&gt;real&lt;/B&gt;, &lt;B&gt;allocatable&lt;/B&gt; :: ar(:,:),ai(:,:),br(:,:),bi(:,:)&lt;BR /&gt;n=1600; nrhs=1700&lt;BR /&gt;&lt;B&gt;allocate&lt;/B&gt;( ar(n,n),ai(n,n),a(n,n), aa(n,n), br(n,nrhs), bi(n,nrhs), b(n,nrhs), bb(n,nrhs) )&lt;BR /&gt;&lt;B&gt;allocate&lt;/B&gt;( mm(n,nrhs), mm2(n,nrhs) )&lt;BR /&gt;&lt;B&gt;call&lt;/B&gt; random_number(ar) ! n x n real matrix of random numbers&lt;BR /&gt;&lt;B&gt;call&lt;/B&gt; random_number(ai) ! n x n real matrix of random numbers&lt;BR /&gt;&lt;B&gt;call&lt;/B&gt; random_number(br) ! n x nrhs real matrix of random numbers&lt;BR /&gt;&lt;B&gt;call&lt;/B&gt; random_number(bi) ! n x nrhs real matrix of random numbers&lt;BR /&gt;aa=ar+(0.,1.)*ai ! n x n complex matrix of random numbers&lt;BR /&gt;bb=br+(0.,1.)*bi ! n x n complex matrix of random numbers&lt;BR /&gt;a=aa; b=bb ! make copies&lt;BR /&gt;&lt;B&gt;call&lt;/B&gt; gesv(a,b) ! solve a x = b&lt;BR /&gt;mm = matmul(aa,b)&lt;BR /&gt;mm2 = mm - bb&lt;BR /&gt;&lt;B&gt;write&lt;/B&gt;(*,*) mm2 ! check the result: output should be a zero matrix&lt;BR /&gt;&lt;B&gt;end&lt;/B&gt; &lt;B&gt;program&lt;/B&gt; main&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Vladimir&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jan 2010 11:44:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912196#M12231</guid>
      <dc:creator>Vladimir_Koldakov__I</dc:creator>
      <dc:date>2010-01-18T11:44:01Z</dc:date>
    </item>
    <item>
      <title>Segmentation fault in gesv when matrices are too large</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912197#M12232</link>
      <description>Thank you Valodya, that was very helpful and educational too.</description>
      <pubDate>Mon, 18 Jan 2010 14:26:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-Math-Kernel-Library/Segmentation-fault-in-gesv-when-matrices-are-too-large/m-p/912197#M12232</guid>
      <dc:creator>scriabin3</dc:creator>
      <dc:date>2010-01-18T14:26:09Z</dc:date>
    </item>
  </channel>
</rss>

