pastix solver break at pastix_checkMatrix
Dear all, I found the pastix solver petsc-3.1-p4 ./configure --with-vendor-compilers=intel --with-blas-lapack-dir=/opt/intel/mkl/10.2.0.013/lib/em64t/ --download-pastix --download-scotch --with-shared=1 --with-debugging=1 For a poisson problem with symmetric matrix, pastix works well. However, for unsymmetric problem, the code break. valgrind reported that: Check : Sort CSC OK ==4959== Invalid read of size 4 ==4959== at 0x1241931: PetscTrFreeDefault (mtr.c:280) ==4959== by 0x150448A: MatConvertToCSC (pastix.c:188) ==4959== by 0x1506638: MatFactorNumeric_PaStiX (pastix.c:390) ==4959== by 0x13980AB: MatLUFactorNumeric (matrix.c:2587) ==4959== by 0x16AB0A6: PCSetUp_LU (lu.c:158) ==4959== by 0x1A9BD42: PCSetUp (precon.c:795) ==4959== by 0x16FA8D0: KSPSetUp (itfunc.c:237) ==4959== by 0x16FBB2A: KSPSolve (itfunc.c:353) ==4959== by 0x17BEC6D: SNES_KSPSolve (snes.c:2944) ==4959== by 0x17CEFEA: SNESSolve_LS (ls.c:191) ==4959== by 0x17B8B78: SNESSolve (snes.c:2255) ==4959== by 0x10B969D: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:820) ==4959== Address 0x88e2f08 is 8 bytes inside a block of size 40 free'd ==4959== at 0x4A05B16: operator delete(void*) (vg_replace_malloc.c:387) ==4959== by 0xA42A53: __gnu_cxx::new_allocator<std::_Rb_tree_node<CTRI::Triangle*> >::deallocate(std::_Rb_tree_node<CTRI::Triangle*>*, unsigned long) (new_allocator.h:94) ==4959== by 0xA41863: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::_M_put_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:362) ==4959== by 0xA419C8: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::destroy_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:392) ==4959== by 0xA42501: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1189) ==4959== by 0xA4264A: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>, std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1281) ==4959== by 0xA4257B: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_tree.h:1215) ==4959== by 0xA415E2: std::set<CTRI::Triangle*, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_set.h:387) ==4959== by 0xA3F6BD: CTRI::Triangle::~Triangle() (c_triangle.cc:109) ==4959== by 0xA43F16: CTRI::TriMesh::~TriMesh() (c_trimesh.cc:163) ==4959== by 0xA3F0C6: ctri_triangulate (c_tri_io.cc:35) ==4959== by 0xD53FB9: MeshGeneratorTri3::do_refine(MeshRefinement&) (mesh_generation_tri3.cc:1369) ==4959== [0]PETSC ERROR: PetscTrFreeDefault() called from MatConvertToCSC() line 188 in src/mat/impls/aij/mpi/pastix/pastix.c [0]PETSC ERROR: Block at address 0x88e2ee0 is corrupted; cannot free; may be block not allocated with PetscMalloc() The test problems used to work well under other linear solvers such as MUMPS and superlu. Does any meet this problem before? Yours Gong Ding
Good morning Ding. Sorry to not have an answer since I do not try to solve that type of problem. But, are the matrices formed and populated in a way that is appropriate to solution with PETSc? If that is the case then there does appear to be an issue with PETSc itself. I'll bet the developers would love to have your example. My own development exercise is to compute the Kronecker tensor product where all components are distributed. Am using the Matrix and Vector level of PETSc, with some use of higher levels. It is a most interesting undertaking. Best, Peter.
Please run program with -ksp_view_binary and send us the file binaryoutput to [email protected] so we can reproduce the problem. Barry On Dec 29, 2010, at 11:00 PM, Gong Ding wrote:
Dear all,
I found the pastix solver
petsc-3.1-p4 ./configure --with-vendor-compilers=intel --with-blas-lapack-dir=/opt/intel/mkl/10.2.0.013/lib/em64t/ --download-pastix --download-scotch --with-shared=1 --with-debugging=1
For a poisson problem with symmetric matrix, pastix works well. However, for unsymmetric problem, the code break. valgrind reported that: Check : Sort CSC OK ==4959== Invalid read of size 4 ==4959== at 0x1241931: PetscTrFreeDefault (mtr.c:280) ==4959== by 0x150448A: MatConvertToCSC (pastix.c:188) ==4959== by 0x1506638: MatFactorNumeric_PaStiX (pastix.c:390) ==4959== by 0x13980AB: MatLUFactorNumeric (matrix.c:2587) ==4959== by 0x16AB0A6: PCSetUp_LU (lu.c:158) ==4959== by 0x1A9BD42: PCSetUp (precon.c:795) ==4959== by 0x16FA8D0: KSPSetUp (itfunc.c:237) ==4959== by 0x16FBB2A: KSPSolve (itfunc.c:353) ==4959== by 0x17BEC6D: SNES_KSPSolve (snes.c:2944) ==4959== by 0x17CEFEA: SNESSolve_LS (ls.c:191) ==4959== by 0x17B8B78: SNESSolve (snes.c:2255) ==4959== by 0x10B969D: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:820) ==4959== Address 0x88e2f08 is 8 bytes inside a block of size 40 free'd ==4959== at 0x4A05B16: operator delete(void*) (vg_replace_malloc.c:387) ==4959== by 0xA42A53: __gnu_cxx::new_allocator<std::_Rb_tree_node<CTRI::Triangle*> >::deallocate(std::_Rb_tree_node<CTRI::Triangle*>*, unsigned long) (new_allocator.h:94) ==4959== by 0xA41863: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::_M_put_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:362) ==4959== by 0xA419C8: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::destroy_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:392) ==4959== by 0xA42501: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1189) ==4959== by 0xA4264A: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>, std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1281) ==4959== by 0xA4257B: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_tree.h:1215) ==4959== by 0xA415E2: std::set<CTRI::Triangle*, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_set.h:387) ==4959== by 0xA3F6BD: CTRI::Triangle::~Triangle() (c_triangle.cc:109) ==4959== by 0xA43F16: CTRI::TriMesh::~TriMesh() (c_trimesh.cc:163) ==4959== by 0xA3F0C6: ctri_triangulate (c_tri_io.cc:35) ==4959== by 0xD53FB9: MeshGeneratorTri3::do_refine(MeshRefinement&) (mesh_generation_tri3.cc:1369) ==4959== [0]PETSC ERROR: PetscTrFreeDefault() called from MatConvertToCSC() line 188 in src/mat/impls/aij/mpi/pastix/pastix.c [0]PETSC ERROR: Block at address 0x88e2ee0 is corrupted; cannot free; may be block not allocated with PetscMalloc()
The test problems used to work well under other linear solvers such as MUMPS and superlu. Does any meet this problem before?
Yours Gong Ding
----- Original Message ----- From: "Barry Smith" <[email protected]> To: "PETSc users list" <[email protected]> Sent: Thursday, December 30, 2010 10:55 PM Subject: Re: [petsc-users] pastix solver break at pastix_checkMatrix Please run program with -ksp_view_binary and send us the file binaryoutput to [email protected] so we can reproduce the problem. Barry Ok, I use pastix as linear solver of SNES. (The coding style of pastix seems much better than mumps. I'd like to try if I can speed it by GPU-based BLAS.) The settings are listed as follows: ierr = KSPSetType (ksp, (char*) KSPPREONLY); assert(!ierr); ierr = PCSetType (pc, (char*) PCLU); assert(!ierr); ierr = PCFactorSetMatSolverPackage (pc, MAT_SOLVER_PASTIX); assert(!ierr); ierr = PCFactorSetReuseFill(pc, PETSC_TRUE);assert(!ierr); ierr = PCFactorSetReuseOrdering(pc, PETSC_TRUE); assert(!ierr); ierr = PCFactorSetColumnPivot(pc, 1.0); genius_assert(!ierr); //ierr = PCFactorReorderForNonzeroDiagonal(pc, 1e-20); assert(!ierr);<-- Caught signal number 11 SEGV error will occure when diag value < 1e-20 ierr = PCFactorSetShiftType(pc,MAT_SHIFT_NONZERO);assert(!ierr); The attached matrix is dumped at the end of jacobian assemble.
Yes, there is an error in how we called one of the pastix routines. It required certain arrays be obtained with a raw malloc(). Please find attached a new src/mat/impls/aij/mpi/pastix/pastix.c put it in that location and run make in that directory. Thanks for reporting the problem and sending the valgrind output Barry On Dec 29, 2010, at 11:00 PM, Gong Ding wrote:
Dear all,
I found the pastix solver
petsc-3.1-p4 ./configure --with-vendor-compilers=intel --with-blas-lapack-dir=/opt/intel/mkl/10.2.0.013/lib/em64t/ --download-pastix --download-scotch --with-shared=1 --with-debugging=1
For a poisson problem with symmetric matrix, pastix works well. However, for unsymmetric problem, the code break. valgrind reported that: Check : Sort CSC OK ==4959== Invalid read of size 4 ==4959== at 0x1241931: PetscTrFreeDefault (mtr.c:280) ==4959== by 0x150448A: MatConvertToCSC (pastix.c:188) ==4959== by 0x1506638: MatFactorNumeric_PaStiX (pastix.c:390) ==4959== by 0x13980AB: MatLUFactorNumeric (matrix.c:2587) ==4959== by 0x16AB0A6: PCSetUp_LU (lu.c:158) ==4959== by 0x1A9BD42: PCSetUp (precon.c:795) ==4959== by 0x16FA8D0: KSPSetUp (itfunc.c:237) ==4959== by 0x16FBB2A: KSPSolve (itfunc.c:353) ==4959== by 0x17BEC6D: SNES_KSPSolve (snes.c:2944) ==4959== by 0x17CEFEA: SNESSolve_LS (ls.c:191) ==4959== by 0x17B8B78: SNESSolve (snes.c:2255) ==4959== by 0x10B969D: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:820) ==4959== Address 0x88e2f08 is 8 bytes inside a block of size 40 free'd ==4959== at 0x4A05B16: operator delete(void*) (vg_replace_malloc.c:387) ==4959== by 0xA42A53: __gnu_cxx::new_allocator<std::_Rb_tree_node<CTRI::Triangle*> >::deallocate(std::_Rb_tree_node<CTRI::Triangle*>*, unsigned long) (new_allocator.h:94) ==4959== by 0xA41863: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::_M_put_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:362) ==4959== by 0xA419C8: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::destroy_node(std::_Rb_tree_node<CTRI::Triangle*>*) (stl_tree.h:392) ==4959== by 0xA42501: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1189) ==4959== by 0xA4264A: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(std::_Rb_tree_iterator<CTRI::Triangle*>, std::_Rb_tree_iterator<CTRI::Triangle*>) (stl_tree.h:1281) ==4959== by 0xA4257B: std::_Rb_tree<CTRI::Triangle*, CTRI::Triangle*, std::_Identity<CTRI::Triangle*>, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_tree.h:1215) ==4959== by 0xA415E2: std::set<CTRI::Triangle*, std::less<CTRI::Triangle*>, std::allocator<CTRI::Triangle*> >::erase(CTRI::Triangle* const&) (stl_set.h:387) ==4959== by 0xA3F6BD: CTRI::Triangle::~Triangle() (c_triangle.cc:109) ==4959== by 0xA43F16: CTRI::TriMesh::~TriMesh() (c_trimesh.cc:163) ==4959== by 0xA3F0C6: ctri_triangulate (c_tri_io.cc:35) ==4959== by 0xD53FB9: MeshGeneratorTri3::do_refine(MeshRefinement&) (mesh_generation_tri3.cc:1369) ==4959== [0]PETSC ERROR: PetscTrFreeDefault() called from MatConvertToCSC() line 188 in src/mat/impls/aij/mpi/pastix/pastix.c [0]PETSC ERROR: Block at address 0x88e2ee0 is corrupted; cannot free; may be block not allocated with PetscMalloc()
The test problems used to work well under other linear solvers such as MUMPS and superlu. Does any meet this problem before?
Yours Gong Ding
Dear Barry, First, the patched file has some evident problem. PetscScalar *tmpvalues; PetscInt *tmprows,*tmpcolptr; tmpvalues = malloc(nnz*sizeof(PetscScalar)); tmprows = malloc(nnz*sizeof(PetscInt)); tmpcolptr = malloc((*n+1)*sizeof(PetscInt)); ierr = PetscMalloc3(nnz,PetscScalar,&tmpvalues,nnz,PetscInt,&tmprows,(*n+1),PetscInt,&tmpcolptr);CHKERRQ(ierr); <-- this line alloc meory again. After comment above line, the pastix works for the first nonlinear iteration. However, it breaks at the second iteration. valgrind reported: DDM Solver Level 1 init... Using PaStiX linear solver... Compute equilibrium its | Eq(V) | | Eq(n) | | Eq(p) | | Eq(T) | |Eq(Tn)| |Eq(Tp)| |delta x| ----------------------------------------------------------------------------- 0 2.50e-06 2.34e-03 3.12e-04 0.00e+00* 0.00e+00* 0.00e+00* 0.00e+00* Check : ordering OK Check : Graph Symmetry Correction Add 4090 null terms OK Check : Sort CSC OK 1 2.06e-05 7.29e-04 1.03e-04 0.00e+00* 0.00e+00* 0.00e+00* 3.85e-01 Check : ordering OK Check : Graph Symmetry==1416== Thread 1: ==1416== Invalid read of size 4 ==1416== at 0x1BC3186: csc_checksym (csc_utils.c:321) ==1416== by 0x1B4E7E3: pastix_checkMatrix (pastix.c:3915) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416== Correction==1416== Invalid read of size 4 ==1416== at 0x1BD1147: correct2 (cscsymcsc.c:77) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10D7: correct2 (cscsymcsc.c:67) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10EB: correct2 (cscsymcsc.c:72) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1102: correct2 (cscsymcsc.c:75) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8d369dc is 4 bytes before a block of size 4,216 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x150812B: MatConvertToCSC (pastix.c:169) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD116D: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1179: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1186: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid write of size 4 ==1416== at 0x1BD1192: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors [0]PETSC ERROR: likely location of problem given in stack below
Well that, obviously was erroneously left in. Remove that line, recompile in that directory and it should run ok. Barry On Dec 30, 2010, at 9:49 PM, Gong Ding wrote:
Dear Barry, First, the patched file has some evident problem.
PetscScalar *tmpvalues; PetscInt *tmprows,*tmpcolptr; tmpvalues = malloc(nnz*sizeof(PetscScalar)); tmprows = malloc(nnz*sizeof(PetscInt)); tmpcolptr = malloc((*n+1)*sizeof(PetscInt));
ierr = PetscMalloc3(nnz,PetscScalar,&tmpvalues,nnz,PetscInt,&tmprows,(*n+1),PetscInt,&tmpcolptr);CHKERRQ(ierr); <-- this line alloc meory again.
After comment above line, the pastix works for the first nonlinear iteration. However, it breaks at the second iteration. valgrind reported:
DDM Solver Level 1 init... Using PaStiX linear solver... Compute equilibrium its | Eq(V) | | Eq(n) | | Eq(p) | | Eq(T) | |Eq(Tn)| |Eq(Tp)| |delta x| ----------------------------------------------------------------------------- 0 2.50e-06 2.34e-03 3.12e-04 0.00e+00* 0.00e+00* 0.00e+00* 0.00e+00* Check : ordering OK Check : Graph Symmetry Correction Add 4090 null terms OK Check : Sort CSC OK 1 2.06e-05 7.29e-04 1.03e-04 0.00e+00* 0.00e+00* 0.00e+00* 3.85e-01 Check : ordering OK Check : Graph Symmetry==1416== Thread 1: ==1416== Invalid read of size 4 ==1416== at 0x1BC3186: csc_checksym (csc_utils.c:321) ==1416== by 0x1B4E7E3: pastix_checkMatrix (pastix.c:3915) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416==
Correction==1416== Invalid read of size 4 ==1416== at 0x1BD1147: correct2 (cscsymcsc.c:77) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10D7: correct2 (cscsymcsc.c:67) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10EB: correct2 (cscsymcsc.c:72) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1102: correct2 (cscsymcsc.c:75) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8d369dc is 4 bytes before a block of size 4,216 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x150812B: MatConvertToCSC (pastix.c:169) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD116D: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1179: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1186: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid write of size 4 ==1416== at 0x1BD1192: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors [0]PETSC ERROR: likely location of problem given in stack below
Dear Barry As I mentioned, only works for the first nonlinear iteration. Will break for the second! I guess the MatConvertToCSC function should be considered again, i.e. do optimization for nonlinear solver which will call pastix many times. Gong Ding
Well that, obviously was erroneously left in. Remove that line, recompile in that directory and it should run ok.
Barry
On Dec 30, 2010, at 9:49 PM, Gong Ding wrote:
Dear Barry, First, the patched file has some evident problem.
PetscScalar *tmpvalues; PetscInt *tmprows,*tmpcolptr; tmpvalues = malloc(nnz*sizeof(PetscScalar)); tmprows = malloc(nnz*sizeof(PetscInt)); tmpcolptr = malloc((*n+1)*sizeof(PetscInt));
ierr = PetscMalloc3(nnz,PetscScalar,&tmpvalues,nnz,PetscInt,&tmprows,(*n+1),PetscInt,&tmpcolptr);CHKERRQ(ierr); <-- this line alloc meory again.
After comment above line, the pastix works for the first nonlinear iteration. However, it breaks at the second iteration. valgrind reported:
DDM Solver Level 1 init... Using PaStiX linear solver... Compute equilibrium its | Eq(V) | | Eq(n) | | Eq(p) | | Eq(T) | |Eq(Tn)| |Eq(Tp)| |delta x| ----------------------------------------------------------------------------- 0 2.50e-06 2.34e-03 3.12e-04 0.00e+00* 0.00e+00* 0.00e+00* 0.00e+00* Check : ordering OK Check : Graph Symmetry Correction Add 4090 null terms OK Check : Sort CSC OK 1 2.06e-05 7.29e-04 1.03e-04 0.00e+00* 0.00e+00* 0.00e+00* 3.85e-01 Check : ordering OK Check : Graph Symmetry==1416== Thread 1: ==1416== Invalid read of size 4 ==1416== at 0x1BC3186: csc_checksym (csc_utils.c:321) ==1416== by 0x1B4E7E3: pastix_checkMatrix (pastix.c:3915) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416==
Correction==1416== Invalid read of size 4 ==1416== at 0x1BD1147: correct2 (cscsymcsc.c:77) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8aeb1a8 is not stack'd, malloc'd or (recently) free'd ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10D7: correct2 (cscsymcsc.c:67) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD10EB: correct2 (cscsymcsc.c:72) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1102: correct2 (cscsymcsc.c:75) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8d369dc is 4 bytes before a block of size 4,216 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x150812B: MatConvertToCSC (pastix.c:169) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD116D: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1179: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== ==1416== Invalid read of size 4 ==1416== at 0x1BD1186: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8ae7574 is 0 bytes after a block of size 68,180 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x15080FF: MatConvertToCSC (pastix.c:168) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== by 0x10BAB53: FVM_NonlinearSolver::sens_solve() (fvm_nonlinear_solver.cc:824) ==1416== ==1416== Invalid write of size 4 ==1416== at 0x1BD1192: correct2 (cscsymcsc.c:88) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== by 0x17BCF6C: SNESSolve (snes.c:2255) ==1416== Address 0x8c1b55c is 4 bytes before a block of size 4,212 alloc'd ==1416== at 0x4A061EF: malloc (vg_replace_malloc.c:236) ==1416== by 0x1BD1029: correct2 (cscsymcsc.c:53) ==1416== by 0x1B4E8EA: pastix_checkMatrix (pastix.c:3930) ==1416== by 0x1508661: MatConvertToCSC (pastix.c:185) ==1416== by 0x150AA2E: MatFactorNumeric_PaStiX (pastix.c:396) ==1416== by 0x139C90B: MatLUFactorNumeric (matrix.c:2587) ==1416== by 0x16AF49A: PCSetUp_LU (lu.c:158) ==1416== by 0x1AA0136: PCSetUp (precon.c:795) ==1416== by 0x16FECC4: KSPSetUp (itfunc.c:237) ==1416== by 0x16FFF1E: KSPSolve (itfunc.c:353) ==1416== by 0x17C3061: SNES_KSPSolve (snes.c:2944) ==1416== by 0x17D33DE: SNESSolve_LS (ls.c:191) ==1416== [0]PETSC ERROR: ------------------------------------------------------------------------ [0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range [0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger [0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/petsc-as/documentation/troubleshooting.html#Signal[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors [0]PETSC ERROR: likely location of problem given in stack below
Dear Barry Sorry, I should complement that when I set DIFFERENT_NONZERO_PATTERN to the MatStructure, pastix works well. But it crash for SAME_NONZERO_PATTERN. However, I always use SAME_NONZERO_PATTERN before, which works for ksp solvers, mumps, superlu_dist, etc. Yours Gong Ding
Sorry. Yes there was another bug. What caused both of these problems is that Pastix requires a symmetric nonzero structure and the interface made some assumptions that the PETSc matrix had a symmetric nonzero structure which is usually true, hence it did not crash for most matrices people use. I've attached another copy of pastix.c follow the same procedure again. Barry On Dec 30, 2010, at 10:47 PM, Gong Ding wrote:
Dear Barry Sorry, I should complement that when I set DIFFERENT_NONZERO_PATTERN to the MatStructure, pastix works well. But it crash for SAME_NONZERO_PATTERN. However, I always use SAME_NONZERO_PATTERN before, which works for ksp solvers, mumps, superlu_dist, etc.
Yours Gong Ding
----- Original Message ----- From: "Barry Smith" <[email protected]> To: "PETSc users list" <[email protected]> Sent: Saturday, January 01, 2011 2:12 AM Subject: Re: [petsc-users] pastix solver break at pastix_checkMatrix Sorry. Yes there was another bug. What caused both of these problems is that Pastix requires a symmetric nonzero structure and the interface made some assumptions that the PETSc matrix had a symmetric nonzero structure which is usually true, hence it did not crash for most matrices people use. I've attached another copy of pastix.c follow the same procedure again. Barry Thank you, Barry. The new version of pastix.c works. And the previous patch of memory allocation seems useless, you can reset it back. Further more, valgrind reported serious memory leak. However, I think it is nothing to do with the petsc interface. Maybe update pastix to the latest version can solve this problem.
Dear Barry, It seems the patch will cause memory leak. when valOnly is false, memory will be allocated for colptr, row and values. 99: if (!valOnly){ 100: ierr = PetscMalloc(((*n)+1) *sizeof(PetscInt) ,colptr );CHKERRQ(ierr); 101: ierr = PetscMalloc( nnz *sizeof(PetscInt) ,row);CHKERRQ(ierr); 102: ierr = PetscMalloc( nnz *sizeof(PetscScalar),values);CHKERRQ(ierr); But at the end of function MatConvertToCSC 186: ierr = PetscMemcpy(*colptr,tmpcolptr,(*n+1)*sizeof(PetscInt));CHKERRQ(ierr); 187: ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscInt),row);CHKERRQ(ierr); 188: ierr = PetscMemcpy(*row,tmprows,((*colptr)[*n]-1)*sizeof(PetscInt));CHKERRQ(ierr); 189: ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscScalar),values);CHKERRQ(ierr); 190: ierr = PetscMemcpy(*values,tmpvalues,((*colptr)[*n]-1)*sizeof(PetscScalar));CHKERRQ(ierr); memory will be allocated again. Which means when code call MatConvertToCSC next time, the memory allocated at line 100-102 will be lost. Will you please fix this problem? i.e. check the *colptr, *row and *values, when they are not empty, skip the memory allocation at line 100-102. Yours Gong Ding
I just two distinct memory leaks in pastix.c (new file attached) for 3.1 (also fixed in petsc-dev). Barry On Jan 2, 2011, at 9:42 PM, Gong Ding wrote:
Dear Barry,
It seems the patch will cause memory leak.
when valOnly is false, memory will be allocated for colptr, row and values.
99: if (!valOnly){ 100: ierr = PetscMalloc(((*n)+1) *sizeof(PetscInt) ,colptr );CHKERRQ(ierr); 101: ierr = PetscMalloc( nnz *sizeof(PetscInt) ,row);CHKERRQ(ierr); 102: ierr = PetscMalloc( nnz *sizeof(PetscScalar),values);CHKERRQ(ierr);
But at the end of function MatConvertToCSC
186: ierr = PetscMemcpy(*colptr,tmpcolptr,(*n+1)*sizeof(PetscInt));CHKERRQ(ierr); 187: ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscInt),row);CHKERRQ(ierr); 188: ierr = PetscMemcpy(*row,tmprows,((*colptr)[*n]-1)*sizeof(PetscInt));CHKERRQ(ierr); 189: ierr = PetscMalloc(((*colptr)[*n]-1)*sizeof(PetscScalar),values);CHKERRQ(ierr); 190: ierr = PetscMemcpy(*values,tmpvalues,((*colptr)[*n]-1)*sizeof(PetscScalar));CHKERRQ(ierr);
memory will be allocated again. Which means when code call MatConvertToCSC next time, the memory allocated at line 100-102 will be lost.
Will you please fix this problem? i.e. check the *colptr, *row and *values, when they are not empty, skip the memory allocation at line 100-102.
Yours Gong Ding
participants (3)
-
Barry Smith -
Gong Ding -
Raeth, Peter