[petsc-dev] Patch to fix vector allocation in ksp-fcg
Barry Smith
bsmith at mcs.anl.gov
Sun Dec 21 19:23:55 CST 2014
Sascha,
Thanks. I have put it in the branch barry/fix-ksp-fcg and next for testing.
Barry
> On Dec 20, 2014, at 6:38 PM, Sascha Schnepp <mail at saschaschnepp.net> wrote:
>
> Hello,
>
> yes, I am sorry, there was a bug in the patch.
>
> The problem occurred when the number of preallocated vectors was bigger than the max number of old directions to store - as in the options in runex60. It hadn’t checked this case. Again, sorry for that.
>
> I prepared a new patch which also replaces a PetscMin for a PetscMax but also swaps argument positions. I ran ex2, ex43 and ex60 with appropriate options in valgrind and got no errors.
>
> BTW:
> valgrind is available for Mac through MacPorts again.
>
> Sascha
>
>
>
>
> On 20 Dec 2014, at 18:17, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> >
> > When I added this change src/ksp/ksp/examples/tutorials/ex60 make runex60 failed with valgrind errors.
> >
> > bsmith at es:/sandbox/bsmith/petsc/src/ksp/ksp/examples/tutorials$ /sandbox/bsmith/petsc/bin/petscmpiexec -valgrind -n 1 ./ex60 -ksp_monitor_short -ksp_rtol 1e-6 -diagfunc 1 -ksp_type fcg -ksp_fcg_mmax 1 -eta 0.1
> > ==14854== Invalid write of size 8
> > ==14854== at 0x5C32987: KSPAllocateVectors_FCG (fcg.c:37)
> > ==14854== by 0x5C32FE2: KSPSetUp_FCG (fcg.c:77)
> > ==14854== by 0x5BEBD69: KSPSetUp (itfunc.c:267)
> > ==14854== by 0x5BED3E3: KSPSolve (itfunc.c:419)
> > ==14854== by 0x403599: main (ex60.c:219)
> > ==14854== Address 0xa49f720 is 0 bytes after a block of size 16 alloc'd
> > ==14854== at 0x4C29BE8: memalign (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> > ==14854== by 0x4F33A45: PetscMallocAlign (mal.c:27)
> > ==14854== by 0x5C32D96: KSPSetUp_FCG (fcg.c:63)
> > ==14854== by 0x5BEBD69: KSPSetUp (itfunc.c:267)
> > ==14854== by 0x5BED3E3: KSPSolve (itfunc.c:419)
> > ==14854== by 0x403599: main (ex60.c:219)
> > ==14854==
> >
> > Thus I have removed this change.
> >
> > Barry
> >
> >> On Dec 19, 2014, at 8:18 AM, Sascha Schnepp <mail at saschaschnepp.net> wrote:
> >>
> >> Hello developers,
> >>
> >> I prepared a patch to fix the allocation of direction vectors in
> >> KSPAllocateVectors_FCG within ksp-fcg.
> >>
> >> The fix consists only of replacing a PetscMin with a PetscMax. This
> >> prevents vectors being allocated one-by-one instead of chunksize
> >> of them once the preallocated ones (nprealloc) are exhausted.
> >>
> >> Let me know if you prefer a PR.
> >>
> >> Best,
> >> Sascha
> >>
> >>
> >>
> >> --------------------------------------
> >> ETH Zurich
> >> Sascha Schnepp
> >> Institute of Geophysics - Geophysical Fluid Dynamics
> >> NO H23, Sonneggstrasse 5, 8092 Zurich, Switzerland
> >>
> >> schnepps at ethz.ch
> >> www.gfd.ethz.ch; www.saschaschnepp.net
> >>
> >> +41 44 632 0244 phone
> >>
> >> Consider encrypting your mail
> >> Public Key ID: 0x67AC24EF
> >> --------------------------------------
> >>
> >> <Fix-to-KSPAllocateVectors_FCG.patch>
> >
>
> <Fix-to-KSPAllocateVectors_FCG_2.patch>
More information about the petsc-dev
mailing list