From 8123e9571ddde0101acbbc719bfde899e1d2a9b1 Mon Sep 17 00:00:00 2001 From: heister Date: Mon, 29 Aug 2011 21:59:20 +0000 Subject: [PATCH] add test that documents unwanted PETSc::MPI::SparseMatrix behavior. Currently disabled, because it hangs git-svn-id: https://svn.dealii.org/trunk@24209 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/mpi/petsc_02.cc | 78 ++++++++++++++++++++++++++ tests/mpi/petsc_02/ncpu_1/cmp/generic | 4 ++ tests/mpi/petsc_02/ncpu_10/cmp/generic | 4 ++ tests/mpi/petsc_02/ncpu_4/cmp/generic | 4 ++ 4 files changed, 90 insertions(+) create mode 100644 tests/mpi/petsc_02.cc create mode 100644 tests/mpi/petsc_02/ncpu_1/cmp/generic create mode 100644 tests/mpi/petsc_02/ncpu_10/cmp/generic create mode 100644 tests/mpi/petsc_02/ncpu_4/cmp/generic diff --git a/tests/mpi/petsc_02.cc b/tests/mpi/petsc_02.cc new file mode 100644 index 0000000000..401600b3ec --- /dev/null +++ b/tests/mpi/petsc_02.cc @@ -0,0 +1,78 @@ +//--------------------------------------------------------------------------- +// $Id: simple_mpi_01.cc 23327 2011-02-11 03:19:07Z bangerth $ +// Version: $Name$ +// +// Copyright (C) 2009 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +// PETScWrappers: document bug with PETSc SparseMatrix. If only one CPU +// does matrix-assembly, it calls compress() inside and the others don't. +// We should implement this like in PETSc::MPI::Vector. + +#include "../tests.h" + +#include +#include +#include +#include +#include + +#include +//#include + + +void test() +{ + unsigned int myid = Utilities::System::get_this_mpi_process (MPI_COMM_WORLD); + unsigned int numprocs = Utilities::System::get_n_mpi_processes (MPI_COMM_WORLD); + + if (myid==0) + deallog << "Running on " << numprocs << " CPU(s)." << std::endl; + + CompressedSimpleSparsityPattern csp(2); + csp.add(0,0); + csp.add(1,1); + + PETScWrappers::MPI::SparseMatrix mat; + std::vector< unsigned int > local_rows(numprocs, 0); + local_rows[0]=2; + + mat.reinit(MPI_COMM_WORLD, csp, local_rows, local_rows, myid); + +#warning this here hangs, so it is uncommented until bug is fixed + //if (myid == 0 ) + mat.add(0, 0, 1.0); + + + mat.compress(); + + if (myid==0) + deallog << "done" << std::endl; +} + + +int main(int argc, char *argv[]) +{ + PetscInitialize(&argc,&argv,0,0); + + if (Utilities::System::get_this_mpi_process (MPI_COMM_WORLD) == 0) + { + std::ofstream logfile(output_file_for_mpi("petsc_02").c_str()); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + test(); + } + else + test(); + + PetscFinalize(); +} diff --git a/tests/mpi/petsc_02/ncpu_1/cmp/generic b/tests/mpi/petsc_02/ncpu_1/cmp/generic new file mode 100644 index 0000000000..76a3add384 --- /dev/null +++ b/tests/mpi/petsc_02/ncpu_1/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::Running on 1 CPU(s). +DEAL::2nd try +DEAL::done diff --git a/tests/mpi/petsc_02/ncpu_10/cmp/generic b/tests/mpi/petsc_02/ncpu_10/cmp/generic new file mode 100644 index 0000000000..729abc0fba --- /dev/null +++ b/tests/mpi/petsc_02/ncpu_10/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::Running on 10 CPU(s). +DEAL::2nd try +DEAL::done diff --git a/tests/mpi/petsc_02/ncpu_4/cmp/generic b/tests/mpi/petsc_02/ncpu_4/cmp/generic new file mode 100644 index 0000000000..25e315071a --- /dev/null +++ b/tests/mpi/petsc_02/ncpu_4/cmp/generic @@ -0,0 +1,4 @@ + +DEAL::Running on 4 CPU(s). +DEAL::2nd try +DEAL::done -- 2.39.5