[petsc-dev] DMDA_*PERIODIC and DMDA_XYZGHOSTED
Lisandro Dalcin
dalcinl at gmail.com
Thu Mar 10 16:58:26 CST 2011
On 10 March 2011 19:37, Ethan Coon <ecoon at lanl.gov> wrote:
>
>> >
>> > Will get patches for these (and the doc fix).
>> >
>>
>> Could you also consider the patch below? I think the CHKMEMQ macros
>> should not be there, we are not calling "untrusted" user code, right?
>
> Oh crap, thanks, there's a bit more cruft that I thought I had removed.
>
>> And the missing free is causing the following output in petsc4py
>> testsuite:
>>
>> $ python test/runtests.py -i da
>> [0 at nikola] Python 2.6 (/usr/bin/python)
>> [0 at nikola] PETSc 3.1.0-p7 development (conf: 'arch-linux2-c-opt')
>> [0 at nikola] petsc4py 1.1.2 (build/lib.linux-x86_64-2.6/petsc4py)
>> [0]Total space allocated 123685312 bytes
>> [ 0]10137008 bytes DMSetUp_DA_3D() line 1272 in
>> /usr/local/petsc/dev/src/dm/impls/da/da3.c
>> [ 0]1302848 bytes DMSetUp_DA_3D() line 1272 in
>> /usr/local/petsc/dev/src/dm/impls/da/da3.c
>>
>>
>> diff -r 3923fa35e382 src/dm/impls/da/da2.c
>> --- a/src/dm/impls/da/da2.c Thu Mar 10 15:03:35 2011 -0600
>> +++ b/src/dm/impls/da/da2.c Thu Mar 10 19:03:28 2011 -0300
>> @@ -1734,7 +1734,6 @@
>> /* ierr = PetscLogObjectMemory(da,nn*dof*sizeof(PetscInt));CHKERRQ(ierr);*/
>> ierr = ISGetIndices(ltogis, &idx_full);
>> ierr = PetscMemcpy(idx_cpy,idx_full,nn*dof*sizeof(PetscInt));CHKERRQ(ierr);
>> - CHKMEMQ;
>> ierr = ISRestoreIndices(ltogis, &idx_full);
>> ierr = ISLocalToGlobalMappingCreateIS(ltogis,&da->ltogmap);CHKERRQ(ierr);
>> ierr = PetscLogObjectParent(da,da->ltogmap);CHKERRQ(ierr);
>> diff -r 3923fa35e382 src/dm/impls/da/da3.c
>> --- a/src/dm/impls/da/da3.c Thu Mar 10 15:03:35 2011 -0600
>> +++ b/src/dm/impls/da/da3.c Thu Mar 10 19:03:28 2011 -0300
>> @@ -1273,7 +1273,6 @@
>> /* ierr = PetscLogObjectMemory(da,nn*dof*sizeof(PetscInt));CHKERRQ(ierr); */
>> ierr = ISGetIndices(ltogis, &idx_full);
>> ierr = PetscMemcpy(idx_cpy,idx_full,nn*dof*sizeof(PetscInt));CHKERRQ(ierr);
>> - CHKMEMQ;
>> ierr = ISRestoreIndices(ltogis, &idx_full);
>> ierr = ISLocalToGlobalMappingCreateIS(ltogis,&da->ltogmap);CHKERRQ(ierr);
>> ierr = PetscLogObjectParent(da,da->ltogmap);CHKERRQ(ierr);
>> diff -r 3923fa35e382 src/dm/impls/da/dadestroy.c
>> --- a/src/dm/impls/da/dadestroy.c Thu Mar 10 15:03:35 2011 -0600
>> +++ b/src/dm/impls/da/dadestroy.c Thu Mar 10 19:03:28 2011 -0300
>> @@ -106,6 +106,7 @@
>> ierr = AODestroy(dd->ao);CHKERRQ(ierr);
>> }
>>
>> + ierr = PetscFree(dd->idx);CHKERRQ(ierr);
>> ierr = PetscFree(dd->lx);CHKERRQ(ierr);
>> ierr = PetscFree(dd->ly);CHKERRQ(ierr);
>> ierr = PetscFree(dd->lz);CHKERRQ(ierr);
>>
>>
>
> Hmm, I didn't add the dd->idx, so I'm suprised it wasn't free'd already.
> I also wasn't sure when/if to log the memory, since it seemed to be in
> there for some stuff and not for others in the previous code.
>
You should just log it in the DM object, just uncomment the line in
the 2D and 3D setup code
> With the copy (your next email) to the IS, shouldn't that changeset leak
> memory? I think it also needs a PetscFree(idx) then as well...
>
My two patches are cumulative... Take into account that DMDestroy_DA
applies to 1/2/3D, while the setup code is different. The free(idx) at
the common destoy() should be enough (provided you use COPY_VALUES for
the 1D code)
>
> Will get these fixes in,
>
With both patches applied, petsc4py testsuite pass cleanly (and mem
leaks seems to go away). So I'm more or less confident on your (huge)
changes + my (tiny) fixes
--
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
More information about the petsc-dev
mailing list