<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 26, 2018 at 2:54 AM Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr">pierre.jolivet@enseeiht.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Hello,<div>The fix suggested by Mark resolves the error:</div><div><div>#define GAMG_HASH(key) (<span style="background-color:rgb(255,255,255)">PetscInt</span>)((((PetscInt64)7)*<span style="background-color:rgb(255,255,255)">(PetscInt64)</span>key)%<span style="background-color:rgb(255,255,255)">(PetscInt64)</span>a_tab->size)<br></div><div><br></div><div>I’m guessing this is similar to the fix suggested by Barry:</div><div>#define GAMG_HASH(key) ((((PetscInt64)7)*key)%a_tab->size)</div><div><br></div><div>FWIW, my problem has around 1.2B d.o.f., so if the key is something like a column or row index, that could explain the error when doing 7*key</div></div></div></blockquote><div><br></div><div>Thanks, and yep the integer rolls over. (unsigned PetscInt) should work also.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space"><div><div><br></div><div>Thanks,</div><div>Pierre</div><div><br><blockquote type="cite"><div>On 24 Jun 2018, at 11:28 PM, Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:</div><br class="m_-8994136112025225043Apple-interchange-newline"><div><div><br>  Pierre,<br><br>    Can you confirm if my suggested fix resolved the error message or not? If so, we'll add it to the maint branch.<br><br>   Thanks<br><br>    Barry<br><br><br><a href="https://stackoverflow.com/questions/11720656/modulo-operation-with-negative-numbers" target="_blank">https://stackoverflow.com/questions/11720656/modulo-operation-with-negative-numbers</a><br><br><br><br><blockquote type="cite">On Jun 24, 2018, at 4:19 PM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br><br><br><br>On Sun, Jun 24, 2018 at 2:09 PM Smith, Barry F. <<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>> wrote:<br><br><br><blockquote type="cite">On Jun 24, 2018, at 11:15 AM, Mark Adams <<a href="mailto:mfadams@lbl.gov" target="_blank">mfadams@lbl.gov</a>> wrote:<br><br>First, -pc_gamg_threshold 0.8  is crazy. 0.08 is very high. probably best to start with 0.<br><br>This threshold will delete all of your edges in the coarsening graph, probably, and GAMG will switch to a one level solve (silently although -info will tell you).<br><br>And yes, this looks like a 64 bit indices problem, we have:<br><br>#define GAMG_HASH(key) ((((PetscInt)7)*key)%a_tab->size)<br><br>We should probably cast everything to (long long) or (unsigned PetscInt) I guess ... I'm not sure how this should be done exactly.  Any ideas from the peanut gallery?<br></blockquote><br>Mark,<br><br>     It should only be changed if we know the exact mechanism that causes the failure. It is not obvious to me that just changing ((((PetscInt)7)*key)%a_tab->size) to ((((PetscInt64)7)*key)%a_tab->size) should matter.<br><br>If 7*key > 2B then you can get a negative number and %a_tab->size will still be a negative number, which triggers:<br><br>ksp/pc/impls/gamg/agg.c:          if (flid < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Cannot find gid1 in table”);<br><br>which is the second error that Pierre gets. I don't fully understand the first error but a messed up hash table is certainly a possibility.<br><br>And maybe we should cast the hell out of it to be safe:<br><br>#define GAMG_HASH(key) (PetscInt)((((PetscInt64)7)*(PetscInt64)key)%(PetscInt64)a_tab->size)<br><br>I am a bit puzzled that this works. I would think this would be more of a problem but maybe everyone just uses 64 bit ints. I have dealt with this many times and I am puzzled that I left it in a state that looks so wrong to me now. Perhaps Pierre's complicated thing is causing this somehow.<br><br><br><br>   Barry<br><br><blockquote type="cite"><br><br><br>On Sun, Jun 24, 2018 at 2:34 AM Pierre Jolivet <<a href="mailto:pierre.jolivet@enseeiht.fr" target="_blank">pierre.jolivet@enseeiht.fr</a>> wrote:<br>Hello,<br>Any ideas on how to debug this?<br>[406]PETSC ERROR: key 328214936 not found in table<br>[406]PETSC ERROR: See <a href="http://www.mcs.anl.gov/petsc/documentation/faq.html" target="_blank">http://www.mcs.anl.gov/petsc/documentation/faq.html</a> for trouble shooting.<br>[406]PETSC ERROR: Petsc Development GIT revision: v3.9.2-603-gceafe64  GIT Date: 2018-06-10 12:46:16 -0500<br>[406]PETSC ERROR: /ccc/work/cont003/rndm/rndm/FreeFem-sources/src/mpi/FreeFem++-mpi on a arch-linux2-c-debug-bullxmpi named curie2698 by jolivetp Sun Jun 24 07:06:07 2018<br>[406]PETSC ERROR: Configure options --with-scalar-type=real --with-hypre-dir=arch-linux2-c-opt-bullxmpi --with-metis-dir=arch-linux2-c-opt-bullxmpi --with-mumps-dir=arch-linux2-c-opt-bullxmpi --with-mkl_cpardiso=1 --with-mkl_pardiso=1 --with-parmetis-dir=arch-linux2-c-opt-bullxmpi --with-ptscotch-dir=arch-linux2-c-opt-bullxmpi --with-sowing-dir=arch-linux2-c-opt-bullxmpi --with-blacs-include=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl/include" target="_blank">18.0.1.163/mkl/include</a> --with-blacs-lib=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.so" target="_blank">18.0.1.163/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.so</a> --with-blaslapack-dir=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl/lib/intel64" target="_blank">18.0.1.163/mkl/lib/intel64</a> --with-x=0 --with-debugging=1 --with-errorchecking=1 --with-mkl_pardiso-dir=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl" target="_blank">18.0.1.163/mkl</a> --with-mkl_cpardiso-dir=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl" target="_blank">18.0.1.163/mkl</a> --with-scalapack-include=/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl/include" target="_blank">18.0.1.163/mkl/include</a> --with-scalapack-lib="[/ccc/products/mkl-18.0.1.163/default/<a href="http://18.0.1.163/mkl/lib/intel64/libmkl_scalapack_lp64.so,/ccc/products/mkl-18.0.1.163/default/18.0.1.163/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.so" target="_blank">18.0.1.163/mkl/lib/intel64/libmkl_scalapack_lp64.so,/ccc/products/mkl-18.0.1.163/default/18.0.1.163/mkl/lib/intel64/libmkl_blacs_openmpi_lp64.so</a>]" --with-fortran-bindings=0 PETSC_ARCH=arch-linux2-c-debug-bullxmpi<br>[406]PETSC ERROR: #1 PCGAMGHashTableFind() line 106 in /ccc/work/cont003/rndm/rndm/petsc/include/petsc/private/pcgamgimpl.h<br>[406]PETSC ERROR: #2 smoothAggs() line 526 in /ccc/work/cont003/rndm/rndm/petsc/src/ksp/pc/impls/gamg/agg.c<br>[406]PETSC ERROR: #3 PCGAMGCoarsen_AGG() line 970 in /ccc/work/cont003/rndm/rndm/petsc/src/ksp/pc/impls/gamg/agg.c<br>[406]PETSC ERROR: #4 PCSetUp_GAMG() line 518 in /ccc/work/cont003/rndm/rndm/petsc/src/ksp/pc/impls/gamg/gamg.c<br>[406]PETSC ERROR: #5 PCSetUp() line 932 in /ccc/work/cont003/rndm/rndm/petsc/src/ksp/pc/interface/precon.c<br>[406]PETSC ERROR: #6 KSPSetUp() line 381 in /ccc/work/cont003/rndm/rndm/petsc/src/ksp/ksp/interface/itfunc.c<br><br>For smaller problems, this works fine. Should I compile using 64 bit indices?<br>I’m using -pc_type gamg -pc_gamg_threshold 0.8 -pc_gamg_agg_nsmooths 1 -pc_gamg_sym_graph true -pc_gamg_square_graph 10<br><br>Thanks,<br>Pierre<br></blockquote></blockquote><br></div></div></blockquote></div><br></div></div></blockquote></div></div>