From 51601c942d23d04417c618aa3e9f6423a8f3242f Mon Sep 17 00:00:00 2001 From: Benjamin Brands Date: Mon, 19 Feb 2018 08:45:04 +0100 Subject: [PATCH] Change scale rows/columns and split tests --- source/lac/scalapack.cc | 40 ++-- tests/scalapack/scalapack_12.cc | 218 ------------------ tests/scalapack/scalapack_12.mpirun=1.output | 15 -- tests/scalapack/scalapack_12.mpirun=11.output | 15 -- tests/scalapack/scalapack_12.mpirun=9.output | 15 -- tests/scalapack/scalapack_12_a.cc | 98 ++++++++ .../scalapack/scalapack_12_a.mpirun=1.output | 6 + .../scalapack/scalapack_12_a.mpirun=11.output | 6 + .../scalapack/scalapack_12_a.mpirun=9.output | 6 + tests/scalapack/scalapack_12_b.cc | 98 ++++++++ .../scalapack/scalapack_12_b.mpirun=1.output | 6 + .../scalapack/scalapack_12_b.mpirun=11.output | 6 + .../scalapack/scalapack_12_b.mpirun=9.output | 6 + tests/scalapack/scalapack_12_c.cc | 98 ++++++++ .../scalapack/scalapack_12_c.mpirun=1.output | 6 + .../scalapack/scalapack_12_c.mpirun=11.output | 6 + .../scalapack/scalapack_12_c.mpirun=9.output | 6 + tests/scalapack/scalapack_12_d.cc | 98 ++++++++ .../scalapack/scalapack_12_d.mpirun=1.output | 6 + .../scalapack/scalapack_12_d.mpirun=11.output | 6 + .../scalapack/scalapack_12_d.mpirun=9.output | 6 + tests/scalapack/scalapack_13.cc | 133 ----------- tests/scalapack/scalapack_13.mpirun=1.output | 81 ------- tests/scalapack/scalapack_13.mpirun=11.output | 81 ------- tests/scalapack/scalapack_13.mpirun=9.output | 81 ------- tests/scalapack/scalapack_13_a.cc | 96 ++++++++ .../scalapack/scalapack_13_a.mpirun=1.output | 54 +++++ .../scalapack/scalapack_13_a.mpirun=11.output | 54 +++++ .../scalapack/scalapack_13_a.mpirun=9.output | 54 +++++ tests/scalapack/scalapack_13_b.cc | 98 ++++++++ .../scalapack/scalapack_13_b.mpirun=1.output | 54 +++++ .../scalapack/scalapack_13_b.mpirun=11.output | 54 +++++ .../scalapack/scalapack_13_b.mpirun=9.output | 54 +++++ tests/scalapack/scalapack_14.mpirun=1.output | 81 ------- tests/scalapack/scalapack_14.mpirun=11.output | 81 ------- tests/scalapack/scalapack_14.mpirun=9.output | 81 ------- tests/scalapack/scalapack_14_a.cc | 91 ++++++++ .../scalapack/scalapack_14_a.mpirun=1.output | 54 +++++ .../scalapack/scalapack_14_a.mpirun=11.output | 54 +++++ .../scalapack/scalapack_14_a.mpirun=9.output | 54 +++++ .../{scalapack_14.cc => scalapack_14_b.cc} | 76 ++---- .../scalapack/scalapack_14_b.mpirun=1.output | 54 +++++ .../scalapack/scalapack_14_b.mpirun=11.output | 54 +++++ .../scalapack/scalapack_14_b.mpirun=9.output | 54 +++++ 44 files changed, 1439 insertions(+), 956 deletions(-) delete mode 100644 tests/scalapack/scalapack_12.cc delete mode 100644 tests/scalapack/scalapack_12.mpirun=1.output delete mode 100644 tests/scalapack/scalapack_12.mpirun=11.output delete mode 100644 tests/scalapack/scalapack_12.mpirun=9.output create mode 100644 tests/scalapack/scalapack_12_a.cc create mode 100644 tests/scalapack/scalapack_12_a.mpirun=1.output create mode 100644 tests/scalapack/scalapack_12_a.mpirun=11.output create mode 100644 tests/scalapack/scalapack_12_a.mpirun=9.output create mode 100644 tests/scalapack/scalapack_12_b.cc create mode 100644 tests/scalapack/scalapack_12_b.mpirun=1.output create mode 100644 tests/scalapack/scalapack_12_b.mpirun=11.output create mode 100644 tests/scalapack/scalapack_12_b.mpirun=9.output create mode 100644 tests/scalapack/scalapack_12_c.cc create mode 100644 tests/scalapack/scalapack_12_c.mpirun=1.output create mode 100644 tests/scalapack/scalapack_12_c.mpirun=11.output create mode 100644 tests/scalapack/scalapack_12_c.mpirun=9.output create mode 100644 tests/scalapack/scalapack_12_d.cc create mode 100644 tests/scalapack/scalapack_12_d.mpirun=1.output create mode 100644 tests/scalapack/scalapack_12_d.mpirun=11.output create mode 100644 tests/scalapack/scalapack_12_d.mpirun=9.output delete mode 100644 tests/scalapack/scalapack_13.cc delete mode 100644 tests/scalapack/scalapack_13.mpirun=1.output delete mode 100644 tests/scalapack/scalapack_13.mpirun=11.output delete mode 100644 tests/scalapack/scalapack_13.mpirun=9.output create mode 100644 tests/scalapack/scalapack_13_a.cc create mode 100644 tests/scalapack/scalapack_13_a.mpirun=1.output create mode 100644 tests/scalapack/scalapack_13_a.mpirun=11.output create mode 100644 tests/scalapack/scalapack_13_a.mpirun=9.output create mode 100644 tests/scalapack/scalapack_13_b.cc create mode 100644 tests/scalapack/scalapack_13_b.mpirun=1.output create mode 100644 tests/scalapack/scalapack_13_b.mpirun=11.output create mode 100644 tests/scalapack/scalapack_13_b.mpirun=9.output delete mode 100644 tests/scalapack/scalapack_14.mpirun=1.output delete mode 100644 tests/scalapack/scalapack_14.mpirun=11.output delete mode 100644 tests/scalapack/scalapack_14.mpirun=9.output create mode 100644 tests/scalapack/scalapack_14_a.cc create mode 100644 tests/scalapack/scalapack_14_a.mpirun=1.output create mode 100644 tests/scalapack/scalapack_14_a.mpirun=11.output create mode 100644 tests/scalapack/scalapack_14_a.mpirun=9.output rename tests/scalapack/{scalapack_14.cc => scalapack_14_b.cc} (52%) create mode 100644 tests/scalapack/scalapack_14_b.mpirun=1.output create mode 100644 tests/scalapack/scalapack_14_b.mpirun=11.output create mode 100644 tests/scalapack/scalapack_14_b.mpirun=9.output diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index 67e068e0cc..8790cedb2e 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -1513,36 +1513,32 @@ namespace internal template void scale_columns(ScaLAPACKMatrix &matrix, - const ArrayView &factors, - const bool grid_mpi_process_is_active) + const ArrayView &factors) { Assert(matrix.n()==factors.size(),ExcDimensionMismatch(matrix.n(),factors.size())); - if (grid_mpi_process_is_active) - for (unsigned int i=0; i void scale_rows(ScaLAPACKMatrix &matrix, - const ArrayView &factors, - const bool grid_mpi_process_is_active) + const ArrayView &factors) { Assert(matrix.m()==factors.size(),ExcDimensionMismatch(matrix.m(),factors.size())); - if (grid_mpi_process_is_active) - for (unsigned int i=0; i template void ScaLAPACKMatrix::scale_columns(const InputVector &factors) { - internal::scale_columns(*this, make_array_view(factors), - this->grid->mpi_process_is_active); + if (this->grid->mpi_process_is_active) + internal::scale_columns(*this, make_array_view(factors)); } @@ -1564,8 +1560,8 @@ template template void ScaLAPACKMatrix::scale_rows(const InputVector &factors) { - internal::scale_rows(*this, make_array_view(factors), - this->grid->mpi_process_is_active); + if (this->grid->mpi_process_is_active) + internal::scale_rows(*this, make_array_view(factors)); } diff --git a/tests/scalapack/scalapack_12.cc b/tests/scalapack/scalapack_12.cc deleted file mode 100644 index 2518e5efbb..0000000000 --- a/tests/scalapack/scalapack_12.cc +++ /dev/null @@ -1,218 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 2018 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 multiplication of distributed ScaLAPACKMatrices - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - - -template -void test() -{ - 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)); - - std::cout << std::setprecision(10); - ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); - - const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); - const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); - //create 2d process grid - std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); - pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; - - const std::vector sizes = {{300,400,500}}; - - // test C = b A*B + c C - { - FullMatrix full_A(sizes[0],sizes[2]); - FullMatrix full_B(sizes[2],sizes[1]); - FullMatrix full_C(sizes[0],sizes[1]); - create_random(full_A); - create_random(full_B); - create_random(full_C); - - // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B - const unsigned int mb_A=32, nb_A=64, nb_B=16; - const unsigned int mb_C=mb_A, mb_B=nb_A; - const unsigned int nb_C=nb_B; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); - scalapack_A = full_A; - scalapack_B = full_B; - scalapack_C = full_C; - - const NumberType b=1.4, c=0.1; - - full_A *= b; - full_C *= c; - full_A.mmult(full_C,full_B,true); - - scalapack_A.mult(b,scalapack_B,c,scalapack_C,false,false); - FullMatrix tmp_full_C(full_C.m(),full_C.n()); - scalapack_C.copy_to(tmp_full_C); - - pcout << " computing C = b A * B + c C with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" - << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " - << full_C.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - // test C = alpha A^T*B + beta C - { - FullMatrix full_A(sizes[2],sizes[0]); - FullMatrix full_B(sizes[2],sizes[1]); - FullMatrix full_C(sizes[0],sizes[1]); - create_random(full_A); - create_random(full_B); - create_random(full_C); - - // conditions for block sizes: nb_A=mb_C, nb_B=nb_C, mb_A=mb_B - const unsigned int mb_A=32, nb_A=64, nb_B=16; - const unsigned int mb_B=mb_A, mb_C=nb_A; - const unsigned int nb_C=nb_B; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); - scalapack_A = full_A; - scalapack_B = full_B; - scalapack_C = full_C; - - const NumberType b=1.4, c=0.1; - - full_A *= b; - full_C *= c; - full_A.Tmmult(full_C,full_B,true); - - scalapack_A.mult(b,scalapack_B,c,scalapack_C,true,false); - FullMatrix tmp_full_C(full_C.m(),full_C.n()); - scalapack_C.copy_to(tmp_full_C); - - pcout << " computing C = b A^T * B + c C with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" - << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " - << full_C.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - // test C = alpha A * B^T + beta C - { - FullMatrix full_A(sizes[0],sizes[2]); - FullMatrix full_B(sizes[1],sizes[2]); - FullMatrix full_C(sizes[0],sizes[1]); - create_random(full_A); - create_random(full_B); - create_random(full_C); - - // conditions for block sizes: mb_A=mb_C, mb_B=nb_C, nb_A=nb_B - const unsigned int mb_A=32, nb_A=64, mb_B=16; - const unsigned int nb_B=nb_A, mb_C=mb_A; - const unsigned int nb_C=mb_B; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); - scalapack_A = full_A; - scalapack_B = full_B; - scalapack_C = full_C; - - const NumberType b=1.4, c=0.1; - - full_A *= b; - full_C *= c; - full_A.mTmult(full_C,full_B,true); - - scalapack_A.mult(b,scalapack_B,c,scalapack_C,false,true); - FullMatrix tmp_full_C(full_C.m(),full_C.n()); - scalapack_C.copy_to(tmp_full_C); - - pcout << " computing C = b A * B^T + c C with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" - << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " - << full_C.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - // test C = alpha A^T * B^T + beta C - { - FullMatrix full_A(sizes[2],sizes[0]); - FullMatrix full_B(sizes[1],sizes[2]); - FullMatrix full_C(sizes[0],sizes[1]); - create_random(full_A); - create_random(full_B); - create_random(full_C); - - // conditions for block sizes: nb_A=mb_C, mb_B=nb_C, mb_A=nb_B - const unsigned int mb_A=32, nb_A=64, mb_B=16; - const unsigned int nb_B=mb_A, mb_C=nb_A; - const unsigned int nb_C=mb_B; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); - scalapack_A = full_A; - scalapack_B = full_B; - scalapack_C = full_C; - - const NumberType b=1.4, c=0.1; - - full_A *= b; - full_C *= c; - full_A.TmTmult(full_C,full_B,true); - - scalapack_A.mult(b,scalapack_B,c,scalapack_C,true,true); - FullMatrix tmp_full_C(full_C.m(),full_C.n()); - scalapack_C.copy_to(tmp_full_C); - - pcout << " computing C = b A^T * B^T + c C with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" - << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " - << full_C.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - pcout << std::endl; -} - - - -int main (int argc,char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); - - test(); -} diff --git a/tests/scalapack/scalapack_12.mpirun=1.output b/tests/scalapack/scalapack_12.mpirun=1.output deleted file mode 100644 index a90c724898..0000000000 --- a/tests/scalapack/scalapack_12.mpirun=1.output +++ /dev/null @@ -1,15 +0,0 @@ -2D process grid: 1x1 - - computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) - norms: 60787.8449 & 60787.8449 for d - - computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) - norms: 60655.07764 & 60655.07764 for d - - computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) - norms: 60707.53954 & 60707.53954 for d - - computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) - norms: 60757.09659 & 60757.09659 for d - - diff --git a/tests/scalapack/scalapack_12.mpirun=11.output b/tests/scalapack/scalapack_12.mpirun=11.output deleted file mode 100644 index d71715a175..0000000000 --- a/tests/scalapack/scalapack_12.mpirun=11.output +++ /dev/null @@ -1,15 +0,0 @@ -2D process grid: 3x3 - - computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) - norms: 60787.8449 & 60787.8449 for d - - computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) - norms: 60655.07764 & 60655.07764 for d - - computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) - norms: 60707.53954 & 60707.53954 for d - - computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) - norms: 60757.09659 & 60757.09659 for d - - diff --git a/tests/scalapack/scalapack_12.mpirun=9.output b/tests/scalapack/scalapack_12.mpirun=9.output deleted file mode 100644 index d71715a175..0000000000 --- a/tests/scalapack/scalapack_12.mpirun=9.output +++ /dev/null @@ -1,15 +0,0 @@ -2D process grid: 3x3 - - computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) - norms: 60787.8449 & 60787.8449 for d - - computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) - norms: 60655.07764 & 60655.07764 for d - - computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) - norms: 60707.53954 & 60707.53954 for d - - computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) - norms: 60757.09659 & 60757.09659 for d - - diff --git a/tests/scalapack/scalapack_12_a.cc b/tests/scalapack/scalapack_12_a.cc new file mode 100644 index 0000000000..b6794c021c --- /dev/null +++ b/tests/scalapack/scalapack_12_a.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 multiplication of distributed ScaLAPACKMatrices: C = b A*B + c C + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test() +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{300,400,500}}; + + FullMatrix full_A(sizes[0],sizes[2]); + FullMatrix full_B(sizes[2],sizes[1]); + FullMatrix full_C(sizes[0],sizes[1]); + create_random(full_A); + create_random(full_B); + create_random(full_C); + + // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B + const unsigned int mb_A=32, nb_A=64, nb_B=16; + const unsigned int mb_C=mb_A, mb_B=nb_A; + const unsigned int nb_C=nb_B; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); + scalapack_A = full_A; + scalapack_B = full_B; + scalapack_C = full_C; + + const NumberType b=1.4, c=0.1; + + full_A *= b; + full_C *= c; + full_A.mmult(full_C,full_B,true); + + scalapack_A.mult(b,scalapack_B,c,scalapack_C,false,false); + FullMatrix tmp_full_C(full_C.m(),full_C.n()); + scalapack_C.copy_to(tmp_full_C); + + pcout << " computing C = b A * B + c C with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" + << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " + << full_C.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + test(); +} diff --git a/tests/scalapack/scalapack_12_a.mpirun=1.output b/tests/scalapack/scalapack_12_a.mpirun=1.output new file mode 100644 index 0000000000..9b4f6d9199 --- /dev/null +++ b/tests/scalapack/scalapack_12_a.mpirun=1.output @@ -0,0 +1,6 @@ +2D process grid: 1x1 + + computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) + norms: 60787.8449 & 60787.8449 for d + + diff --git a/tests/scalapack/scalapack_12_a.mpirun=11.output b/tests/scalapack/scalapack_12_a.mpirun=11.output new file mode 100644 index 0000000000..348d3d7b7e --- /dev/null +++ b/tests/scalapack/scalapack_12_a.mpirun=11.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) + norms: 60787.8449 & 60787.8449 for d + + diff --git a/tests/scalapack/scalapack_12_a.mpirun=9.output b/tests/scalapack/scalapack_12_a.mpirun=9.output new file mode 100644 index 0000000000..348d3d7b7e --- /dev/null +++ b/tests/scalapack/scalapack_12_a.mpirun=9.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A * B + c C with A in R^(300x500), B in R^(500x400) and C in R^(300x400) + norms: 60787.8449 & 60787.8449 for d + + diff --git a/tests/scalapack/scalapack_12_b.cc b/tests/scalapack/scalapack_12_b.cc new file mode 100644 index 0000000000..3f8c7d1c32 --- /dev/null +++ b/tests/scalapack/scalapack_12_b.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 multiplication of distributed ScaLAPACKMatrices: C = alpha A^T*B + beta C + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test() +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{300,400,500}}; + + FullMatrix full_A(sizes[2],sizes[0]); + FullMatrix full_B(sizes[2],sizes[1]); + FullMatrix full_C(sizes[0],sizes[1]); + create_random(full_A); + create_random(full_B); + create_random(full_C); + + // conditions for block sizes: nb_A=mb_C, nb_B=nb_C, mb_A=mb_B + const unsigned int mb_A=32, nb_A=64, nb_B=16; + const unsigned int mb_B=mb_A, mb_C=nb_A; + const unsigned int nb_C=nb_B; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); + scalapack_A = full_A; + scalapack_B = full_B; + scalapack_C = full_C; + + const NumberType b=1.4, c=0.1; + + full_A *= b; + full_C *= c; + full_A.Tmmult(full_C,full_B,true); + + scalapack_A.mult(b,scalapack_B,c,scalapack_C,true,false); + FullMatrix tmp_full_C(full_C.m(),full_C.n()); + scalapack_C.copy_to(tmp_full_C); + + pcout << " computing C = b A^T * B + c C with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" + << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " + << full_C.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + test(); +} diff --git a/tests/scalapack/scalapack_12_b.mpirun=1.output b/tests/scalapack/scalapack_12_b.mpirun=1.output new file mode 100644 index 0000000000..2c4ee56ed1 --- /dev/null +++ b/tests/scalapack/scalapack_12_b.mpirun=1.output @@ -0,0 +1,6 @@ +2D process grid: 1x1 + + computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) + norms: 60784.47026 & 60784.47026 for d + + diff --git a/tests/scalapack/scalapack_12_b.mpirun=11.output b/tests/scalapack/scalapack_12_b.mpirun=11.output new file mode 100644 index 0000000000..1347a6ec96 --- /dev/null +++ b/tests/scalapack/scalapack_12_b.mpirun=11.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) + norms: 60784.47026 & 60784.47026 for d + + diff --git a/tests/scalapack/scalapack_12_b.mpirun=9.output b/tests/scalapack/scalapack_12_b.mpirun=9.output new file mode 100644 index 0000000000..1347a6ec96 --- /dev/null +++ b/tests/scalapack/scalapack_12_b.mpirun=9.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A^T * B + c C with A in R^(500x300), B in R^(500x400) and C in R^(300x400) + norms: 60784.47026 & 60784.47026 for d + + diff --git a/tests/scalapack/scalapack_12_c.cc b/tests/scalapack/scalapack_12_c.cc new file mode 100644 index 0000000000..eaa7bfb8a7 --- /dev/null +++ b/tests/scalapack/scalapack_12_c.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 multiplication of distributed ScaLAPACKMatrices: C = alpha A * B^T + beta C + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test() +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{300,400,500}}; + + FullMatrix full_A(sizes[0],sizes[2]); + FullMatrix full_B(sizes[1],sizes[2]); + FullMatrix full_C(sizes[0],sizes[1]); + create_random(full_A); + create_random(full_B); + create_random(full_C); + + // conditions for block sizes: mb_A=mb_C, mb_B=nb_C, nb_A=nb_B + const unsigned int mb_A=32, nb_A=64, mb_B=16; + const unsigned int nb_B=nb_A, mb_C=mb_A; + const unsigned int nb_C=mb_B; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); + scalapack_A = full_A; + scalapack_B = full_B; + scalapack_C = full_C; + + const NumberType b=1.4, c=0.1; + + full_A *= b; + full_C *= c; + full_A.mTmult(full_C,full_B,true); + + scalapack_A.mult(b,scalapack_B,c,scalapack_C,false,true); + FullMatrix tmp_full_C(full_C.m(),full_C.n()); + scalapack_C.copy_to(tmp_full_C); + + pcout << " computing C = b A * B^T + c C with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" + << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " + << full_C.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + test(); +} diff --git a/tests/scalapack/scalapack_12_c.mpirun=1.output b/tests/scalapack/scalapack_12_c.mpirun=1.output new file mode 100644 index 0000000000..1dc14d261e --- /dev/null +++ b/tests/scalapack/scalapack_12_c.mpirun=1.output @@ -0,0 +1,6 @@ +2D process grid: 1x1 + + computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) + norms: 60781.44758 & 60781.44758 for d + + diff --git a/tests/scalapack/scalapack_12_c.mpirun=11.output b/tests/scalapack/scalapack_12_c.mpirun=11.output new file mode 100644 index 0000000000..73e89b72c5 --- /dev/null +++ b/tests/scalapack/scalapack_12_c.mpirun=11.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) + norms: 60781.44758 & 60781.44758 for d + + diff --git a/tests/scalapack/scalapack_12_c.mpirun=9.output b/tests/scalapack/scalapack_12_c.mpirun=9.output new file mode 100644 index 0000000000..73e89b72c5 --- /dev/null +++ b/tests/scalapack/scalapack_12_c.mpirun=9.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A * B^T + c C with A in R^(300x500), B in R^(400x500) and C in R^(300x400) + norms: 60781.44758 & 60781.44758 for d + + diff --git a/tests/scalapack/scalapack_12_d.cc b/tests/scalapack/scalapack_12_d.cc new file mode 100644 index 0000000000..3c6d84dff8 --- /dev/null +++ b/tests/scalapack/scalapack_12_d.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 multiplication of distributed ScaLAPACKMatrices: C = alpha A^T * B^T + beta C + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test() +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{300,400,500}}; + + FullMatrix full_A(sizes[2],sizes[0]); + FullMatrix full_B(sizes[1],sizes[2]); + FullMatrix full_C(sizes[0],sizes[1]); + create_random(full_A); + create_random(full_B); + create_random(full_C); + + // conditions for block sizes: nb_A=mb_C, mb_B=nb_C, mb_A=nb_B + const unsigned int mb_A=32, nb_A=64, mb_B=16; + const unsigned int nb_B=mb_A, mb_C=nb_A; + const unsigned int nb_C=mb_B; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + ScaLAPACKMatrix scalapack_C (full_C.m(),full_C.n(),grid,mb_C,nb_C); + scalapack_A = full_A; + scalapack_B = full_B; + scalapack_C = full_C; + + const NumberType b=1.4, c=0.1; + + full_A *= b; + full_C *= c; + full_A.TmTmult(full_C,full_B,true); + + scalapack_A.mult(b,scalapack_B,c,scalapack_C,true,true); + FullMatrix tmp_full_C(full_C.m(),full_C.n()); + scalapack_C.copy_to(tmp_full_C); + + pcout << " computing C = b A^T * B^T + c C with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ")," + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ") and" + << " C in R^(" << scalapack_C.m() << "x" << scalapack_C.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_C.frobenius_norm()<< " & " + << full_C.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + test(); +} diff --git a/tests/scalapack/scalapack_12_d.mpirun=1.output b/tests/scalapack/scalapack_12_d.mpirun=1.output new file mode 100644 index 0000000000..b26591cf1c --- /dev/null +++ b/tests/scalapack/scalapack_12_d.mpirun=1.output @@ -0,0 +1,6 @@ +2D process grid: 1x1 + + computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) + norms: 60781.20992 & 60781.20992 for d + + diff --git a/tests/scalapack/scalapack_12_d.mpirun=11.output b/tests/scalapack/scalapack_12_d.mpirun=11.output new file mode 100644 index 0000000000..bcb275857b --- /dev/null +++ b/tests/scalapack/scalapack_12_d.mpirun=11.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) + norms: 60781.20992 & 60781.20992 for d + + diff --git a/tests/scalapack/scalapack_12_d.mpirun=9.output b/tests/scalapack/scalapack_12_d.mpirun=9.output new file mode 100644 index 0000000000..bcb275857b --- /dev/null +++ b/tests/scalapack/scalapack_12_d.mpirun=9.output @@ -0,0 +1,6 @@ +2D process grid: 3x3 + + computing C = b A^T * B^T + c C with A in R^(500x300), B in R^(400x500) and C in R^(300x400) + norms: 60781.20992 & 60781.20992 for d + + diff --git a/tests/scalapack/scalapack_13.cc b/tests/scalapack/scalapack_13.cc deleted file mode 100644 index b9c720d1ed..0000000000 --- a/tests/scalapack/scalapack_13.cc +++ /dev/null @@ -1,133 +0,0 @@ -// --------------------------------------------------------------------- -// -// Copyright (C) 2017 - 2018 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 addition of distributed ScaLAPACKMatrices - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - - -template -void test(const unsigned int block_size_i, const unsigned int block_size_j) -{ - 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)); - - std::cout << std::setprecision(10); - ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); - - const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); - const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); - //create 2d process grid - std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); - pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; - - const std::vector sizes = {{400,500}}; - - // test A = alpha A + beta B - { - FullMatrix full_A(sizes[0],sizes[1]); - FullMatrix full_B(sizes[0],sizes[1]); - create_random(full_A); - create_random(full_B); - - // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B - const unsigned int mb_A=block_size_i, nb_A=block_size_j; - const unsigned int mb_B=mb_A, nb_B=nb_A; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - scalapack_A = full_A; - scalapack_B = full_B; - - const NumberType alpha = 1.2, beta = -0.7; - - full_A *= alpha; - full_A.add(beta,full_B); - - scalapack_A.add(scalapack_B,alpha,beta,false); - FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); - scalapack_A.copy_to(tmp_full_A); - - pcout << " computing A = alpha A + beta B with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ") and" - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_A.frobenius_norm()<< " & " - << full_A.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - // test A = alpha A + beta B^T - { - FullMatrix full_A(sizes[0],sizes[1]); - FullMatrix full_B(sizes[1],sizes[0]); - create_random(full_A); - create_random(full_B); - - // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B - const unsigned int mb_A=block_size_i, nb_A=block_size_j; - const unsigned int mb_B=nb_A, nb_B=mb_A; - - ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); - ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); - scalapack_A = full_A; - scalapack_B = full_B; - - const NumberType alpha = 1.2, beta = -0.7; - - full_A *= alpha; - FullMatrix full_B_t(sizes[0],sizes[1]); - full_B_t.copy_transposed(full_B); - full_A.add(beta,full_B_t); - - scalapack_A.add(scalapack_B,alpha,beta,true); - FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); - scalapack_A.copy_to(tmp_full_A); - - pcout << " computing A = alpha A + beta B^T with" - << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ") and" - << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ")" << std::endl; - pcout << " norms: " << tmp_full_A.frobenius_norm()<< " & " - << full_A.frobenius_norm() << " for " - << typeid(NumberType).name() << std::endl << std::endl; - } - pcout << std::endl; -} - - - -int main (int argc,char **argv) -{ - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); - - const std::vector blocks_i = {{16,32,64}}; - const std::vector blocks_j = {{16,32,64}}; - - for (const auto &s : blocks_i) - for (const auto &b : blocks_j) - test(s,b); -} diff --git a/tests/scalapack/scalapack_13.mpirun=1.output b/tests/scalapack/scalapack_13.mpirun=1.output deleted file mode 100644 index 45ce75f0bd..0000000000 --- a/tests/scalapack/scalapack_13.mpirun=1.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 210.8890477 & 210.8890477 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3218642 & 211.3218642 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.0415011 & 211.0415011 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.963856 & 210.963856 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1814485 & 211.1814485 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.4254302 & 211.4254302 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1982034 & 211.1982034 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.7211238 & 211.7211238 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.7341662 & 211.7341662 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.390201 & 211.390201 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 212.0358711 & 212.0358711 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.7492073 & 210.7492073 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3884882 & 211.3884882 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.2484978 & 211.2484978 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.5479046 & 211.5479046 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.5775407 & 211.5775407 for d - - -2D process grid: 1x1 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3749142 & 211.3749142 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3602887 & 211.3602887 for d - - diff --git a/tests/scalapack/scalapack_13.mpirun=11.output b/tests/scalapack/scalapack_13.mpirun=11.output deleted file mode 100644 index a6bcb1a857..0000000000 --- a/tests/scalapack/scalapack_13.mpirun=11.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 210.8890477 & 210.8890477 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3218642 & 211.3218642 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.0415011 & 211.0415011 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.963856 & 210.963856 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1814485 & 211.1814485 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.4254302 & 211.4254302 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1982034 & 211.1982034 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.7211238 & 211.7211238 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.7341662 & 211.7341662 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.390201 & 211.390201 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 212.0358711 & 212.0358711 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.7492073 & 210.7492073 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3884882 & 211.3884882 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.2484978 & 211.2484978 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.5479046 & 211.5479046 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.5775407 & 211.5775407 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3749142 & 211.3749142 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3602887 & 211.3602887 for d - - diff --git a/tests/scalapack/scalapack_13.mpirun=9.output b/tests/scalapack/scalapack_13.mpirun=9.output deleted file mode 100644 index a6bcb1a857..0000000000 --- a/tests/scalapack/scalapack_13.mpirun=9.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 210.8890477 & 210.8890477 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3218642 & 211.3218642 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.0415011 & 211.0415011 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.963856 & 210.963856 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1814485 & 211.1814485 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.4254302 & 211.4254302 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.1982034 & 211.1982034 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.7211238 & 211.7211238 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.7341662 & 211.7341662 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.390201 & 211.390201 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 212.0358711 & 212.0358711 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 210.7492073 & 210.7492073 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3884882 & 211.3884882 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.2484978 & 211.2484978 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.5479046 & 211.5479046 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.5775407 & 211.5775407 for d - - -2D process grid: 3x3 - - computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) - norms: 211.3749142 & 211.3749142 for d - - computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) - norms: 211.3602887 & 211.3602887 for d - - diff --git a/tests/scalapack/scalapack_13_a.cc b/tests/scalapack/scalapack_13_a.cc new file mode 100644 index 0000000000..635a988073 --- /dev/null +++ b/tests/scalapack/scalapack_13_a.cc @@ -0,0 +1,96 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 addition of distributed ScaLAPACKMatrices: A = alpha A + beta B + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test(const unsigned int block_size_i, const unsigned int block_size_j) +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{400,500}}; + + FullMatrix full_A(sizes[0],sizes[1]); + FullMatrix full_B(sizes[0],sizes[1]); + create_random(full_A); + create_random(full_B); + + // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B + const unsigned int mb_A=block_size_i, nb_A=block_size_j; + const unsigned int mb_B=mb_A, nb_B=nb_A; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + scalapack_A = full_A; + scalapack_B = full_B; + + const NumberType alpha = 1.2, beta = -0.7; + + full_A *= alpha; + full_A.add(beta,full_B); + + scalapack_A.add(scalapack_B,alpha,beta,false); + FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); + scalapack_A.copy_to(tmp_full_A); + + pcout << " computing A = alpha A + beta B with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ") and" + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_A.frobenius_norm()<< " & " + << full_A.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + const std::vector blocks_i = {{16,32,64}}; + const std::vector blocks_j = {{16,32,64}}; + + for (const auto &s : blocks_i) + for (const auto &b : blocks_j) + test(s,b); +} diff --git a/tests/scalapack/scalapack_13_a.mpirun=1.output b/tests/scalapack/scalapack_13_a.mpirun=1.output new file mode 100644 index 0000000000..ef0d0f47d0 --- /dev/null +++ b/tests/scalapack/scalapack_13_a.mpirun=1.output @@ -0,0 +1,54 @@ +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 210.8890477 & 210.8890477 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.279256 & 211.279256 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.0415011 & 211.0415011 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1717475 & 211.1717475 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1814485 & 211.1814485 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.548357 & 211.548357 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1982034 & 211.1982034 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7897812 & 211.7897812 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7341662 & 211.7341662 for d + + diff --git a/tests/scalapack/scalapack_13_a.mpirun=11.output b/tests/scalapack/scalapack_13_a.mpirun=11.output new file mode 100644 index 0000000000..bdb940dfb0 --- /dev/null +++ b/tests/scalapack/scalapack_13_a.mpirun=11.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 210.8890477 & 210.8890477 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.279256 & 211.279256 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.0415011 & 211.0415011 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1717475 & 211.1717475 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1814485 & 211.1814485 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.548357 & 211.548357 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1982034 & 211.1982034 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7897812 & 211.7897812 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7341662 & 211.7341662 for d + + diff --git a/tests/scalapack/scalapack_13_a.mpirun=9.output b/tests/scalapack/scalapack_13_a.mpirun=9.output new file mode 100644 index 0000000000..bdb940dfb0 --- /dev/null +++ b/tests/scalapack/scalapack_13_a.mpirun=9.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 210.8890477 & 210.8890477 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.279256 & 211.279256 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.0415011 & 211.0415011 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1717475 & 211.1717475 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1814485 & 211.1814485 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.548357 & 211.548357 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.1982034 & 211.1982034 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7897812 & 211.7897812 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B with A in R^(400x500) and B in R^(400x500) + norms: 211.7341662 & 211.7341662 for d + + diff --git a/tests/scalapack/scalapack_13_b.cc b/tests/scalapack/scalapack_13_b.cc new file mode 100644 index 0000000000..df8697c9e5 --- /dev/null +++ b/tests/scalapack/scalapack_13_b.cc @@ -0,0 +1,98 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 addition of distributed ScaLAPACKMatrices: A = alpha A + beta B^T + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test(const unsigned int block_size_i, const unsigned int block_size_j) +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + std::shared_ptr grid = std::make_shared(mpi_communicator,proc_rows,proc_columns); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + const std::vector sizes = {{400,500}}; + + FullMatrix full_A(sizes[0],sizes[1]); + FullMatrix full_B(sizes[1],sizes[0]); + create_random(full_A); + create_random(full_B); + + // conditions for block sizes: mb_A=mb_C, nb_B=nb_C, nb_A=mb_B + const unsigned int mb_A=block_size_i, nb_A=block_size_j; + const unsigned int mb_B=nb_A, nb_B=mb_A; + + ScaLAPACKMatrix scalapack_A (full_A.m(),full_A.n(),grid,mb_A,nb_A); + ScaLAPACKMatrix scalapack_B (full_B.m(),full_B.n(),grid,mb_B,nb_B); + scalapack_A = full_A; + scalapack_B = full_B; + + const NumberType alpha = 1.2, beta = -0.7; + + full_A *= alpha; + FullMatrix full_B_t(sizes[0],sizes[1]); + full_B_t.copy_transposed(full_B); + full_A.add(beta,full_B_t); + + scalapack_A.add(scalapack_B,alpha,beta,true); + FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); + scalapack_A.copy_to(tmp_full_A); + + pcout << " computing A = alpha A + beta B^T with" + << " A in R^(" << scalapack_A.m() << "x" << scalapack_A.n() << ") and" + << " B in R^(" << scalapack_B.m() << "x" << scalapack_B.n() << ")" << std::endl; + pcout << " norms: " << tmp_full_A.frobenius_norm()<< " & " + << full_A.frobenius_norm() << " for " + << typeid(NumberType).name() << std::endl << std::endl; + pcout << std::endl; +} + + + +int main (int argc,char **argv) +{ + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); + + const std::vector blocks_i = {{16,32,64}}; + const std::vector blocks_j = {{16,32,64}}; + + for (const auto &s : blocks_i) + for (const auto &b : blocks_j) + test(s,b); +} diff --git a/tests/scalapack/scalapack_13_b.mpirun=1.output b/tests/scalapack/scalapack_13_b.mpirun=1.output new file mode 100644 index 0000000000..4f417ea3e6 --- /dev/null +++ b/tests/scalapack/scalapack_13_b.mpirun=1.output @@ -0,0 +1,54 @@ +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.163862 & 211.163862 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.3218642 & 211.3218642 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.184002 & 211.184002 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 210.963856 & 210.963856 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.5403408 & 211.5403408 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.4254302 & 211.4254302 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.278436 & 211.278436 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7211238 & 211.7211238 for d + + +2D process grid: 1x1 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7476249 & 211.7476249 for d + + diff --git a/tests/scalapack/scalapack_13_b.mpirun=11.output b/tests/scalapack/scalapack_13_b.mpirun=11.output new file mode 100644 index 0000000000..740104d8fc --- /dev/null +++ b/tests/scalapack/scalapack_13_b.mpirun=11.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.163862 & 211.163862 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.3218642 & 211.3218642 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.184002 & 211.184002 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 210.963856 & 210.963856 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.5403408 & 211.5403408 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.4254302 & 211.4254302 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.278436 & 211.278436 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7211238 & 211.7211238 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7476249 & 211.7476249 for d + + diff --git a/tests/scalapack/scalapack_13_b.mpirun=9.output b/tests/scalapack/scalapack_13_b.mpirun=9.output new file mode 100644 index 0000000000..740104d8fc --- /dev/null +++ b/tests/scalapack/scalapack_13_b.mpirun=9.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.163862 & 211.163862 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.3218642 & 211.3218642 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.184002 & 211.184002 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 210.963856 & 210.963856 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.5403408 & 211.5403408 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.4254302 & 211.4254302 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.278436 & 211.278436 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7211238 & 211.7211238 for d + + +2D process grid: 3x3 + + computing A = alpha A + beta B^T with A in R^(400x500) and B in R^(500x400) + norms: 211.7476249 & 211.7476249 for d + + diff --git a/tests/scalapack/scalapack_14.mpirun=1.output b/tests/scalapack/scalapack_14.mpirun=1.output deleted file mode 100644 index 4dfac23a67..0000000000 --- a/tests/scalapack/scalapack_14.mpirun=1.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3654.285795 & 3654.285795 for d - - Column scaling for A in R^(400x500) - norms: 4090.694598 & 4090.694598 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3654.738726 & 3654.738726 for d - - Column scaling for A in R^(400x500) - norms: 4085.273405 & 4085.273405 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3660.42714 & 3660.42714 for d - - Column scaling for A in R^(400x500) - norms: 4082.735765 & 4082.735765 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3654.388891 & 3654.388891 for d - - Column scaling for A in R^(400x500) - norms: 4084.61645 & 4084.61645 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3655.261484 & 3655.261484 for d - - Column scaling for A in R^(400x500) - norms: 4084.19574 & 4084.19574 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3655.547554 & 3655.547554 for d - - Column scaling for A in R^(400x500) - norms: 4088.843423 & 4088.843423 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3654.096322 & 3654.096322 for d - - Column scaling for A in R^(400x500) - norms: 4083.807486 & 4083.807486 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3662.0357 & 3662.0357 for d - - Column scaling for A in R^(400x500) - norms: 4089.328538 & 4089.328538 for d - - -2D process grid: 1x1 - - Row scaling for A in R^(400x500) - norms: 3663.288472 & 3663.288472 for d - - Column scaling for A in R^(400x500) - norms: 4081.172517 & 4081.172517 for d - - diff --git a/tests/scalapack/scalapack_14.mpirun=11.output b/tests/scalapack/scalapack_14.mpirun=11.output deleted file mode 100644 index 58e9b076e7..0000000000 --- a/tests/scalapack/scalapack_14.mpirun=11.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.285795 & 3654.285795 for d - - Column scaling for A in R^(400x500) - norms: 4090.694598 & 4090.694598 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.738726 & 3654.738726 for d - - Column scaling for A in R^(400x500) - norms: 4085.273405 & 4085.273405 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3660.42714 & 3660.42714 for d - - Column scaling for A in R^(400x500) - norms: 4082.735765 & 4082.735765 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.388891 & 3654.388891 for d - - Column scaling for A in R^(400x500) - norms: 4084.61645 & 4084.61645 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3655.261484 & 3655.261484 for d - - Column scaling for A in R^(400x500) - norms: 4084.19574 & 4084.19574 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3655.547554 & 3655.547554 for d - - Column scaling for A in R^(400x500) - norms: 4088.843423 & 4088.843423 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.096322 & 3654.096322 for d - - Column scaling for A in R^(400x500) - norms: 4083.807486 & 4083.807486 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3662.0357 & 3662.0357 for d - - Column scaling for A in R^(400x500) - norms: 4089.328538 & 4089.328538 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3663.288472 & 3663.288472 for d - - Column scaling for A in R^(400x500) - norms: 4081.172517 & 4081.172517 for d - - diff --git a/tests/scalapack/scalapack_14.mpirun=9.output b/tests/scalapack/scalapack_14.mpirun=9.output deleted file mode 100644 index 58e9b076e7..0000000000 --- a/tests/scalapack/scalapack_14.mpirun=9.output +++ /dev/null @@ -1,81 +0,0 @@ -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.285795 & 3654.285795 for d - - Column scaling for A in R^(400x500) - norms: 4090.694598 & 4090.694598 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.738726 & 3654.738726 for d - - Column scaling for A in R^(400x500) - norms: 4085.273405 & 4085.273405 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3660.42714 & 3660.42714 for d - - Column scaling for A in R^(400x500) - norms: 4082.735765 & 4082.735765 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.388891 & 3654.388891 for d - - Column scaling for A in R^(400x500) - norms: 4084.61645 & 4084.61645 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3655.261484 & 3655.261484 for d - - Column scaling for A in R^(400x500) - norms: 4084.19574 & 4084.19574 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3655.547554 & 3655.547554 for d - - Column scaling for A in R^(400x500) - norms: 4088.843423 & 4088.843423 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3654.096322 & 3654.096322 for d - - Column scaling for A in R^(400x500) - norms: 4083.807486 & 4083.807486 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3662.0357 & 3662.0357 for d - - Column scaling for A in R^(400x500) - norms: 4089.328538 & 4089.328538 for d - - -2D process grid: 3x3 - - Row scaling for A in R^(400x500) - norms: 3663.288472 & 3663.288472 for d - - Column scaling for A in R^(400x500) - norms: 4081.172517 & 4081.172517 for d - - diff --git a/tests/scalapack/scalapack_14_a.cc b/tests/scalapack/scalapack_14_a.cc new file mode 100644 index 0000000000..1705e470c4 --- /dev/null +++ b/tests/scalapack/scalapack_14_a.cc @@ -0,0 +1,91 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2017 - 2018 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 scaling of rows of distributed ScaLAPACKMatrices + +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + + +template +void test(const unsigned int block_size_i, const unsigned int block_size_j) +{ + 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)); + + std::cout << std::setprecision(10); + ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + + const unsigned int proc_rows = std::floor(std::sqrt(n_mpi_processes)); + const unsigned int proc_columns = std::floor(n_mpi_processes/proc_rows); + //create 2d process grid + const std::vector sizes = {{400,500}}; + std::shared_ptr grid = std::make_shared(mpi_communicator,sizes[0],sizes[1],block_size_i,block_size_i); + pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; + + // test scaling of rows + FullMatrix full_A(sizes[0],sizes[1]); + create_random(full_A); + + std::vector scaling_factors(full_A.m()); + for (unsigned int i=0; i scalapack_A (full_A.m(),full_A.n(),grid,block_size_i,block_size_j); + scalapack_A = full_A; + const ArrayView view_rows(scaling_factors); + scalapack_A.scale_rows(view_rows); + FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); + scalapack_A.copy_to(tmp_full_A); + + for (unsigned int i=0; i blocks_i = {{16,32,64}}; + const std::vector blocks_j = {{16,32,64}}; + + for (const auto &s : blocks_i) + for (const auto &b : blocks_j) + test(s,b); +} diff --git a/tests/scalapack/scalapack_14_a.mpirun=1.output b/tests/scalapack/scalapack_14_a.mpirun=1.output new file mode 100644 index 0000000000..2e72aa888f --- /dev/null +++ b/tests/scalapack/scalapack_14_a.mpirun=1.output @@ -0,0 +1,54 @@ +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3654.285795 & 3654.285795 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3660.063508 & 3660.063508 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3654.738726 & 3654.738726 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3654.280104 & 3654.280104 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3660.42714 & 3660.42714 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3651.8011 & 3651.8011 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3654.388891 & 3654.388891 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3655.950825 & 3655.950825 for d + + +2D process grid: 1x1 + + Row scaling for A in R^(400x500) + norms: 3655.261484 & 3655.261484 for d + + diff --git a/tests/scalapack/scalapack_14_a.mpirun=11.output b/tests/scalapack/scalapack_14_a.mpirun=11.output new file mode 100644 index 0000000000..1ad7986de4 --- /dev/null +++ b/tests/scalapack/scalapack_14_a.mpirun=11.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.285795 & 3654.285795 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3660.063508 & 3660.063508 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.738726 & 3654.738726 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.280104 & 3654.280104 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3660.42714 & 3660.42714 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3651.8011 & 3651.8011 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.388891 & 3654.388891 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3655.950825 & 3655.950825 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3655.261484 & 3655.261484 for d + + diff --git a/tests/scalapack/scalapack_14_a.mpirun=9.output b/tests/scalapack/scalapack_14_a.mpirun=9.output new file mode 100644 index 0000000000..1ad7986de4 --- /dev/null +++ b/tests/scalapack/scalapack_14_a.mpirun=9.output @@ -0,0 +1,54 @@ +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.285795 & 3654.285795 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3660.063508 & 3660.063508 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.738726 & 3654.738726 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.280104 & 3654.280104 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3660.42714 & 3660.42714 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3651.8011 & 3651.8011 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3654.388891 & 3654.388891 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3655.950825 & 3655.950825 for d + + +2D process grid: 3x3 + + Row scaling for A in R^(400x500) + norms: 3655.261484 & 3655.261484 for d + + diff --git a/tests/scalapack/scalapack_14.cc b/tests/scalapack/scalapack_14_b.cc similarity index 52% rename from tests/scalapack/scalapack_14.cc rename to tests/scalapack/scalapack_14_b.cc index d5501b2986..4132a1df6a 100644 --- a/tests/scalapack/scalapack_14.cc +++ b/tests/scalapack/scalapack_14_b.cc @@ -16,7 +16,7 @@ #include "../tests.h" #include "../lapack/create_matrix.h" -// test scaling of rows and columns of distributed ScaLAPACKMatrices +// test scaling of columns of distributed ScaLAPACKMatrices #include #include @@ -49,58 +49,30 @@ void test(const unsigned int block_size_i, const unsigned int block_size_j) std::shared_ptr grid = std::make_shared(mpi_communicator,sizes[0],sizes[1],block_size_i,block_size_i); pcout << "2D process grid: " << grid->get_process_grid_rows() << "x" << grid->get_process_grid_columns() << std::endl << std::endl; - // test scaling of rows - { - FullMatrix full_A(sizes[0],sizes[1]); - create_random(full_A); - - std::vector scaling_factors(full_A.m()); - for (unsigned int i=0; i scalapack_A (full_A.m(),full_A.n(),grid,block_size_i,block_size_j); - scalapack_A = full_A; - const ArrayView view_rows(scaling_factors); - scalapack_A.scale_rows(view_rows); - FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); - scalapack_A.copy_to(tmp_full_A); - - for (unsigned int i=0; i full_A(sizes[0],sizes[1]); - create_random(full_A); - - std::vector scaling_factors(full_A.n()); - for (unsigned int i=0; i scalapack_A (full_A.m(),full_A.n(),grid,block_size_i,block_size_j); - scalapack_A = full_A; - const ArrayView view_columns(scaling_factors); - scalapack_A.scale_columns(view_columns); - FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); - scalapack_A.copy_to(tmp_full_A); - - for (unsigned int i=0; i full_A(sizes[0],sizes[1]); + create_random(full_A); + + std::vector scaling_factors(full_A.n()); + for (unsigned int i=0; i scalapack_A (full_A.m(),full_A.n(),grid,block_size_i,block_size_j); + scalapack_A = full_A; + const ArrayView view_columns(scaling_factors); + scalapack_A.scale_columns(view_columns); + FullMatrix tmp_full_A(scalapack_A.m(),scalapack_A.n()); + scalapack_A.copy_to(tmp_full_A); + + for (unsigned int i=0; i