From 88477d50cbfad1dd0e6f4f21f4f32deb018372eb Mon Sep 17 00:00:00 2001 From: heister Date: Mon, 5 Aug 2013 22:02:59 +0000 Subject: [PATCH] simple test to see memory leaks git-svn-id: https://svn.dealii.org/trunk@30229 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/gla/vec_06.cc | 95 ++++++++++++++++++++++++++++ tests/gla/vec_06/ncpu_10/cmp/generic | 67 ++++++++++++++++++++ tests/gla/vec_06/ncpu_4/cmp/generic | 31 +++++++++ 3 files changed, 193 insertions(+) create mode 100644 tests/gla/vec_06.cc create mode 100644 tests/gla/vec_06/ncpu_10/cmp/generic create mode 100644 tests/gla/vec_06/ncpu_4/cmp/generic diff --git a/tests/gla/vec_06.cc b/tests/gla/vec_06.cc new file mode 100644 index 0000000000..562dbecd46 --- /dev/null +++ b/tests/gla/vec_06.cc @@ -0,0 +1,95 @@ +// --------------------------------------------------------------------- +// $Id$ +// +// Copyright (C) 2004 - 2013 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + + +// track memory leak in PETSc + +#include "../tests.h" +#include +#include +#include +#include +#include +#include +#include + +#include "gla.h" + +template +void test () +{ + unsigned int myid = Utilities::MPI::this_mpi_process (MPI_COMM_WORLD); + unsigned int numproc = Utilities::MPI::n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) + deallog << "numproc=" << numproc << std::endl; + + // each processor owns 2 indices and all + // are ghosting Element 1 (the second) + + IndexSet local_active(numproc*2); + local_active.add_range(myid*2,myid*2+2); + IndexSet local_relevant(numproc*2); + local_relevant.add_range(1,2); + + typename LA::MPI::Vector vb(local_active, MPI_COMM_WORLD); + typename LA::MPI::Vector v(local_active, local_relevant, MPI_COMM_WORLD); + + vb = 1.0; + + // set local values + vb(myid*2)=myid*2.0; + vb(myid*2+1)=myid*2.0+1.0; + + vb.compress(VectorOperation::insert); + v=vb; + + { + typename LA::MPI::Vector x; + typename LA::MPI::Vector y; + x=y; + } + { + typename LA::MPI::Vector x; + x=v; + } + { + typename LA::MPI::Vector x; + x=vb; + } + + // done + if (myid==0) + deallog << "OK" << std::endl; +} + + + +int main (int argc, char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, 1); + MPILogInitAll log(__FILE__); + { + deallog.push("PETSc"); + test(); + deallog.pop(); + deallog.push("Trilinos"); + test(); + deallog.pop(); + } + +} diff --git a/tests/gla/vec_06/ncpu_10/cmp/generic b/tests/gla/vec_06/ncpu_10/cmp/generic new file mode 100644 index 0000000000..acad5b14a4 --- /dev/null +++ b/tests/gla/vec_06/ncpu_10/cmp/generic @@ -0,0 +1,67 @@ + +DEAL:0:PETSc::numproc=10 +DEAL:0:PETSc::0: 0.00000 +DEAL:0:PETSc::1: 2.00000 +DEAL:0:PETSc::before: 2.00000 +DEAL:0:PETSc::after: 12.0000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=10 +DEAL:0:Trilinos::0: 0.00000 +DEAL:0:Trilinos::1: 2.00000 +DEAL:0:Trilinos::before: 2.00000 +DEAL:0:Trilinos::after: 12.0000 +DEAL:0:Trilinos::OK + +DEAL:1:PETSc::2: 4.00000 +DEAL:1:PETSc::3: 6.00000 +DEAL:1:Trilinos::2: 4.00000 +DEAL:1:Trilinos::3: 6.00000 + + +DEAL:2:PETSc::4: 8.00000 +DEAL:2:PETSc::5: 10.0000 +DEAL:2:Trilinos::4: 8.00000 +DEAL:2:Trilinos::5: 10.0000 + + +DEAL:3:PETSc::6: 12.0000 +DEAL:3:PETSc::7: 14.0000 +DEAL:3:Trilinos::6: 12.0000 +DEAL:3:Trilinos::7: 14.0000 + + +DEAL:4:PETSc::8: 16.0000 +DEAL:4:PETSc::9: 18.0000 +DEAL:4:Trilinos::8: 16.0000 +DEAL:4:Trilinos::9: 18.0000 + + +DEAL:5:PETSc::10: 20.0000 +DEAL:5:PETSc::11: 22.0000 +DEAL:5:Trilinos::10: 20.0000 +DEAL:5:Trilinos::11: 22.0000 + + +DEAL:6:PETSc::12: 24.0000 +DEAL:6:PETSc::13: 26.0000 +DEAL:6:Trilinos::12: 24.0000 +DEAL:6:Trilinos::13: 26.0000 + + +DEAL:7:PETSc::14: 28.0000 +DEAL:7:PETSc::15: 30.0000 +DEAL:7:Trilinos::14: 28.0000 +DEAL:7:Trilinos::15: 30.0000 + + +DEAL:8:PETSc::16: 32.0000 +DEAL:8:PETSc::17: 34.0000 +DEAL:8:Trilinos::16: 32.0000 +DEAL:8:Trilinos::17: 34.0000 + + +DEAL:9:PETSc::18: 36.0000 +DEAL:9:PETSc::19: 38.0000 +DEAL:9:Trilinos::18: 36.0000 +DEAL:9:Trilinos::19: 38.0000 + diff --git a/tests/gla/vec_06/ncpu_4/cmp/generic b/tests/gla/vec_06/ncpu_4/cmp/generic new file mode 100644 index 0000000000..17a7739b76 --- /dev/null +++ b/tests/gla/vec_06/ncpu_4/cmp/generic @@ -0,0 +1,31 @@ + +DEAL:0:PETSc::numproc=4 +DEAL:0:PETSc::0: 0.00000 +DEAL:0:PETSc::1: 2.00000 +DEAL:0:PETSc::before: 2.00000 +DEAL:0:PETSc::after: 12.0000 +DEAL:0:PETSc::OK +DEAL:0:Trilinos::numproc=4 +DEAL:0:Trilinos::0: 0.00000 +DEAL:0:Trilinos::1: 2.00000 +DEAL:0:Trilinos::before: 2.00000 +DEAL:0:Trilinos::after: 12.0000 +DEAL:0:Trilinos::OK + +DEAL:1:PETSc::2: 4.00000 +DEAL:1:PETSc::3: 6.00000 +DEAL:1:Trilinos::2: 4.00000 +DEAL:1:Trilinos::3: 6.00000 + + +DEAL:2:PETSc::4: 8.00000 +DEAL:2:PETSc::5: 10.0000 +DEAL:2:Trilinos::4: 8.00000 +DEAL:2:Trilinos::5: 10.0000 + + +DEAL:3:PETSc::6: 12.0000 +DEAL:3:PETSc::7: 14.0000 +DEAL:3:Trilinos::6: 12.0000 +DEAL:3:Trilinos::7: 14.0000 + -- 2.39.5