From: Benjamin Brands Date: Tue, 23 Jan 2018 09:14:57 +0000 (+0100) Subject: add tests for save/load of ScaLapackMatrix X-Git-Tag: v9.0.0-rc1~483^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1458f1b7c1f012a0e8320e8135bf2f3bc23fd914;p=dealii.git add tests for save/load of ScaLapackMatrix --- diff --git a/tests/scalapack/scalapack_10.cc b/tests/scalapack/scalapack_10.cc new file mode 100644 index 0000000000..664b82ab01 --- /dev/null +++ b/tests/scalapack/scalapack_10.cc @@ -0,0 +1,85 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 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. +// +// --------------------------------------------------------------------- + +#include "../tests.h" +#include "../lapack/create_matrix.h" + +// test serial saving and loading of distributed ScaLAPACKMatrices + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test(const unsigned int size, const unsigned int block_size) +{ + const std::string filename = std::string(SOURCE_DIR) + "/test.h5"; + + MPI_Comm mpi_communicator(MPI_COMM_WORLD); + const unsigned int this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator)); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + //create FullMatrix and fill it + FullMatrix full(size); + unsigned int count=0; + for (unsigned int i=0; i grid = std::make_shared(mpi_communicator,size,size,block_size,block_size); + + ScaLAPACKMatrix scalapack_matrix(size,size,grid,block_size,block_size); + ScaLAPACKMatrix scalapack_matrix_copy(size,size,grid,block_size,block_size); + + scalapack_matrix = full; + scalapack_matrix.save(filename.c_str()); + scalapack_matrix_copy.load(filename.c_str()); + + FullMatrix copy(size); + scalapack_matrix_copy.copy_to(copy); + copy.add(-1,full); + + pcout << size << " " << block_size << std::endl; + AssertThrow(copy.frobenius_norm()<1e-12,ExcInternalError()); + std::remove(filename.c_str()); +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + const std::vector sizes = {{100,200,300}}; + const std::vector block_sizes = {{1,16,32}}; + + for (const auto &s : sizes) + for (const auto &b : block_sizes) + test(s,b); + + for (const auto &s : sizes) + for (const auto &b : block_sizes) + test(s,b); +} diff --git a/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=1.output b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=1.output new file mode 100644 index 0000000000..3a87dd3031 --- /dev/null +++ b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=1.output @@ -0,0 +1,18 @@ +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 diff --git a/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=11.output b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=11.output new file mode 100644 index 0000000000..3a87dd3031 --- /dev/null +++ b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=11.output @@ -0,0 +1,18 @@ +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 diff --git a/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=4.output b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=4.output new file mode 100644 index 0000000000..3a87dd3031 --- /dev/null +++ b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=4.output @@ -0,0 +1,18 @@ +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 diff --git a/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=5.output b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=5.output new file mode 100644 index 0000000000..3a87dd3031 --- /dev/null +++ b/tests/scalapack/scalapack_10.with_hdf5=on.mpirun=5.output @@ -0,0 +1,18 @@ +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32 +100 1 +100 16 +100 32 +200 1 +200 16 +200 32 +300 1 +300 16 +300 32