<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><div>Hi, Barry, </div><br><div>Thanks for your reply. I see the issue and I think I can now continue my work with a quick fix as you suggested. </div><br><div>Regards</div><div>JT</div><br><div class="gmail_quote_attribution">On Jul 19 2020, at 1:26 pm, Barry Smith <bsmith@petsc.dev> wrote:</div><blockquote><div><br><br><div>> On Jul 18, 2020, at 11:27 PM, Karl Yang <y.juntao@hotmail.com> wrote:</div><div>></div><div>></div><div>> Hello,</div><div>></div><div>> I was using FGMRES solver with fieldsplit preconditioner for solving a fluid equation.</div><div>> I have the code ran for coarser meshes and it works fine. But when I got it to run for very fine meshes I encountered the PetscLogFlops error.</div><div>></div><div>> The following is the output of error and the output from kspview.</div><div>></div><div>> [7]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>> [7]PETSC ERROR: Argument out of range</div><div>> [7]PETSC ERROR: Cannot log negative flops</div><div>> [7]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.</div><div>> [7]PETSC ERROR: Petsc Release Version 3.12.5, Mar, 29, 2020</div><div>> [7]PETSC ERROR: ./testSolve on a arch-linux2-c-debug named hsw222 by yjuntao Sat Jul 18 20:30:05 2020</div><div>> [7]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-cuda</div><div>> [7]PETSC ERROR: #1 PetscLogFlops() line 232 in /usr/local/petsc/petsc-3.12.5/include/petsclog.h</div><div>> [7]PETSC ERROR: #2 MatSolve_SeqAIJ() line 3200 in /usr/local/petsc/petsc-3.12.5/src/mat/impls/aij/seq/aijfact.c</div><div>> [7]PETSC ERROR: #3 MatSolve() line 3290 in /usr/local/petsc/petsc-3.12.5/src/mat/interface/matrix.c</div><div>> [7]PETSC ERROR: #4 PCApply_LU() line 177 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/impls/factor/lu/lu.c</div><div>> [7]PETSC ERROR: #5 PCApply() line 444 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/interface/precon.c</div><div>> [7]PETSC ERROR: #6 KSP_PCApply() line 281 in /usr/local/petsc/petsc-3.12.5/include/petsc/private/kspimpl.h</div><div>> [7]PETSC ERROR: #7 KSPInitialResidual() line 65 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itres.c</div><div>> [7]PETSC ERROR: #8 KSPSolve_GMRES() line 236 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/impls/gmres/gmres.c</div><div>> [7]PETSC ERROR: #9 KSPSolve() line 760 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itfunc.c</div><div>> [7]PETSC ERROR: #10 PCApply_FieldSplit_Schur() line 1180 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/impls/fieldsplit/fieldsplit.c</div><div>> [7]PETSC ERROR: #11 PCApply() line 444 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/interface/precon.c</div><div>> [7]PETSC ERROR: #12 KSP_PCApply() line 281 in /usr/local/petsc/petsc-3.12.5/include/petsc/private/kspimpl.h</div><div>> [7]PETSC ERROR: #13 KSPFGMRESCycle() line 166 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/impls/gmres/fgmres/fgmres.c</div><div>> [7]PETSC ERROR: #14 KSPSolve_FGMRES() line 291 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/impls/gmres/fgmres/fgmres.c</div><div>> [7]PETSC ERROR: #15 KSPSolve() line 760 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itfunc.c</div><div>></div><br><div>PetscErrorCode MatSolve_SeqAIJ(Mat A,Vec bb,Vec xx)</div><div>{</div><div>Mat_SeqAIJ *a = (Mat_SeqAIJ*)A->data;</div><div>IS iscol = a->col,isrow = a->row;</div><div>PetscErrorCode ierr;</div><div>PetscInt i,n=A->rmap->n,*vi,*ai=a->i,*aj=a->j,*adiag = a->diag,nz;</div><div>const PetscInt *rout,*cout,*r,*c;</div><div>PetscScalar *x,*tmp,sum;</div><div>const PetscScalar *b;</div><div>const MatScalar *aa = a->a,*v;</div><br><div>PetscFunctionBegin;</div><div>if (!n) PetscFunctionReturn(0);</div><br><div>......</div><br><div>ierr = PetscLogFlops(2*a->nz - A->cmap->n);CHKERRQ(ierr);</div><div>PetscFunctionReturn(0);</div><br><div>Could maybe be integer overflow where a->nz fits but 2*a->nz doesn't fit so it results in a negative integer that is then converted to a negative floating point number.</div><br><div>It should have a 2.0*a->nz but we must have missed this place in the code. We can fix this.</div><br><div>> There is some issues during kspview if PCLSC is used as shown below. But the code could be ran if I do not show ksp details.</div><div>> In order to show the whole ksp setup, I also attached another kspview output without PCLSC.</div><div>> ======================kspview output ==============================</div><div>> KSP Object: 1 MPI processes</div><div>> type: fgmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-08, absolute=1e-50, divergence=10000.</div><div>> right preconditioning</div><div>> using UNPRECONDITIONED norm type for convergence test</div><div>> PC Object: 1 MPI processes</div><div>> type: fieldsplit</div><div>> FieldSplit with Schur preconditioner, blocksize = 1, factorization FULL</div><div>> Preconditioner for the Schur complement formed from S itself</div><div>> Split info:</div><div>> Split number 0 Defined by IS</div><div>> Split number 1 Defined by IS</div><div>> KSP solver for A00 block</div><div>> KSP Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: gmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-05, absolute=1e-50, divergence=10000.</div><div>> left preconditioning</div><div>> using DEFAULT norm type for convergence test</div><div>> PC Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: lu</div><div>> PC has not been set up so information may be incomplete</div><div>> out-of-place factorization</div><div>> tolerance for zero pivot 2.22045e-14</div><div>> matrix ordering: nd</div><div>> linear system matrix = precond matrix:</div><div>> Mat Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=8396802, cols=8396802</div><div>> total: nonzeros=75440146, allocated nonzeros=75440146</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> KSP solver for S = A11 - A10 inv(A00) A01</div><div>> KSP Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: gmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-05, absolute=1e-50, divergence=10000.</div><div>> left preconditioning</div><div>> using DEFAULT norm type for convergence test</div><div>> PC Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: lsc</div><div>> PC has not been set up so information may be incomplete</div><div>> [0]PETSC ERROR: --------------------- Error Message --------------------------------------------------------------</div><div>> [0]PETSC ERROR: Null argument, when expecting valid pointer</div><div>> [0]PETSC ERROR: Null Object: Parameter # 1</div><div>> [0]PETSC ERROR: See https://www.mcs.anl.gov/petsc/documentation/faq.html for trouble shooting.</div><div>> [0]PETSC ERROR: Petsc Release Version 3.12.5, Mar, 29, 2020</div><div>> [0]PETSC ERROR: ./testSolve on a arch-linux2-c-debug named hsw221 by yjuntao Sat Jul 18 21:08:42 2020</div><div>> [0]PETSC ERROR: Configure options --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack --with-cuda</div><div>> [0]PETSC ERROR: #1 KSPView() line 111 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itcreate.c</div><div>> [0]PETSC ERROR: #2 PCView_LSC() line 142 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/impls/lsc/lsc.c</div><div>> [0]PETSC ERROR: #3 PCView() line 1588 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/interface/precon.c</div><div>> [0]PETSC ERROR: #4 KSPView() line 217 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itcreate.c</div><div>> [0]PETSC ERROR: #5 PCView_FieldSplit_Schur() line 238 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/impls/fieldsplit/fieldsplit.c</div><div>> [0]PETSC ERROR: #6 PCView() line 1588 in /usr/local/petsc/petsc-3.12.5/src/ksp/pc/interface/precon.c</div><div>> [0]PETSC ERROR: #7 KSPView() line 217 in /usr/local/petsc/petsc-3.12.5/src/ksp/ksp/interface/itcreate.c</div><br><div>This is something we can fix. Since the LSC has not been setup yet it should skip the KSPView on the KSP that has not yet been created.</div><br><div>static PetscErrorCode PCView_LSC(PC pc,PetscViewer viewer)</div><div>{</div><div>PC_LSC *jac = (PC_LSC*)pc->data;</div><div>PetscErrorCode ierr;</div><div>PetscBool iascii;</div><br><div>PetscFunctionBegin;</div><div>ierr = PetscObjectTypeCompare((PetscObject)viewer,PETSCVIEWERASCII,&iascii);CHKERRQ(ierr);</div><div>if (iascii) {</div><div>ierr = PetscViewerASCIIPushTab(viewer);CHKERRQ(ierr);</div><div>ierr = KSPView(jac->kspL,viewer);CHKERRQ(ierr);</div><div>ierr = PetscViewerASCIIPopTab(viewer);CHKERRQ(ierr);</div><div>}</div><div>PetscFunctionReturn(0);</div><div>}</div><br><div>></div><div>> =====================KSP without PCLSC======================================</div><div>> KSP Object: 1 MPI processes</div><div>> type: fgmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-08, absolute=1e-50, divergence=10000.</div><div>> right preconditioning</div><div>> using UNPRECONDITIONED norm type for convergence test</div><div>> PC Object: 1 MPI processes</div><div>> type: fieldsplit</div><div>> FieldSplit with Schur preconditioner, blocksize = 1, factorization FULL</div><div>> Preconditioner for the Schur complement formed from S itself</div><div>> Split info:</div><div>> Split number 0 Defined by IS</div><div>> Split number 1 Defined by IS</div><div>> KSP solver for A00 block</div><div>> KSP Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: gmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-05, absolute=1e-50, divergence=10000.</div><div>> left preconditioning</div><div>> using DEFAULT norm type for convergence test</div><div>> PC Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: lu</div><div>> PC has not been set up so information may be incomplete</div><div>> out-of-place factorization</div><div>> tolerance for zero pivot 2.22045e-14</div><div>> matrix ordering: nd</div><div>> linear system matrix = precond matrix:</div><div>> Mat Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=8396802, cols=8396802</div><div>> total: nonzeros=75440146, allocated nonzeros=75440146</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> KSP solver for S = A11 - A10 inv(A00) A01</div><div>> KSP Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: gmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-05, absolute=1e-50, divergence=10000.</div><div>> left preconditioning</div><div>> using DEFAULT norm type for convergence test</div><div>> PC Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: none</div><div>> PC has not been set up so information may be incomplete</div><div>> linear system matrix = precond matrix:</div><div>> Mat Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: schurcomplement</div><div>> rows=1050625, cols=1050625</div><div>> Schur complement A11 - A10 inv(A00) A01</div><div>> A11</div><div>> Mat Object: (fieldsplit_1_) 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=1050625, cols=1050625</div><div>> total: nonzeros=0, allocated nonzeros=0</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> A10</div><div>> Mat Object: 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=1050625, cols=8396802</div><div>> total: nonzeros=44060674, allocated nonzeros=44060674</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> KSP of A00</div><div>> KSP Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: gmres</div><div>> restart=30, using Classical (unmodified) Gram-Schmidt Orthogonalization with no iterative refinement</div><div>> happy breakdown tolerance 1e-30</div><div>> maximum iterations=10000, initial guess is zero</div><div>> tolerances: relative=1e-05, absolute=1e-50, divergence=10000.</div><div>> left preconditioning</div><div>> using DEFAULT norm type for convergence test</div><div>> PC Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: lu</div><div>> PC has not been set up so information may be incomplete</div><div>> out-of-place factorization</div><div>> tolerance for zero pivot 2.22045e-14</div><div>> matrix ordering: nd</div><div>> linear system matrix = precond matrix:</div><div>> Mat Object: (fieldsplit_0_) 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=8396802, cols=8396802</div><div>> total: nonzeros=75440146, allocated nonzeros=75440146</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> A01</div><div>> Mat Object: 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=8396802, cols=1050625</div><div>> total: nonzeros=43995146, allocated nonzeros=43995146</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>> linear system matrix = precond matrix:</div><div>> Mat Object: 1 MPI processes</div><div>> type: seqaijcusparse</div><div>> rows=9447427, cols=9447427</div><div>> total: nonzeros=163495966, allocated nonzeros=163643398</div><div>> total number of mallocs used during MatSetValues calls=0</div><div>> not using I-node routines</div><div>></div><div>> Regards</div><div>> JT</div></div></blockquote>