Re: [petsc-users] what kind of stuffs I forget to free?
Thanks, Jed, I tried valgrind, but it could not catch any noises. I used these options: mpirun -n 8 valgrind --tool=memcheck -q --num-callers=20 --log-file=valgrind.log.%p ./nonlinearElasticity3d -malloc off . I think I forget freeing something or petsc does. On Wed, Mar 19, 2014 at 4:58 PM, Jed Brown j...@jedbrown.org wrote: Fande Kong fd.k...@siat.ac.cn writes: I run my code with options: -malloc_debug -malloc_dump, then the following messages are produced, but nothing happened in my code. I want to know what kind of objects I forgot freeing. Any suggestions? Huh, those should show more stack. Before trying to think hard, can you run with valgrind? [0]Total space allocated 6864 bytes [ 0]256 bytes PetscSplitReductionCreate() line 91 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]256 bytes PetscSplitReductionCreate() line 88 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 87 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 86 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]80 bytes PetscSplitReductionCreate() line 81 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]16 bytes PetscThreadCommReductionCreate() line 448 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]512 bytes PetscThreadCommReductionCreate() line 440 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]256 bytes PetscThreadCommReductionCreate() line 436 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]1280 bytes PetscThreadCommReductionCreate() line 435 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]32 bytes PetscThreadCommReductionCreate() line 432 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]128 bytes PetscThreadCommWorldInitialize() line 1242 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]2560 bytes PetscThreadCommWorldInitialize() line 1241 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscThreadCommWorldInitialize() line 1233 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]16 bytes PetscThreadCommSetAffinities() line 424 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]48 bytes PetscThreadCommCreate() line 150 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]336 bytes PetscThreadCommCreate() line 146 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscCommDuplicate() line 151 in /home/fdkong/math/petsc-3.4.1/src/sys/objects/tagm.c Fande,
Re: [petsc-users] what kind of stuffs I forget to free?
Hi Jed, I finally figured out why. I think there is a bug in the PETSc. I write a very simple program that can reproduce the same results. Please check the attachment. Type make all -f makefilet to run this code. Could you know how to fix this issue? Thanks, On Thu, Mar 20, 2014 at 11:29 AM, Fande Kong fd.k...@siat.ac.cn wrote: Thanks, Jed, I tried valgrind, but it could not catch any noises. I used these options: mpirun -n 8 valgrind --tool=memcheck -q --num-callers=20 --log-file=valgrind.log.%p ./nonlinearElasticity3d -malloc off . I think I forget freeing something or petsc does. On Wed, Mar 19, 2014 at 4:58 PM, Jed Brown j...@jedbrown.org wrote: Fande Kong fd.k...@siat.ac.cn writes: I run my code with options: -malloc_debug -malloc_dump, then the following messages are produced, but nothing happened in my code. I want to know what kind of objects I forgot freeing. Any suggestions? Huh, those should show more stack. Before trying to think hard, can you run with valgrind? [0]Total space allocated 6864 bytes [ 0]256 bytes PetscSplitReductionCreate() line 91 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]256 bytes PetscSplitReductionCreate() line 88 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 87 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 86 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]80 bytes PetscSplitReductionCreate() line 81 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]16 bytes PetscThreadCommReductionCreate() line 448 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]512 bytes PetscThreadCommReductionCreate() line 440 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]256 bytes PetscThreadCommReductionCreate() line 436 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]1280 bytes PetscThreadCommReductionCreate() line 435 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]32 bytes PetscThreadCommReductionCreate() line 432 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]128 bytes PetscThreadCommWorldInitialize() line 1242 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]2560 bytes PetscThreadCommWorldInitialize() line 1241 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscThreadCommWorldInitialize() line 1233 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]16 bytes PetscThreadCommSetAffinities() line 424 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]48 bytes PetscThreadCommCreate() line 150 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]336 bytes PetscThreadCommCreate() line 146 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscCommDuplicate() line 151 in /home/fdkong/math/petsc-3.4.1/src/sys/objects/tagm.c Fande, /* * commproblem.cpp * * Created on: Mar 20, 2014 * Author: fdkong */ #include petscsnes.h #include petscdm.h #include petsc-private/snesimpl.h static char help[] = Need helps.\n\n; #undef __FUNCT__ #define __FUNCT__ main int main(int argc,char **argv) { Vec vec; MPI_Request request; MPI_Statusstatus; PetscMPIInt tag =123; MPI_Comm comm; PetscMPIInt rank, size; PetscInt recv =10; PetscInt send = 0; DM dm; PetscErrorCodeierr; PetscInitialize(argc,argv,(char *)0,help); comm = PETSC_COMM_WORLD; ierr = MPI_Comm_rank(comm, rank);CHKERRQ(ierr); ierr = MPI_Comm_size(comm, size);CHKERRQ(ierr); // create an object ierr = VecCreate(comm, vec);CHKERRQ(ierr); // take a comm from that object comm = ((PetscObject) vec)-comm; // if we set comm back to PETSC_COMM_WORLD, the code should work fine //comm = PETSC_COMM_WORLD; // receive messages from rank 0 if( rank!=0) { ierr = MPI_Irecv(recv, 1, MPIU_INT, 0,tag, comm, request);CHKERRQ(ierr); } if(!rank) { //send messages to all others for(PetscMPIInt i =1; isize;i++) { ierr = MPI_Isend(send, 1, MPIU_INT, i, tag, comm, request);CHKERRQ(ierr); } } // rank 0 doest not need to wait, it could continue to do other things. if(rank !=0) { ierr = MPI_Waitall(1,request, status);CHKERRQ(ierr); } ierr = VecDestroy(vec);CHKERRQ(ierr); ierr = PetscFinalize();CHKERRQ(ierr); } makefilet Description: Binary data
Re: [petsc-users] what kind of stuffs I forget to free?
Fande Kong fd.k...@siat.ac.cn writes: /* * commproblem.cpp * * Created on: Mar 20, 2014 * Author: fdkong */ #include petscsnes.h #include petscdm.h #include petsc-private/snesimpl.h static char help[] = Need helps.\n\n; #undef __FUNCT__ #define __FUNCT__ main int main(int argc,char **argv) { Vec vec; MPI_Request request; MPI_Statusstatus; PetscMPIInt tag =123; MPI_Comm comm; PetscMPIInt rank, size; PetscInt recv =10; PetscInt send = 0; DM dm; PetscErrorCodeierr; PetscInitialize(argc,argv,(char *)0,help); comm = PETSC_COMM_WORLD; ierr = MPI_Comm_rank(comm, rank);CHKERRQ(ierr); ierr = MPI_Comm_size(comm, size);CHKERRQ(ierr); // create an object ierr = VecCreate(comm, vec);CHKERRQ(ierr); // take a comm from that object comm = ((PetscObject) vec)-comm; // if we set comm back to PETSC_COMM_WORLD, the code should work fine //comm = PETSC_COMM_WORLD; // receive messages from rank 0 if( rank!=0) { ierr = MPI_Irecv(recv, 1, MPIU_INT, 0,tag, comm, request);CHKERRQ(ierr); } You have to wait on this request. MPI_Requests are not automatically collected at some point where you can prove that the operation has finished. The Wait should return immediately, but you have to call it. Otherwise MPI holds a reference to the communicator and will not call the destructors. if(!rank) { //send messages to all others for(PetscMPIInt i =1; isize;i++) { ierr = MPI_Isend(send, 1, MPIU_INT, i, tag, comm, request);CHKERRQ(ierr); } } // rank 0 doest not need to wait, it could continue to do other things. It *does* need to wait eventually. if(rank !=0) { ierr = MPI_Waitall(1,request, status);CHKERRQ(ierr); } ierr = VecDestroy(vec);CHKERRQ(ierr); ierr = PetscFinalize();CHKERRQ(ierr); } pgpHnMSShcFGH.pgp Description: PGP signature
Re: [petsc-users] what kind of stuffs I forget to free?
Jed, Thanks, On Thu, Mar 20, 2014 at 10:39 PM, Jed Brown j...@jedbrown.org wrote: Fande Kong fd.k...@siat.ac.cn writes: /* * commproblem.cpp * * Created on: Mar 20, 2014 * Author: fdkong */ #include petscsnes.h #include petscdm.h #include petsc-private/snesimpl.h static char help[] = Need helps.\n\n; #undef __FUNCT__ #define __FUNCT__ main int main(int argc,char **argv) { Vec vec; MPI_Request request; MPI_Statusstatus; PetscMPIInt tag =123; MPI_Comm comm; PetscMPIInt rank, size; PetscInt recv =10; PetscInt send = 0; DM dm; PetscErrorCodeierr; PetscInitialize(argc,argv,(char *)0,help); comm = PETSC_COMM_WORLD; ierr = MPI_Comm_rank(comm, rank);CHKERRQ(ierr); ierr = MPI_Comm_size(comm, size);CHKERRQ(ierr); // create an object ierr = VecCreate(comm, vec);CHKERRQ(ierr); // take a comm from that object comm = ((PetscObject) vec)-comm; // if we set comm back to PETSC_COMM_WORLD, the code should work fine //comm = PETSC_COMM_WORLD; // receive messages from rank 0 if( rank!=0) { ierr = MPI_Irecv(recv, 1, MPIU_INT, 0,tag, comm, request);CHKERRQ(ierr); } You have to wait on this request. MPI_Requests are not automatically collected at some point where you can prove that the operation has finished. The Wait should return immediately, but you have to call it. Otherwise MPI holds a reference to the communicator and will not call the destructors. if(!rank) { //send messages to all others for(PetscMPIInt i =1; isize;i++) { ierr = MPI_Isend(send, 1, MPIU_INT, i, tag, comm, request);CHKERRQ(ierr); } } // rank 0 doest not need to wait, it could continue to do other things. It *does* need to wait eventually. if(rank !=0) { ierr = MPI_Waitall(1,request, status);CHKERRQ(ierr); } ierr = VecDestroy(vec);CHKERRQ(ierr); ierr = PetscFinalize();CHKERRQ(ierr); }
[petsc-users] what kind of stuffs I forget to free?
Hi, I run my code with options: -malloc_debug -malloc_dump, then the following messages are produced, but nothing happened in my code. I want to know what kind of objects I forgot freeing. Any suggestions? [0]Total space allocated 6864 bytes [ 0]256 bytes PetscSplitReductionCreate() line 91 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]256 bytes PetscSplitReductionCreate() line 88 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 87 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 86 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]80 bytes PetscSplitReductionCreate() line 81 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]16 bytes PetscThreadCommReductionCreate() line 448 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]512 bytes PetscThreadCommReductionCreate() line 440 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]256 bytes PetscThreadCommReductionCreate() line 436 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]1280 bytes PetscThreadCommReductionCreate() line 435 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]32 bytes PetscThreadCommReductionCreate() line 432 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]128 bytes PetscThreadCommWorldInitialize() line 1242 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]2560 bytes PetscThreadCommWorldInitialize() line 1241 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscThreadCommWorldInitialize() line 1233 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]16 bytes PetscThreadCommSetAffinities() line 424 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]48 bytes PetscThreadCommCreate() line 150 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]336 bytes PetscThreadCommCreate() line 146 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscCommDuplicate() line 151 in /home/fdkong/math/petsc-3.4.1/src/sys/objects/tagm.c Fande,
Re: [petsc-users] what kind of stuffs I forget to free?
Fande Kong fd.k...@siat.ac.cn writes: I run my code with options: -malloc_debug -malloc_dump, then the following messages are produced, but nothing happened in my code. I want to know what kind of objects I forgot freeing. Any suggestions? Huh, those should show more stack. Before trying to think hard, can you run with valgrind? [0]Total space allocated 6864 bytes [ 0]256 bytes PetscSplitReductionCreate() line 91 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]256 bytes PetscSplitReductionCreate() line 88 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 87 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]512 bytes PetscSplitReductionCreate() line 86 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]80 bytes PetscSplitReductionCreate() line 81 in /home/fdkong/math/petsc-3.4.1/src/vec/vec/utils/comb.c [ 0]16 bytes PetscThreadCommReductionCreate() line 448 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]512 bytes PetscThreadCommReductionCreate() line 440 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]256 bytes PetscThreadCommReductionCreate() line 436 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]1280 bytes PetscThreadCommReductionCreate() line 435 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]32 bytes PetscThreadCommReductionCreate() line 432 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcommred.c [ 0]128 bytes PetscThreadCommWorldInitialize() line 1242 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]2560 bytes PetscThreadCommWorldInitialize() line 1241 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscThreadCommWorldInitialize() line 1233 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]16 bytes PetscThreadCommSetAffinities() line 424 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]48 bytes PetscThreadCommCreate() line 150 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]336 bytes PetscThreadCommCreate() line 146 in /home/fdkong/math/petsc-3.4.1/src/sys/threadcomm/interface/threadcomm.c [ 0]32 bytes PetscCommDuplicate() line 151 in /home/fdkong/math/petsc-3.4.1/src/sys/objects/tagm.c Fande, pgp4ldFi3jJyn.pgp Description: PGP signature