From 10b6901aab687a2c0d8055b7f6f21879246a71ee Mon Sep 17 00:00:00 2001 From: Benjamin Brands Date: Fri, 6 Apr 2018 10:11:43 +0200 Subject: [PATCH] add ScaLAPACKMatrix::reinit() --- include/deal.II/lac/scalapack.h | 19 +++++++++ source/lac/scalapack.cc | 73 +++++++++++++++++++++------------ 2 files changed, 66 insertions(+), 26 deletions(-) diff --git a/include/deal.II/lac/scalapack.h b/include/deal.II/lac/scalapack.h index 6feaba0f02..ae0c0f9b4b 100644 --- a/include/deal.II/lac/scalapack.h +++ b/include/deal.II/lac/scalapack.h @@ -136,6 +136,25 @@ public: */ ~ScaLAPACKMatrix() = default; + /** + * Initialize the rectangular matrix with @p n_rows and @p n_cols + * and distributed using the grid @p process_grid. + */ + void reinit(const size_type n_rows, + const size_type n_columns, + const std::shared_ptr &process_grid, + const size_type row_block_size = 32, + const size_type column_block_size = 32, + const LAPACKSupport::Property property = LAPACKSupport::Property::general); + + /** + * Initialize the square matrix of size @p size and distributed using the grid @p process_grid. + */ + void reinit(const size_type size, + const std::shared_ptr process_grid, + const size_type block_size = 32, + const LAPACKSupport::Property property = LAPACKSupport::Property::symmetric); + /** * Assign @p property to this matrix. */ diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index 7f1b417748..671b5bd6be 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -75,31 +75,56 @@ ScaLAPACKMatrix::ScaLAPACKMatrix(const size_type n_rows_, const std::shared_ptr &process_grid, const size_type row_block_size_, const size_type column_block_size_, - const LAPACKSupport::Property property) + const LAPACKSupport::Property property_) : - TransposeTable (), - state (LAPACKSupport::matrix), - property(property), - grid (process_grid), - n_rows(n_rows_), - n_columns(n_columns_), - row_block_size(row_block_size_), - column_block_size(column_block_size_), uplo('L'), // for non-symmetric matrices this is not needed first_process_row(0), first_process_column(0), submatrix_row(1), submatrix_column(1) { - Assert (row_block_size > 0, + reinit(n_rows_, n_columns_, process_grid, row_block_size_, column_block_size_, property_); +} + + + +template +ScaLAPACKMatrix::ScaLAPACKMatrix(const size_type size, + const std::shared_ptr process_grid, + const size_type block_size, + const LAPACKSupport::Property property) + : + ScaLAPACKMatrix(size, size, process_grid, block_size, block_size, property) +{} + + + +template +void +ScaLAPACKMatrix::reinit(const size_type n_rows_, + const size_type n_columns_, + const std::shared_ptr &process_grid, + const size_type row_block_size_, + const size_type column_block_size_, + const LAPACKSupport::Property property_) +{ + Assert (row_block_size_ > 0, ExcMessage("Row block size has to be positive.")); - Assert (column_block_size > 0, + Assert (column_block_size_ > 0, ExcMessage("Column block size has to be positive.")); - Assert (row_block_size <= n_rows, + Assert (row_block_size_ <= n_rows_, ExcMessage("Row block size can not be greater than the number of rows of the matrix")); - Assert (column_block_size <= n_columns, + Assert (column_block_size_ <= n_columns_, ExcMessage("Column block size can not be greater than the number of columns of the matrix")); + state = LAPACKSupport::State::matrix; + property = property_; + grid = process_grid; + n_rows = n_rows_; + n_columns = n_columns_; + row_block_size = row_block_size_; + column_block_size = column_block_size_; + if (grid->mpi_process_is_active) { // Get local sizes: @@ -116,7 +141,7 @@ ScaLAPACKMatrix::ScaLAPACKMatrix(const size_type n_rows_, &(grid->blacs_context), &lda, &info); AssertThrow (info==0, LAPACKSupport::ExcErrorCode("descinit_", info)); - this->reinit(n_local_rows, n_local_columns); + this->TransposeTable::reinit(n_local_rows, n_local_columns); } else { @@ -131,18 +156,14 @@ ScaLAPACKMatrix::ScaLAPACKMatrix(const size_type n_rows_, template -ScaLAPACKMatrix::ScaLAPACKMatrix(const size_type size, - const std::shared_ptr process_grid, - const size_type block_size, - const LAPACKSupport::Property property) - : - ScaLAPACKMatrix(size, - size, - process_grid, - block_size, - block_size, - property) -{} +void +ScaLAPACKMatrix::reinit(const size_type size, + const std::shared_ptr process_grid, + const size_type block_size, + const LAPACKSupport::Property property) +{ + reinit(size, size, process_grid, block_size, block_size, property); +} -- 2.39.5