From: Benjamin Brands Date: Mon, 15 Jan 2018 16:52:35 +0000 (+0100) Subject: added SVD computation and tests X-Git-Tag: v9.0.0-rc1~545^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c695f27d53e6dd531841c58eed07ee008bfd445a;p=dealii.git added SVD computation and tests --- diff --git a/include/deal.II/lac/scalapack.h b/include/deal.II/lac/scalapack.h index b09450a0bd..c58936b101 100644 --- a/include/deal.II/lac/scalapack.h +++ b/include/deal.II/lac/scalapack.h @@ -197,6 +197,30 @@ public: const std::pair &index_limits = std::make_pair(-1,-1), const std::pair &value_limits = std::make_pair(-1,-1)); + + + /** + * Funcion to compute the singular value decomposition (SVD) of an + * M-by-N matrix A, optionally computing the left and/or right + * singular vectors. The SVD is written as A = U * SIGMA * transpose(V) + * where SIGMA is an M-by-N diagonal matrix, @p U is an M-by-M orthogonal matrix, + * and @p V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA + * are the singular values of A and the columns of U and V are the + * corresponding left and right singular vectors, respectively. The + * singular values are returned in decreasing order and only the first min(M,N) + * columns of U and rows of VT = transpose(V) are computed. + * Upon return the content of the matrix is unusable. + * The matrix A must have identical block cyclic distribution for the rows and column + * If left singular vectors are required matrices A and U + * have to be constructed with the same process grid and block cyclic distribution. + * If right singular vectors are required matrices A and VT + * have to be constructed with the same process grid and block cyclic distribution. + */ + std::vector compute_SVD(ScaLAPACKMatrix &U, + ScaLAPACKMatrix &VT, + const bool left_singluar_vectors=false, + const bool right_singluar_vectors=false); + /** * Estimate the the condition number of a SPD matrix in the $l_1$-norm. * The matrix has to be in the Cholesky state (see compute_cholesky_factorization()). diff --git a/include/deal.II/lac/scalapack.templates.h b/include/deal.II/lac/scalapack.templates.h index 50258d7488..9ba8796d8c 100644 --- a/include/deal.II/lac/scalapack.templates.h +++ b/include/deal.II/lac/scalapack.templates.h @@ -600,8 +600,57 @@ extern "C" int *iclustr, float *gap, int *info); + + /* + * PDGESVD computes the singular value decomposition (SVD) of an + * M-by-N matrix A, optionally computing the left and/or right + * singular vectors + */ + //FIXME + void pdgesvd_(const char *jobu, + const char *jobvt, + const int *m, + const int *n, + double *A, + const int *ia, + const int *ja, + const int *desca, + double *S, + double *U, + const int *iu, + const int *ju, + const int *descu, + double *VT, + const int *ivt, + const int *jvt, + const int *descvt, + double *work, + int *lwork, + int *info); + void psgesvd_(const char *jobu, + const char *jobvt, + const int *m, + const int *n, + float *A, + const int *ia, + const int *ja, + const int *desca, + float *S, + float *U, + const int *iu, + const int *ju, + const int *descu, + float *VT, + const int *ivt, + const int *jvt, + const int *descvt, + float *work, + int *lwork, + int *info); } + + /* * In the following we have template wrappers for the ScaLAPACK routines * wrappers for other numeric types can be added in the future @@ -1272,6 +1321,79 @@ inline void psyevx(const char *jobz, } +template +inline void pgesvd(const char *jobu, + const char *jobvt, + const int *m, + const int *n, + number *A, + const int *ia, + const int *ja, + const int *desca, + number *S, + number *U, + const int *iu, + const int *ju, + const int *descu, + number *VT, + const int *ivt, + const int *jvt, + const int *descvt, + number *work, + int *lwork, + int *info) +{ + Assert (false, dealii::ExcNotImplemented()); +} + +inline void pgesvd(const char *jobu, + const char *jobvt, + const int *m, + const int *n, + double *A, + const int *ia, + const int *ja, + const int *desca, + double *S, + double *U, + const int *iu, + const int *ju, + const int *descu, + double *VT, + const int *ivt, + const int *jvt, + const int *descvt, + double *work, + int *lwork, + int *info) +{ + pdgesvd_(jobu,jobvt,m,n,A,ia,ja,desca,S,U,iu,ju,descu,VT,ivt,jvt,descvt,work,lwork,info); +} + +inline void pgesvd(const char *jobu, + const char *jobvt, + const int *m, + const int *n, + float *A, + const int *ia, + const int *ja, + const int *desca, + float *S, + float *U, + const int *iu, + const int *ju, + const int *descu, + float *VT, + const int *ivt, + const int *jvt, + const int *descvt, + float *work, + int *lwork, + int *info) +{ + psgesvd_(jobu,jobvt,m,n,A,ia,ja,desca,S,U,iu,ju,descu,VT,ivt,jvt,descvt,work,lwork,info); +} + #endif // DEAL_II_WITH_SCALAPACK #endif // dealii_scalapack_templates_h diff --git a/source/base/process_grid.cc b/source/base/process_grid.cc index 69741b9046..2a4db55892 100644 --- a/source/base/process_grid.cc +++ b/source/base/process_grid.cc @@ -245,6 +245,7 @@ namespace Utilities template void Utilities::MPI::ProcessGrid::send_to_inactive(double *, const int) const; template void Utilities::MPI::ProcessGrid::send_to_inactive(float *, const int) const; +template void Utilities::MPI::ProcessGrid::send_to_inactive(int *, const int) const; DEAL_II_NAMESPACE_CLOSE diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index b6eae03d7c..ea9d7dfa4c 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -328,9 +328,6 @@ ScaLAPACKMatrix::eigenpairs_symmetric(const bool compute_eigenvector const std::pair &eigenvalue_idx, const std::pair &eigenvalue_limits) { - //Assert(Utilities::MPI::n_mpi_processes(gird->mpi_communicator_inactive_with_root)<=1, - // ExcMessage("For the computation of eigenpairs do not use a number of MPI processes that do not fit in a 2D process grid")); - Assert (state == LAPACKSupport::matrix, ExcMessage("Matrix has to be in Matrix state before calling this function.")); Assert (property == LAPACKSupport::symmetric, @@ -347,6 +344,8 @@ ScaLAPACKMatrix::eigenpairs_symmetric(const bool compute_eigenvector //ScaLAPACKMatrix eigenvectors (n_rows, grid, row_block_size); eigenvectors->property = property; + // number of eigenvalues to be returned; upon successful exit ev contains the m seclected eigenvalues in ascending order + int m = n_rows; std::vector ev(n_rows); if (grid->mpi_process_is_active) @@ -361,8 +360,6 @@ ScaLAPACKMatrix::eigenpairs_symmetric(const bool compute_eigenvector bool all_eigenpairs=true; NumberType vl,vu; int il,iu; - // number of eigenvalues to be returned; upon successful exit ev contains the m seclected eigenvalues in ascending order - int m = n_rows; // number of eigenvectors to be returned; // upon successful exit the first m=nz columns contain the selected eigenvectors (only if jobz=='V') int nz; @@ -475,6 +472,16 @@ ScaLAPACKMatrix::eigenpairs_symmetric(const bool compute_eigenvector while ((int)ev.size() > m) ev.pop_back(); } + /* + * send number of computed eigenvalues to inactive processes + */ + grid->send_to_inactive(&m, 1); + + /* + * inactive processes have to resize array of eigenvalues + */ + if (! grid->mpi_process_is_active) + ev.resize (m); /* * send the eigenvalues to processors not being part of the process grid */ @@ -491,6 +498,78 @@ ScaLAPACKMatrix::eigenpairs_symmetric(const bool compute_eigenvector } +template +std::vector ScaLAPACKMatrix::compute_SVD(ScaLAPACKMatrix &U, + ScaLAPACKMatrix &VT, + const bool left_singluar_vectors, + const bool right_singluar_vectors) +{ + Assert (state == LAPACKSupport::matrix, + ExcMessage("Matrix has to be in Matrix state before calling this function.")); + Assert(row_block_size==column_block_size,ExcDimensionMismatch(n_rows,U.n_rows)); + + if (left_singluar_vectors) + { + Assert(n_rows==U.n_rows,ExcDimensionMismatch(n_rows,U.n_rows)); + Assert(U.n_rows==U.n_columns,ExcDimensionMismatch(U.n_rows,U.n_columns)); + Assert(row_block_size==U.row_block_size,ExcDimensionMismatch(row_block_size,U.row_block_size)); + Assert(column_block_size==U.column_block_size,ExcDimensionMismatch(column_block_size,U.column_block_size)); + Assert(grid->blacs_context==U.grid->blacs_context,ExcDimensionMismatch(grid->blacs_context,U.grid->blacs_context)); + } + if (right_singluar_vectors) + { + Assert(n_columns==VT.n_rows,ExcDimensionMismatch(n_columns,VT.n_rows)); + Assert(VT.n_rows==VT.n_columns,ExcDimensionMismatch(VT.n_rows,VT.n_columns)); + Assert(row_block_size==VT.row_block_size,ExcDimensionMismatch(row_block_size,VT.row_block_size)); + Assert(column_block_size==VT.column_block_size,ExcDimensionMismatch(column_block_size,VT.column_block_size)); + Assert(grid->blacs_context==VT.grid->blacs_context,ExcDimensionMismatch(grid->blacs_context,VT.grid->blacs_context)); + } + Threads::Mutex::ScopedLock lock (mutex); + + std::vector sv(std::min(n_rows,n_columns)); + + if (grid->mpi_process_is_active) + { + char jobu = left_singluar_vectors ? 'V' : 'N'; + char jobvt = right_singluar_vectors ? 'V' : 'N'; + NumberType *A_loc = &this->values[0]; + NumberType *U_loc = left_singluar_vectors ? &(U.values[0]) : NULL; + NumberType *VT_loc = right_singluar_vectors ? &(VT.values[0]) : NULL; + int info = 0; + /* + * by setting lwork to -1 a workspace query for optimal length of work is performed + */ + int lwork=-1; + work.resize(1); + + pgesvd(&jobu,&jobvt,&n_rows,&n_columns,A_loc,&submatrix_row,&submatrix_column,descriptor, + & *sv.begin(),U_loc,&U.submatrix_row,&U.submatrix_column,U.descriptor, + VT_loc,&VT.submatrix_row,&VT.submatrix_column,VT.descriptor, + &work[0],&lwork,&info); + AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pgesvd", info)); + + lwork=work[0]; + work.resize(lwork); + + pgesvd(&jobu,&jobvt,&n_rows,&n_columns,A_loc,&submatrix_row,&submatrix_column,descriptor, + & *sv.begin(),U_loc,&U.submatrix_row,&U.submatrix_column,U.descriptor, + VT_loc,&VT.submatrix_row,&VT.submatrix_column,VT.descriptor, + &work[0],&lwork,&info); + AssertThrow (info==0, LAPACKSupport::ExcErrorCode("pgesvd", info)); + } + + /* + * send the singular values to processors not being part of the process grid + */ + grid->send_to_inactive(sv.data(), sv.size()); + + property = LAPACKSupport::Property::general; + state = LAPACKSupport::State::unusable; + + return sv; +} + + template NumberType ScaLAPACKMatrix::reciprocal_condition_number(const NumberType a_norm) const diff --git a/tests/lapack/create_matrix.h b/tests/lapack/create_matrix.h index 6d1fa63974..7e4e2d4052 100644 --- a/tests/lapack/create_matrix.h +++ b/tests/lapack/create_matrix.h @@ -32,7 +32,7 @@ void create_spd (FullMatrix &A) if (i==j) // since A(i,j) < 1 and // a symmetric diagonally dominant matrix is SPD - A(i,j) = val + size + i*i/size; + A(i,j) = val + size; else { A(i,j) = val; diff --git a/tests/scalapack/scalapack_06.cc b/tests/scalapack/scalapack_06.cc index 249aa3eadf..3ede3474ae 100644 --- a/tests/scalapack/scalapack_06.cc +++ b/tests/scalapack/scalapack_06.cc @@ -16,13 +16,14 @@ #include "../tests.h" #include "../lapack/create_matrix.h" -// test eigenvalues_symmetric() +// test eigenpairs_symmetric(const bool, const std::pair&, const std::pair&) #include #include #include #include #include +#include #include #include @@ -32,7 +33,7 @@ #include #include #include - +#include template @@ -44,26 +45,24 @@ void test(const unsigned int size, const unsigned int block_size, const NumberTy ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); + std::shared_ptr grid = std::make_shared(mpi_communicator,size,size,block_size,block_size); + + pcout << size << " " << block_size << std::endl; + // Create SPD matrices of requested size: FullMatrix full_A(size); std::vector lapack_A(size*size); - std::shared_ptr grid = std::make_shared(mpi_communicator,size,size,block_size,block_size); - ScaLAPACKMatrix scalapack_A (size, grid, block_size, - LAPACKSupport::Property::symmetric); - - pcout << size << " " << block_size << " " << grid->get_process_grid_rows() << " " << grid->get_process_grid_columns() << std::endl; create_spd (full_A); - for (unsigned int i = 0; i < size; ++i) for (unsigned int j = 0; j < size; ++j) lapack_A[i*size+j] = full_A(i,j); - std::vector eigenvalues_ScaLapack, eigenvalues_Lapack(size); + std::vector eigenvalues_Lapack(size); //Lapack as reference { int info; //Variable containing information about the successfull exit of the lapack routine - char jobz = 'N'; //'N': the eigenvalues_Lapack of A are computed + char jobz = 'V'; //'V': all eigenpairs of A are computed char uplo = 'U'; //storage format of the matrix A; not so important as matrix is symmetric int LDA = size; //leading dimension of the matrix A int lwork; //length of vector/array work @@ -79,15 +78,85 @@ void test(const unsigned int size, const unsigned int block_size, const NumberTy AssertThrow (info==0, LAPACKSupport::ExcErrorCode("syev", info)); } - // Scalapack: - scalapack_A = full_A; - eigenvalues_ScaLapack = scalapack_A.eigenvalues_symmetric(); - unsigned int n_eigenvalues = eigenvalues_ScaLapack.size(), max_n_eigenvalues=5; + unsigned int n_eigenvalues = eigenvalues_Lapack.size(), max_n_eigenvalues=5; + + std::vector> s_eigenvectors_ (max_n_eigenvalues,Vector(size)); + for (int i=0; i eigenvalues_psyev; + ScaLAPACKMatrix scalapack_syev (size, grid, block_size); + scalapack_syev.set_property(LAPACKSupport::Property::symmetric); + scalapack_syev = full_A; + eigenvalues_psyev = scalapack_syev.eigenpairs_symmetric(true); + FullMatrix p_eigenvectors (size,size); + scalapack_syev.copy_to(p_eigenvectors); + for (unsigned int i=0; i> p_eigenvectors_ (max_n_eigenvalues,Vector(size)); for (unsigned int i=0; i eigenvalues_psyevx_partial; + ScaLAPACKMatrix scalapack_syevx_partial (size, grid, block_size); + scalapack_syevx_partial.set_property(LAPACKSupport::Property::symmetric); + scalapack_syevx_partial = full_A; + eigenvalues_psyevx_partial = scalapack_syevx_partial.eigenpairs_symmetric(true, std::make_pair(size-max_n_eigenvalues+1,size)); + scalapack_syevx_partial.copy_to(p_eigenvectors); + for (unsigned int i=eigenvalues_psyevx_partial.size()-1; i>0; --i) + { + if ( !(std::abs(eigenvalues_psyevx_partial[i]-eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) / + std::abs(eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) < tol)) + { + std::cout << "process #" << this_mpi_process << ": eigenvalues do not fit: " + << eigenvalues_psyevx_partial[i] << " <--> " << eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i] << std::endl; + } + + AssertThrow ( std::abs(eigenvalues_psyevx_partial[i]-eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) / + std::abs(eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) < tol, + dealii::ExcInternalError()); + } + pcout << " with respect to the given tolerance the eigenvalues coincide" << std::endl; + + for (unsigned int i=0; i sizes = {{32,64,120,320,640}}; + const std::vector sizes = {{200,400,600}}; const std::vector blocks = {{32,64}}; - const double tol_double = 1e-10; - const float tol_float = 1e-5; - - for (const auto &s : sizes) - for (const auto &b : blocks) - if (b <= s) - test(s,b,tol_float); + const double tol = 1e-10; for (const auto &s : sizes) for (const auto &b : blocks) if (b <= s) - test(s,b,tol_double); + test(s,b,tol); } diff --git a/tests/scalapack/scalapack_06.mpirun=1.output b/tests/scalapack/scalapack_06.mpirun=1.output index 724105f262..77e6a56658 100644 --- a/tests/scalapack/scalapack_06.mpirun=1.output +++ b/tests/scalapack/scalapack_06.mpirun=1.output @@ -1,72 +1,60 @@ -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide diff --git a/tests/scalapack/scalapack_06.mpirun=11.output b/tests/scalapack/scalapack_06.mpirun=11.output index 95a7fc9423..77e6a56658 100644 --- a/tests/scalapack/scalapack_06.mpirun=11.output +++ b/tests/scalapack/scalapack_06.mpirun=11.output @@ -1,72 +1,60 @@ -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 3 3 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide diff --git a/tests/scalapack/scalapack_06.mpirun=4.output b/tests/scalapack/scalapack_06.mpirun=4.output index 28fc898f2e..77e6a56658 100644 --- a/tests/scalapack/scalapack_06.mpirun=4.output +++ b/tests/scalapack/scalapack_06.mpirun=4.output @@ -1,72 +1,60 @@ -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +200 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -32 32 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +400 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -120 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -320 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide -320 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +600 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 32 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide + with respect to the given tolerance also the eigenvectors coincide -640 64 2 2 -comparing 5 eigenvalues computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide diff --git a/tests/scalapack/scalapack_07.mpirun=11.output b/tests/scalapack/scalapack_06.mpirun=9.output similarity index 59% rename from tests/scalapack/scalapack_07.mpirun=11.output rename to tests/scalapack/scalapack_06.mpirun=9.output index ef4d249881..77e6a56658 100644 --- a/tests/scalapack/scalapack_07.mpirun=11.output +++ b/tests/scalapack/scalapack_06.mpirun=9.output @@ -1,90 +1,60 @@ -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +200 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide -120 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +200 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -320 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide -320 64 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +400 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -640 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -640 64 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +400 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -64 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide -120 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +600 32 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -120 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -320 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide -320 64 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +600 64 +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyev: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -640 32 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: +comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK pdsyevx: with respect to the given tolerance the eigenvalues coincide with respect to the given tolerance also the eigenvectors coincide -640 64 3 3 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide diff --git a/tests/scalapack/scalapack_07.cc b/tests/scalapack/scalapack_07.cc index 00ab56b18a..2dfb1b5e23 100644 --- a/tests/scalapack/scalapack_07.cc +++ b/tests/scalapack/scalapack_07.cc @@ -16,28 +16,23 @@ #include "../tests.h" #include "../lapack/create_matrix.h" -// test eigenpairs_symmetric() and calls set_property() +// test copying of distributed ScaLAPACKMatrices using ScaLAPACK routine p_gemr2d #include #include #include #include #include -#include -#include -#include -#include + #include #include #include -#include -#include template -void test(const unsigned int size, const unsigned int block_size, const NumberType tol) +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)); @@ -45,100 +40,71 @@ void test(const unsigned int size, const unsigned int block_size, const NumberTy ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); - // Create SPD matrices of requested size: - FullMatrix full_A(size); - std::vector lapack_A(size*size); - - std::shared_ptr grid = std::make_shared(mpi_communicator,size,size,block_size,block_size); - ScaLAPACKMatrix scalapack_A (size, grid, block_size); - scalapack_A.set_property(LAPACKSupport::Property::symmetric); - - pcout << size << " " << block_size << " " << grid->get_process_grid_rows() << " " << grid->get_process_grid_columns() << std::endl; - - create_spd (full_A); - for (unsigned int i = 0; i < size; ++i) - for (unsigned int j = 0; j < size; ++j) - lapack_A[i*size+j] = full_A(i,j); - - std::vector eigenvalues_ScaLapack, eigenvalues_Lapack(size); - //Lapack as reference - { - int info; //Variable containing information about the successfull exit of the lapack routine - char jobz = 'V'; //'V': all eigenpairs of A are computed - char uplo = 'U'; //storage format of the matrix A; not so important as matrix is symmetric - int LDA = size; //leading dimension of the matrix A - int lwork; //length of vector/array work - std::vector work (1); - - //by setting lwork to -1 a workspace query for work is done - //as matrix is symmetric: LDA == size of matrix - lwork = -1; - syev(&jobz, &uplo, &LDA, & *lapack_A.begin(), &LDA, & *eigenvalues_Lapack.begin(), & *work.begin(), &lwork, &info); - lwork=work[0]; - work.resize (lwork); - syev(&jobz, &uplo, &LDA, & *lapack_A.begin(), &LDA, & *eigenvalues_Lapack.begin(), & *work.begin(), &lwork, &info); - - AssertThrow (info==0, LAPACKSupport::ExcErrorCode("syev", info)); - } - // Scalapack: - scalapack_A = full_A; - eigenvalues_ScaLapack = scalapack_A.eigenpairs_symmetric(); - FullMatrix p_eigenvectors (size,size); - scalapack_A.copy_to(p_eigenvectors); - unsigned int n_eigenvalues = eigenvalues_ScaLapack.size(), max_n_eigenvalues=5; - - pcout << "comparing " << max_n_eigenvalues << " eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK:" << std::endl; - for (unsigned int i=0; i s_eigenvectors (size,size); - for (int i=0; i> s_eigenvectors_ (max_n_eigenvalues,Vector(size)); - for (int i=0; i> p_eigenvectors_ (max_n_eigenvalues,Vector(size)); - for (unsigned int i=0; i full(size); + unsigned int count=0; + for (unsigned int i=0; i grid_2d = std::make_shared(mpi_communicator,size,size,block_size_i,block_size_i); + //create 1d process grid + std::shared_ptr grid_1d = std::make_shared(mpi_communicator,n_mpi_processes,1); + //create process grid containing one process + std::shared_ptr grid_single = std::make_shared(mpi_communicator,1,1); + + ScaLAPACKMatrix scalapack_matrix_2d (size, size, grid_2d, block_size_i, block_size_i); + ScaLAPACKMatrix scalapack_matrix_1d (size, size, grid_1d, block_size_j, block_size_j); + ScaLAPACKMatrix scalapack_matrix_single (size, size, grid_single, block_size_i, block_size_j); + ScaLAPACKMatrix scalapack_matrix_source (size, size, grid_single, block_size_j, block_size_i); + + pcout << "2D grid matrix: dim=" << scalapack_matrix_2d.m() << "x" << scalapack_matrix_2d.n() + << "; blocks=" << block_size_i << "x" << block_size_i + << "; grid=" << grid_2d->get_process_grid_rows() << "x" << grid_2d->get_process_grid_columns() << std::endl; + + pcout << "1D grid matrix: " << scalapack_matrix_1d.m() << "x" << scalapack_matrix_1d.n() + << "; blocks=" << block_size_j << "x" << block_size_j + << "; grid=" << grid_1d->get_process_grid_rows() << "x" << grid_1d->get_process_grid_columns() << std::endl; + + pcout << "single process matrix: " << scalapack_matrix_single.m() << "x" << scalapack_matrix_single.n() + << "; blocks=" << block_size_i << "x" << block_size_j + << "; grid=" << grid_single->get_process_grid_rows() << "x" << grid_single->get_process_grid_columns() << std::endl << std::endl; + + scalapack_matrix_source = full; + + scalapack_matrix_source.copy_to(scalapack_matrix_2d); + scalapack_matrix_source.copy_to(scalapack_matrix_1d); + scalapack_matrix_source.copy_to(scalapack_matrix_single); + + FullMatrix test_2d(size), test_1d(size), test_one(size); + scalapack_matrix_2d.copy_to(test_2d); + scalapack_matrix_1d.copy_to(test_1d); + scalapack_matrix_single.copy_to(test_one); + test_2d.add (-1,full); + test_1d.add (-1,full); + test_one.add (-1,full); + + AssertThrow(test_2d.frobenius_norm() < 1e-12,ExcInternalError()); + AssertThrow(test_1d.frobenius_norm() < 1e-12,ExcInternalError()); + AssertThrow(test_one.frobenius_norm() < 1e-12,ExcInternalError()); } int main (int argc,char **argv) { - Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); - const std::vector sizes = {{32,64,120,320,640}}; - const std::vector blocks = {{32,64}}; - - const double tol_double = 1e-10; - const float tol_float = 1e-5; + const std::vector blocks_i = {{16,32,64}}; + const std::vector blocks_j = {{16,32,64}}; - for (const auto &s : sizes) - for (const auto &b : blocks) - if (b <= s) - test(s,b,tol_float); + for (const auto &s : blocks_i) + for (const auto &b : blocks_j) + test(s,b); - for (const auto &s : sizes) - for (const auto &b : blocks) - if (b <= s) - test(s,b,tol_double); + for (const auto &s : blocks_i) + for (const auto &b : blocks_j) + test(s,b); } diff --git a/tests/scalapack/scalapack_07.mpirun=1.output b/tests/scalapack/scalapack_07.mpirun=1.output index 7159ec7532..5028735bb4 100644 --- a/tests/scalapack/scalapack_07.mpirun=1.output +++ b/tests/scalapack/scalapack_07.mpirun=1.output @@ -1,90 +1,72 @@ -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=16x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=16x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=16x64; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=32x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=32x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=32x64; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=64x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=64x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=64x64; grid=1x1 + +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=16x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=16x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=16x64; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=32x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=32x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=32x64; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=16x16; grid=1x1 +single process matrix: 500x500; blocks=64x16; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=32x32; grid=1x1 +single process matrix: 500x500; blocks=64x32; grid=1x1 + +2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 +1D grid matrix: 500x500; blocks=64x64; grid=1x1 +single process matrix: 500x500; blocks=64x64; grid=1x1 diff --git a/tests/scalapack/scalapack_08.mpirun=10.output b/tests/scalapack/scalapack_07.mpirun=10.output similarity index 100% rename from tests/scalapack/scalapack_08.mpirun=10.output rename to tests/scalapack/scalapack_07.mpirun=10.output diff --git a/tests/scalapack/scalapack_07.mpirun=4.output b/tests/scalapack/scalapack_07.mpirun=4.output deleted file mode 100644 index 6bf2dcd729..0000000000 --- a/tests/scalapack/scalapack_07.mpirun=4.output +++ /dev/null @@ -1,90 +0,0 @@ -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -32 32 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -64 64 1 1 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -120 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -320 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 32 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - -640 64 2 2 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: - with respect to the given tolerance the eigenvalues coincide - with respect to the given tolerance also the eigenvectors coincide - diff --git a/tests/scalapack/scalapack_08.mpirun=5.output b/tests/scalapack/scalapack_07.mpirun=5.output similarity index 100% rename from tests/scalapack/scalapack_08.mpirun=5.output rename to tests/scalapack/scalapack_07.mpirun=5.output diff --git a/tests/scalapack/scalapack_08.cc b/tests/scalapack/scalapack_08.cc index 2dfb1b5e23..399b235cff 100644 --- a/tests/scalapack/scalapack_08.cc +++ b/tests/scalapack/scalapack_08.cc @@ -16,23 +16,28 @@ #include "../tests.h" #include "../lapack/create_matrix.h" -// test copying of distributed ScaLAPACKMatrices using ScaLAPACK routine p_gemr2d +// test compute_SVD(ScaLAPACKMatrix&,ScaLAPACKMatrix&,const bool,const bool) #include #include #include #include #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) +void test(const unsigned int size, const unsigned int block_size, const NumberType tol) { MPI_Comm mpi_communicator(MPI_COMM_WORLD); const unsigned int n_mpi_processes(Utilities::MPI::n_mpi_processes(mpi_communicator)); @@ -40,71 +45,72 @@ void test(const unsigned int block_size_i, const unsigned int block_size_j) ConditionalOStream pcout (std::cout, (this_mpi_process ==0)); - const unsigned int size = 500; - //create FullMatrix and fill it - FullMatrix full(size); - unsigned int count=0; - for (unsigned int i=0; i grid_2d = std::make_shared(mpi_communicator,size,size,block_size_i,block_size_i); - //create 1d process grid - std::shared_ptr grid_1d = std::make_shared(mpi_communicator,n_mpi_processes,1); - //create process grid containing one process - std::shared_ptr grid_single = std::make_shared(mpi_communicator,1,1); - - ScaLAPACKMatrix scalapack_matrix_2d (size, size, grid_2d, block_size_i, block_size_i); - ScaLAPACKMatrix scalapack_matrix_1d (size, size, grid_1d, block_size_j, block_size_j); - ScaLAPACKMatrix scalapack_matrix_single (size, size, grid_single, block_size_i, block_size_j); - ScaLAPACKMatrix scalapack_matrix_source (size, size, grid_single, block_size_j, block_size_i); - - pcout << "2D grid matrix: dim=" << scalapack_matrix_2d.m() << "x" << scalapack_matrix_2d.n() - << "; blocks=" << block_size_i << "x" << block_size_i - << "; grid=" << grid_2d->get_process_grid_rows() << "x" << grid_2d->get_process_grid_columns() << std::endl; - - pcout << "1D grid matrix: " << scalapack_matrix_1d.m() << "x" << scalapack_matrix_1d.n() - << "; blocks=" << block_size_j << "x" << block_size_j - << "; grid=" << grid_1d->get_process_grid_rows() << "x" << grid_1d->get_process_grid_columns() << std::endl; - - pcout << "single process matrix: " << scalapack_matrix_single.m() << "x" << scalapack_matrix_single.n() - << "; blocks=" << block_size_i << "x" << block_size_j - << "; grid=" << grid_single->get_process_grid_rows() << "x" << grid_single->get_process_grid_columns() << std::endl << std::endl; - - scalapack_matrix_source = full; - - scalapack_matrix_source.copy_to(scalapack_matrix_2d); - scalapack_matrix_source.copy_to(scalapack_matrix_1d); - scalapack_matrix_source.copy_to(scalapack_matrix_single); - - FullMatrix test_2d(size), test_1d(size), test_one(size); - scalapack_matrix_2d.copy_to(test_2d); - scalapack_matrix_1d.copy_to(test_1d); - scalapack_matrix_single.copy_to(test_one); - test_2d.add (-1,full); - test_1d.add (-1,full); - test_one.add (-1,full); - - AssertThrow(test_2d.frobenius_norm() < 1e-12,ExcInternalError()); - AssertThrow(test_1d.frobenius_norm() < 1e-12,ExcInternalError()); - AssertThrow(test_one.frobenius_norm() < 1e-12,ExcInternalError()); + std::shared_ptr grid_2d = std::make_shared(mpi_communicator,size,size,block_size,block_size); + + pcout << size << " " << block_size << std::endl; + + // Create s.p.d matrices of requested size: + FullMatrix full_A(size); + create_spd (full_A); + + //compute eigenpairs of s.p.d matrix + ScaLAPACKMatrix scalapack_A_ev (size, grid_2d, block_size); + scalapack_A_ev.set_property(LAPACKSupport::Property::symmetric); + scalapack_A_ev = full_A; + std::vector eigenvalues = scalapack_A_ev.eigenpairs_symmetric(true); + FullMatrix eigenvectors (size,size); + scalapack_A_ev.copy_to(eigenvectors); + + //compute SVD of s.p.d matrix A = U * SIGMA * VT + ScaLAPACKMatrix scalapack_A_sv (size, grid_2d, block_size); + ScaLAPACKMatrix scalapack_U (size, grid_2d, block_size); + ScaLAPACKMatrix scalapack_VT (size, grid_2d, block_size); + scalapack_A_sv.set_property(LAPACKSupport::Property::symmetric); + scalapack_A_sv = full_A; + std::vector singular_values = scalapack_A_sv.compute_SVD(scalapack_U,scalapack_VT,true,true); + FullMatrix l_singular_vectors (size,size); + FullMatrix r_singular_vectors (size,size); + scalapack_U.copy_to(l_singular_vectors); + scalapack_VT.copy_to(r_singular_vectors); + + const unsigned int max_num_values=5; + pcout << "comparing the SVD and Eigendecomposition of a s.p.d matrix" << std::endl; + for (unsigned i=0; i eigenvector(size), l_singular_vector(size), r_singular_vector(size); + for (unsigned int i=0; i blocks_i = {{16,32,64}}; - const std::vector blocks_j = {{16,32,64}}; + Utilities::MPI::MPI_InitFinalize mpi_initialization(argc, argv, numbers::invalid_unsigned_int); - for (const auto &s : blocks_i) - for (const auto &b : blocks_j) - test(s,b); + const std::vector sizes = {{200,400,600}}; + const std::vector blocks = {{32,64}}; + const double tol_double = 1e-10; - for (const auto &s : blocks_i) - for (const auto &b : blocks_j) - test(s,b); + for (const auto &s : sizes) + for (const auto &b : blocks) + if (b <= s) + test(s,b,tol_double); } diff --git a/tests/scalapack/scalapack_08.mpirun=1.output b/tests/scalapack/scalapack_08.mpirun=1.output index 5028735bb4..f6a7f9008a 100644 --- a/tests/scalapack/scalapack_08.mpirun=1.output +++ b/tests/scalapack/scalapack_08.mpirun=1.output @@ -1,72 +1,30 @@ -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=16x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=16x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=16x64; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=32x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=32x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=32x64; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=64x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=64x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=64x64; grid=1x1 - -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=16x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=16x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=16x16; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=16x64; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=32x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=32x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=32x32; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=32x64; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=16x16; grid=1x1 -single process matrix: 500x500; blocks=64x16; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=32x32; grid=1x1 -single process matrix: 500x500; blocks=64x32; grid=1x1 - -2D grid matrix: dim=500x500; blocks=64x64; grid=1x1 -1D grid matrix: 500x500; blocks=64x64; grid=1x1 -single process matrix: 500x500; blocks=64x64; grid=1x1 +200 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +200 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors diff --git a/tests/scalapack/scalapack_08.mpirun=11.output b/tests/scalapack/scalapack_08.mpirun=11.output new file mode 100644 index 0000000000..f6a7f9008a --- /dev/null +++ b/tests/scalapack/scalapack_08.mpirun=11.output @@ -0,0 +1,30 @@ +200 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +200 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + diff --git a/tests/scalapack/scalapack_08.mpirun=4.output b/tests/scalapack/scalapack_08.mpirun=4.output new file mode 100644 index 0000000000..f6a7f9008a --- /dev/null +++ b/tests/scalapack/scalapack_08.mpirun=4.output @@ -0,0 +1,30 @@ +200 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +200 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +400 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 32 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + +600 64 +comparing the SVD and Eigendecomposition of a s.p.d matrix + with respect to the given tolerance the singular and eigenvalues coincide + with respect to the given tolerance the right and left singular vectors coincide with the eigenvectors + diff --git a/tests/scalapack/scalapack_09.cc b/tests/scalapack/scalapack_09.cc deleted file mode 100644 index ea6790e015..0000000000 --- a/tests/scalapack/scalapack_09.cc +++ /dev/null @@ -1,172 +0,0 @@ -// --------------------------------------------------------------------- -// -// 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 eigenpairs_symmetric(const bool, const std::pair&, const std::pair&) - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include - - -template -void test(const unsigned int size, const unsigned int block_size, const NumberType tol) -{ - 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)); - - std::shared_ptr grid = std::make_shared(mpi_communicator,size,size,block_size,block_size); - - pcout << size << " " << block_size << std::endl; - - // Create SPD matrices of requested size: - FullMatrix full_A(size); - std::vector lapack_A(size*size); - - create_spd (full_A); - for (unsigned int i = 0; i < size; ++i) - for (unsigned int j = 0; j < size; ++j) - lapack_A[i*size+j] = full_A(i,j); - - std::vector eigenvalues_Lapack(size); - //Lapack as reference - { - int info; //Variable containing information about the successfull exit of the lapack routine - char jobz = 'V'; //'V': all eigenpairs of A are computed - char uplo = 'U'; //storage format of the matrix A; not so important as matrix is symmetric - int LDA = size; //leading dimension of the matrix A - int lwork; //length of vector/array work - std::vector work (1); - - //by setting lwork to -1 a workspace query for work is done - //as matrix is symmetric: LDA == size of matrix - lwork = -1; - syev(&jobz, &uplo, &LDA, & *lapack_A.begin(), &LDA, & *eigenvalues_Lapack.begin(), & *work.begin(), &lwork, &info); - lwork=work[0]; - work.resize (lwork); - syev(&jobz, &uplo, &LDA, & *lapack_A.begin(), &LDA, & *eigenvalues_Lapack.begin(), & *work.begin(), &lwork, &info); - - AssertThrow (info==0, LAPACKSupport::ExcErrorCode("syev", info)); - } - unsigned int n_eigenvalues = eigenvalues_Lapack.size(), max_n_eigenvalues=5; - - std::vector> s_eigenvectors_ (max_n_eigenvalues,Vector(size)); - for (int i=0; i eigenvalues_psyev; - ScaLAPACKMatrix scalapack_syev (size, grid, block_size); - scalapack_syev.set_property(LAPACKSupport::Property::symmetric); - scalapack_syev = full_A; - eigenvalues_psyev = scalapack_syev.eigenpairs_symmetric(true); - FullMatrix p_eigenvectors (size,size); - scalapack_syev.copy_to(p_eigenvectors); - for (unsigned int i=0; i> p_eigenvectors_ (max_n_eigenvalues,Vector(size)); - for (unsigned int i=0; i eigenvalues_psyevx_partial; - ScaLAPACKMatrix scalapack_syevx_partial (size, grid, block_size); - scalapack_syevx_partial.set_property(LAPACKSupport::Property::symmetric); - scalapack_syevx_partial = full_A; - eigenvalues_psyevx_partial = scalapack_syevx_partial.eigenpairs_symmetric(true, std::make_pair(size-max_n_eigenvalues+1,size)); - scalapack_syevx_partial.copy_to(p_eigenvectors); - for (unsigned int i=eigenvalues_psyevx_partial.size()-1; i>0; --i) - { - AssertThrow ( std::abs(eigenvalues_psyevx_partial[i]-eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) / - std::abs(eigenvalues_Lapack[size-eigenvalues_psyevx_partial.size()+i]) < tol, - dealii::ExcInternalError()); - } - pcout << " with respect to the given tolerance the eigenvalues coincide" << std::endl; - - for (unsigned int i=0; i sizes = {{200,400,600}}; - const std::vector blocks = {{32,64}}; - - const double tol_double = 1e-10; - const float tol_float = 1e-5; - - for (const auto &s : sizes) - for (const auto &b : blocks) - if (b <= s) - test(s,b,tol_float); - - for (const auto &s : sizes) - for (const auto &b : blocks) - if (b <= s) - test(s,b,tol_double); -} diff --git a/tests/scalapack/scalapack_09.mpirun=1.output b/tests/scalapack/scalapack_09.mpirun=1.output deleted file mode 100644 index 4f3177f140..0000000000 --- a/tests/scalapack/scalapack_09.mpirun=1.output +++ /dev/null @@ -1,66 +0,0 @@ -200 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - - -200 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - - -400 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - - -400 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - - -600 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - - -600 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - - diff --git a/tests/scalapack/scalapack_09.mpirun=4.output b/tests/scalapack/scalapack_09.mpirun=4.output deleted file mode 100644 index 4f3177f140..0000000000 --- a/tests/scalapack/scalapack_09.mpirun=4.output +++ /dev/null @@ -1,66 +0,0 @@ -200 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - - -200 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - - -400 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - - -400 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - - -600 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - - -600 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - - diff --git a/tests/scalapack/scalapack_09.mpirun=9.output b/tests/scalapack/scalapack_09.mpirun=9.output deleted file mode 100644 index 4f3177f140..0000000000 --- a/tests/scalapack/scalapack_09.mpirun=9.output +++ /dev/null @@ -1,66 +0,0 @@ -200 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -411.91<->411.91 396.894<->396.894 395.588<->395.588 392.905<->392.905 391.261<->391.261 - with respect to the given tolerance the eigenvalues coincide - - -200 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -412.36<->412.36 397.285<->397.285 395.54<->395.54 392.855<->392.855 391.447<->391.447 - with respect to the given tolerance the eigenvalues coincide - - -400 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.747<->825.747 797.968<->797.968 795.8<->795.8 793.229<->793.229 790.87<->790.87 - with respect to the given tolerance the eigenvalues coincide - - -400 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -825.723<->825.723 798.22<->798.22 795.562<->795.562 793.391<->793.391 791.088<->791.088 - with respect to the given tolerance the eigenvalues coincide - - -600 32 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.43<->1238.43 1197.98<->1197.98 1195.9<->1195.9 1193.53<->1193.53 1191.69<->1191.69 - with respect to the given tolerance the eigenvalues coincide - - -600 64 -comparing 5 eigenvalues and eigenvectors computed using LAPACK and ScaLAPACK: -pdsyev -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - -pdsyevx partial -1238.82<->1238.82 1197.67<->1197.67 1195.39<->1195.39 1192.85<->1192.85 1191.38<->1191.38 - with respect to the given tolerance the eigenvalues coincide - -