On 12 April 2011 10:26, Barry Smith <bsmith at mcs.anl.gov> wrote:
>
> On Apr 11, 2011, at 10:02 PM, Lisandro Dalcin wrote:
>
>> After adding this test in petsc4py-dev/test/test_ksp.py :
>>
>> ? ?def testResetAndSolve(self):
>> ? ? ? ?self.ksp.reset()
>> ? ? ? ?self.testSolve()
>> ? ? ? ?self.ksp.reset()
>> ? ? ? ?self.testSolve()
>> ? ? ? ?self.ksp.reset()
>>
>> it seems there is some memory bleeding:
>>
>> [0]Total space allocated 256 bytes
>> [ 0]80 bytes KSPSetUp_BCGSL() line 476 in
>> /home/devel/petsc/dev/src/ksp/ksp/impls/bcgsl/bcgsl.c
>> ? ? ?[0] ?KSPSetUp() line 184 in
>> /home/devel/petsc/dev/src/ksp/ksp/interface/itfunc.c
>> ? ? ?[0] ?KSPSolve() line 332 in
>> /home/devel/petsc/dev/src/ksp/ksp/interface/itfunc.c
>>
>> These are workspace arrays that are re-allocated at every KSPSetup_BCGSL 
>> call.
>>
>> Not sure about the proper way to fix this, but I would deallocate the
>> arrays at KSPReset_BCGSL. Can anyone help me with this?
>>
> ? ?This could be a problem in many places: for example if eigenvalue 
> computing is done with CG then I think those arrays will be reallocated.
>

Indeed. I'm not testing eigenvalue computing. I could try to add the
options to my testsuite and see what happens.

> ? Previously I guess KSPSetUp_XXX() never had a reason to be called more than 
> once, with reset now it is. So that means that all arrays allocated in 
> KSPSetUp_XXX() should be freed in KSPReset_XXX()? If this is correct then it 
> is easily fixed by moving them from KSPDestroy_XXX().
>

Well, In my latest push I was lazy enough as to not remove the
PetscFree() call to Reset_XXX. After all, PetscFree() nullifies the
pointer, so we are safe. If you want me to fix this, let me know.

PS: Barry, could you check BCGLS for a few "ksp->setupstage =
KSP_SETUP_NEW;" lines? This really smells, such approach forces a full
KSPSetup(), not just the subype.


-- 
Lisandro Dalcin
---------------
CIMEC (INTEC/CONICET-UNL)
Predio CONICET-Santa Fe
Colectora RN 168 Km 472, Paraje El Pozo
3000 Santa Fe, Argentina
Tel: +54-342-4511594 (ext 1011)
Tel/Fax: +54-342-4511169

Reply via email to