From: Denis Davydov Date: Wed, 22 Nov 2017 22:46:35 +0000 (+0100) Subject: add a quick test X-Git-Tag: v9.0.0-rc1~701^2~5 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=349c02d3d65912f7b472749069f5c5592e9091f3;p=dealii.git add a quick test --- diff --git a/tests/quick_tests/CMakeLists.txt b/tests/quick_tests/CMakeLists.txt index f31178b9fb..45484c47be 100644 --- a/tests/quick_tests/CMakeLists.txt +++ b/tests/quick_tests/CMakeLists.txt @@ -173,6 +173,11 @@ IF (DEAL_II_WITH_CUDA) make_quicktest("cuda" ${_mybuild} "") ENDIF() +# Test ScaLAPACK +IF (DEAL_II_WITH_SCALAPACK) + make_quicktest("scalapack" ${_mybuild} 4) +ENDIF() + # A custom test target: ADD_CUSTOM_TARGET(test diff --git a/tests/quick_tests/scalapack.cc b/tests/quick_tests/scalapack.cc new file mode 100644 index 0000000000..6dd37089ce --- /dev/null +++ b/tests/quick_tests/scalapack.cc @@ -0,0 +1,93 @@ +// --------------------------------------------------------------------- +// +// 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" + +// adaptation of /scalapack/scalapack_02.cc to a quick test + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + + +template +void test(const unsigned int size, const unsigned int block_size) +{ + MPI_Comm mpi_communicator(MPI_COMM_WORLD); + const unsigned int n_mpi_processes(Utilities::MPI::n_mpi_processes(mpi_communicator)); + const unsigned int this_mpi_process(Utilities::MPI::this_mpi_process(mpi_communicator)); + + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + // Create SPD matrices of requested size: + FullMatrix full_in(size), inverse(size), full_out(size), diff(size); + + std::pair sizes = std::make_pair(size,size), block_sizes = std::make_pair(block_size,block_size); + std::shared_ptr grid = std::make_shared(mpi_communicator,sizes,block_sizes); + + ScaLAPACKMatrix scalapack_matrix (sizes.first, grid, block_sizes.first, + LAPACKSupport::Property::symmetric); + + pcout << size << " " << block_size << " " << grid->get_process_grid_rows() << " " << grid->get_process_grid_columns() << std::endl; + + create_spd (full_in); + + // invert via Lapack + inverse.cholesky(full_in); + + // invert via ScaLAPACK + scalapack_matrix = full_in; + scalapack_matrix.compute_cholesky_factorization(); + scalapack_matrix.copy_to(full_out); + + diff = 0; + diff.add( 1., inverse); + diff.add(-1., full_out); + + const double error = diff.frobenius_norm(); + + if (error > 1e-10 && this_mpi_process == 0) + { + std::cout << "Error!" << std::endl + << "expected to have:" << std::endl; + inverse.print_formatted (std::cout); + std::cout << "but got:" << std::endl; + full_out.print_formatted(std::cout); + std::cout << "difference:" << std::endl; + diff.print_formatted(std::cout); + AssertThrow (false, dealii::ExcInternalError()); + } + else + pcout << "Ok" << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + test(320,64); +}