<div dir="ltr">This seems integer overflow when computing the factors.<div><br></div><div>How large is the matrix when you encounter the error?<div><div></div></div><div>Note that LU is not memory optimal and you can easily encounter out-of-memory issues with large matrices.</div><div>Assuming sparsity, the memory requirements for LU are N log(N) in 2D and N^4/3 in 3D.</div><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno dom 23 feb 2020 alle ore 11:01 Tsung-Hsing Chen <<a href="mailto:barrydog505@gmail.com">barrydog505@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi all,<br><br>I have written a simple code to solve the FEM problem, and I want to use LU to solve the Ax=b.<br><div>My problem(error) won't happen at the beginning until M & N in A_matrix is getting larger. (Can also be understood as mesh vertex increase.)</div><div>All the error output seems to relate to LU, but I don't know what should be done.</div><div>The followings are the code I wrote(section) and the error output.</div><div><br></div><div>Here's the code (section) :<br>  /*</div><div>        code ...</div><div>  */<br>  ierr = MatCreate(PETSC_COMM_WORLD, &A_matrix);CHKERRQ(ierr);<br>  ierr = MatSetSizes(A_matrix, PETSC_DECIDE, PETSC_DECIDE, M, N);CHKERRQ(ierr);<br>  ierr = MatSetType(A_matrix, MATSEQAIJ);CHKERRQ(ierr);<br>  // setting nnz ...<br>  ierr = MatSeqAIJSetPreallocation(A_matrix, 0, nnz);CHKERRQ(ierr);<br>  /*<br>        MatSetValues(); ...<br>        MatAssemblyBegin();<br>        MatAssemblyEnd();<br>  */<br>  ierr = KSPCreate(PETSC_COMM_WORLD, &ksp);CHKERRQ(ierr);<br>  ierr = KSPSetOperators(ksp, A_matrix, A_matrix);CHKERRQ(ierr);<br>  ierr = KSPSetType(ksp, KSPPREONLY);CHKERRQ(ierr);<br>  ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr);<br>  ierr = PCSetType(pc, PCLU);CHKERRQ(ierr);<br>  ierr = KSPSetFromOptions(ksp);CHKERRQ(ierr);<br>  ierr = KSPSetUp(ksp);CHKERRQ(ierr);<br>  /*<br>        code ...<br>  */</div><div><br></div><div>Here's the error (run with valgrind --tool=memcheck --leak-check=full) :</div><div>  ==6371== Warning: set address range perms: large range [0x7c84a040, 0xb4e9a598) (undefined)<br>  ==6371== Warning: set address range perms: large range [0xb4e9b040, 0x2b4e9aeac) (undefined)<br>  ==6371== Warning: set address range perms: large range [0x2b4e9b040, 0x4b4e9aeac) (undefined)<br>  ==6371== Argument 'size' of function memalign has a fishy (possibly negative) value: -5187484888<br>  ==6371==    at 0x4C320A6: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)<br>  ==6371==    by 0x501B4B0: PetscMallocAlign (mal.c:49)<br>  ==6371==    by 0x501CE37: PetscMallocA (mal.c:422)<br>  ==6371==    by 0x5ACFF0C: MatLUFactorSymbolic_SeqAIJ (aijfact.c:366)<br>  ==6371==    by 0x561D8B3: MatLUFactorSymbolic (matrix.c:3005)<br>  ==6371==    by 0x644ED9C: PCSetUp_LU (lu.c:90)<br>  ==6371==    by 0x65A2C32: PCSetUp (precon.c:894)<br>  ==6371==    by 0x6707E71: KSPSetUp (itfunc.c:376)<br>  ==6371==    by 0x13AB09: Calculate (taylor_hood.c:1780)<br>  ==6371==    by 0x10CB85: main (taylor_hood.c:228)<br>  ==6371== <br>  [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------<br>  [0]PETSC ERROR: Out of memory. This could be due to allocating<br>  [0]PETSC ERROR: too large an object or bleeding by not properly<br>  [0]PETSC ERROR: destroying unneeded objects.<br>  [0]PETSC ERROR: Memory allocated 0 Memory used by process 15258234880<br>  [0]PETSC ERROR: Try running with -malloc_dump or -malloc_view for info.<br>  [0]PETSC ERROR: Memory requested 18446744068522065920<br>  [0]PETSC ERROR: See <a href="https://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">https://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>  [0]PETSC ERROR: Petsc Release Version 3.12.4, unknown <br>  [0]PETSC ERROR: ./taylor_hood on a arch-linux2-c-debug named e2-120 by barry Sun Feb 23 14:18:46 2020<br>  [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --download-triangle<br>  [0]PETSC ERROR: #1 MatLUFactorSymbolic_SeqAIJ() line 366 in /home/barry/petsc/src/mat/impls/aij/seq/aijfact.c<br>  [0]PETSC ERROR: #2 PetscMallocA() line 422 in /home/barry/petsc/src/sys/memory/mal.c<br>  [0]PETSC ERROR: #3 MatLUFactorSymbolic_SeqAIJ() line 366 in /home/barry/petsc/src/mat/impls/aij/seq/aijfact.c<br>  [0]PETSC ERROR: #4 MatLUFactorSymbolic() line 3005 in /home/barry/petsc/src/mat/interface/matrix.c<br>  [0]PETSC ERROR: #5 PCSetUp_LU() line 90 in /home/barry/petsc/src/ksp/pc/impls/factor/lu/lu.c<br>  [0]PETSC ERROR: #6 PCSetUp() line 894 in /home/barry/petsc/src/ksp/pc/interface/precon.c<br>  [0]PETSC ERROR: #7 KSPSetUp() line 376 in /home/barry/petsc/src/ksp/ksp/interface/itfunc.c<br>  [0]PETSC ERROR: #8 Calculate() line 1780 in /home/barry/brain/brain/3D/taylor_hood.c<br>  [0]PETSC ERROR: #9 main() line 230 in /home/barry/brain/brain/3D/taylor_hood.c<br>  [0]PETSC ERROR: PETSc Option Table entries:<br>  [0]PETSC ERROR: -dm_view<br>  [0]PETSC ERROR: -f mesh/ellipsoid.msh<br>  [0]PETSC ERROR: -matload_block_size 1<br>  [0]PETSC ERROR: ----------------End of Error Message -------send entire error message to petsc-maint@mcs.anl.gov----------</div><div><br></div><div>Is there any setting that should be done but I ignore?<br><br>Thanks in advance,<br><br>Tsung-Hsing Chen<br></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature">Stefano</div>