From 640003b490d76238e05e5d3544aadf85acc34e8c Mon Sep 17 00:00:00 2001 From: Bruno Turcksin Date: Mon, 25 Mar 2013 21:27:09 +0000 Subject: [PATCH] Use the 64 bits version of Trilinos 11. git-svn-id: https://svn.dealii.org/branches/branch_bigger_global_dof_indices_4@29030 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/types.h | 7 +- .../deal.II/lac/trilinos_sparse_matrix.h | 46 +++--- .../deal.II/lac/trilinos_sparsity_pattern.h | 2 +- deal.II/source/lac/trilinos_sparse_matrix.cc | 137 +++++++++--------- .../source/lac/trilinos_sparsity_pattern.cc | 52 +++---- deal.II/source/lac/trilinos_vector.cc | 2 +- 6 files changed, 120 insertions(+), 126 deletions(-) diff --git a/deal.II/include/deal.II/base/types.h b/deal.II/include/deal.II/base/types.h index 6f29d80955..80c02453df 100644 --- a/deal.II/include/deal.II/base/types.h +++ b/deal.II/include/deal.II/base/types.h @@ -145,17 +145,16 @@ namespace TrilinosWrappers { namespace types { -#define DEAL_II_EPETRA_NO_64BIT_GLOBAL_INDICES -#ifdef DEAL_II_EPETRA_NO_64BIT_GLOBAL_INDICES +#ifdef DEAL_II_USE_LARGE_INDEX_TYPE /** * Declare type of integer used in the Epetra package of Trilinos. */ - typedef int int_type; + typedef long long int_type; #else /** * Declare type of integer used in the Epetra package of Trilinos. */ - typedef long long int_type; + typedef int int_type; #endif } } diff --git a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h index 40b7aade7f..c647fde6f6 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h +++ b/deal.II/include/deal.II/lac/trilinos_sparse_matrix.h @@ -578,7 +578,7 @@ namespace TrilinosWrappers */ SparseMatrix (const size_type m, const size_type n, - const size_type n_max_entries_per_row); + const unsigned int n_max_entries_per_row); /** * Generate a matrix that is completely @@ -590,9 +590,9 @@ namespace TrilinosWrappers * specifies the number of entries in * each row. */ - SparseMatrix (const size_type m, - const size_type n, - const std::vector &n_entries_per_row); + SparseMatrix (const size_type m, + const size_type n, + const std::vector &n_entries_per_row); /** * Generate a matrix from a Trilinos @@ -761,8 +761,8 @@ namespace TrilinosWrappers * SparseMatrix::reinit call * considerably faster. */ - SparseMatrix (const Epetra_Map ¶llel_partitioning, - const std::vector &n_entries_per_row); + SparseMatrix (const Epetra_Map ¶llel_partitioning, + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -828,7 +828,7 @@ namespace TrilinosWrappers */ SparseMatrix (const Epetra_Map &row_parallel_partitioning, const Epetra_Map &col_parallel_partitioning, - const std::vector &n_entries_per_row); + const std::vector &n_entries_per_row); /** * This function is initializes the @@ -991,9 +991,9 @@ namespace TrilinosWrappers * memory prior to use (in the * compress() step). */ - SparseMatrix (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator = MPI_COMM_WORLD, - const size_type n_max_entries_per_row = 0); + SparseMatrix (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator = MPI_COMM_WORLD, + const unsigned int n_max_entries_per_row = 0); /** * Same as before, but now set the @@ -1009,9 +1009,9 @@ namespace TrilinosWrappers * SparseMatrix::reinit call * considerably faster. */ - SparseMatrix (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + SparseMatrix (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * This constructor is similar to the @@ -1074,10 +1074,10 @@ namespace TrilinosWrappers * each row of the newly generated * matrix. */ - SparseMatrix (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row); + SparseMatrix (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row); /** * This function is initializes the @@ -1249,7 +1249,7 @@ namespace TrilinosWrappers * exactly are stored locally, * use local_range(). */ - size_type local_size () const; + unsigned int local_size () const; /** * Return a pair of indices @@ -3501,7 +3501,7 @@ namespace TrilinosWrappers std::cout << col_index_ptr[i] << " "; std::cout << std::endl << std::endl; std::cout << "Matrix row has the following indices:" << std::endl; - TrilinosWrappers::types::int_type n_indices, *indices; + int n_indices, *indices; trilinos_sparsity_pattern().ExtractMyRowView(row_partitioner().LID(static_cast(row)), n_indices, indices); @@ -3524,7 +3524,7 @@ namespace TrilinosWrappers SparseMatrix::size_type SparseMatrix::m () const { - return matrix -> NumGlobalRows(); + return matrix -> NumGlobalRows64(); } @@ -3533,13 +3533,13 @@ namespace TrilinosWrappers SparseMatrix::size_type SparseMatrix::n () const { - return matrix -> NumGlobalCols(); + return matrix -> NumGlobalCols64(); } inline - SparseMatrix::size_type + unsigned int SparseMatrix::local_size () const { return matrix -> NumMyRows(); @@ -3564,7 +3564,7 @@ namespace TrilinosWrappers SparseMatrix::size_type SparseMatrix::n_nonzero_elements () const { - return matrix->NumGlobalNonzeros(); + return matrix->NumGlobalNonzeros64(); } diff --git a/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h b/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h index 494da6f40f..a0b7cb947f 100644 --- a/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h +++ b/deal.II/include/deal.II/lac/trilinos_sparsity_pattern.h @@ -1038,7 +1038,7 @@ namespace TrilinosWrappers * exactly are stored locally, * use local_range(). */ - size_type local_size () const; + int local_size () const; /** * Return a pair of indices diff --git a/deal.II/source/lac/trilinos_sparse_matrix.cc b/deal.II/source/lac/trilinos_sparse_matrix.cc index d90ad93733..4d97382db3 100644 --- a/deal.II/source/lac/trilinos_sparse_matrix.cc +++ b/deal.II/source/lac/trilinos_sparse_matrix.cc @@ -54,7 +54,7 @@ namespace TrilinosWrappers // get a representation of the present // row - TrilinosWrappers::types::int_type ncols; + int ncols; TrilinosWrappers::types::int_type colnums = matrix->n(); if (value_cache.get() == 0) { @@ -124,12 +124,12 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map (input_map)), matrix (new Epetra_FECrsMatrix (Copy, *column_space_map, - (TrilinosWrappers::types::int_type *)const_cast(&(n_entries_per_row[0])), + (int *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -152,11 +152,11 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const Epetra_Map &input_row_map, const Epetra_Map &input_col_map, - const std::vector &n_entries_per_row) + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map (input_col_map)), matrix (new Epetra_FECrsMatrix(Copy, input_row_map, - (TrilinosWrappers::types::int_type *)const_cast(&(n_entries_per_row[0])), + (int *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -166,7 +166,7 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const size_type m, const size_type n, - const size_type n_max_entries_per_row) + const unsigned int n_max_entries_per_row) : column_space_map (new Epetra_Map (static_cast(n), 0, Utilities::Trilinos::comm_self())), @@ -191,9 +191,9 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const size_type m, - const size_type n, - const std::vector &n_entries_per_row) + SparseMatrix::SparseMatrix (const size_type m, + const size_type n, + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map (static_cast(n), 0, Utilities::Trilinos::comm_self())), @@ -201,7 +201,7 @@ namespace TrilinosWrappers Epetra_Map (static_cast(m), 0, Utilities::Trilinos::comm_self()), *column_space_map, - (TrilinosWrappers::types::int_type *)const_cast(&(n_entries_per_row[0])), + (int *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -211,7 +211,7 @@ namespace TrilinosWrappers SparseMatrix::SparseMatrix (const IndexSet ¶llel_partitioning, const MPI_Comm &communicator, - const size_type n_max_entries_per_row) + const unsigned int n_max_entries_per_row) : column_space_map (new Epetra_Map(parallel_partitioning. make_trilinos_map(communicator, false))), @@ -225,15 +225,15 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const IndexSet ¶llel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + SparseMatrix::SparseMatrix (const IndexSet ¶llel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map(parallel_partitioning. make_trilinos_map(communicator, false))), matrix (new Epetra_FECrsMatrix(Copy, *column_space_map, - (TrilinosWrappers::types::int_type *)const_cast(&(n_entries_per_row[0])), + (int *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -259,17 +259,17 @@ namespace TrilinosWrappers - SparseMatrix::SparseMatrix (const IndexSet &row_parallel_partitioning, - const IndexSet &col_parallel_partitioning, - const MPI_Comm &communicator, - const std::vector &n_entries_per_row) + SparseMatrix::SparseMatrix (const IndexSet &row_parallel_partitioning, + const IndexSet &col_parallel_partitioning, + const MPI_Comm &communicator, + const std::vector &n_entries_per_row) : column_space_map (new Epetra_Map(col_parallel_partitioning. make_trilinos_map(communicator, false))), matrix (new Epetra_FECrsMatrix(Copy, row_parallel_partitioning. make_trilinos_map(communicator, false), - (TrilinosWrappers::types::int_type *)const_cast(&(n_entries_per_row[0])), + (int *)const_cast(&(n_entries_per_row[0])), false)), last_action (Zero), compressed (false) @@ -428,7 +428,7 @@ namespace TrilinosWrappers const size_type first_row = input_row_map.MinMyGID(), last_row = input_row_map.MaxMyGID()+1; - std::vector n_entries_per_row(last_row-first_row); + std::vector n_entries_per_row(last_row-first_row); for (size_type row=first_row; rowOptimizeStorage(); // check whether we got the number of columns right. - AssertDimension (sparsity_pattern.n_cols(), - static_cast(graph->NumGlobalCols())); + AssertDimension (sparsity_pattern.n_cols(),static_cast(graph->NumGlobalCols64())); // And now finally generate the matrix. matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false)); @@ -720,23 +719,21 @@ namespace TrilinosWrappers // Only do this on the rows owned // locally on this processor. - TrilinosWrappers::types::int_type local_row = + int local_row = matrix->LRID(static_cast(row)); if (local_row >= 0) { TrilinosScalar *values; - TrilinosWrappers::types::int_type *col_indices; - TrilinosWrappers::types::int_type num_entries; + int *col_indices; + int num_entries; const int ierr = matrix->ExtractMyRowView(local_row, num_entries, values, col_indices); Assert (ierr == 0, ExcTrilinosError(ierr)); - TrilinosWrappers::types::int_type *diag_find = std::find(col_indices, - col_indices+num_entries,local_row); - TrilinosWrappers::types::int_type diag_index = - (TrilinosWrappers::types::int_type)(diag_find - col_indices); + int *diag_find = std::find(col_indices,col_indices+num_entries,local_row); + int diag_index = (int)(diag_find - col_indices); for (TrilinosWrappers::types::int_type j=0; jLRID(static_cast(i)), - trilinos_j = matrix->LCID(static_cast(j)); + int trilinos_i = matrix->LRID(static_cast(i)), + trilinos_j = matrix->LCID(static_cast(j)); TrilinosScalar value = 0.; // If the data is not on the @@ -798,14 +795,15 @@ namespace TrilinosWrappers // Prepare pointers for extraction // of a view of the row. - TrilinosWrappers::types::int_type nnz_present = matrix->NumMyEntries(trilinos_i); - TrilinosWrappers::types::int_type nnz_extracted; - TrilinosWrappers::types::int_type *col_indices; + int nnz_present = matrix->NumMyEntries(trilinos_i); + int nnz_extracted; + int *col_indices; TrilinosScalar *values; // Generate the view and make // sure that we have not generated // an error. + // TODO Check that col_indices are int and not long long int ierr = matrix->ExtractMyRowView(trilinos_i, nnz_extracted, values, col_indices); Assert (ierr==0, ExcTrilinosError(ierr)); @@ -817,11 +815,9 @@ namespace TrilinosWrappers // look for the value, and then // finally get it. - TrilinosWrappers::types::int_type *el_find = std::find(col_indices, - col_indices + nnz_present, trilinos_j); + int *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - TrilinosWrappers::types::int_type local_col_index = - (TrilinosWrappers::types::int_type)(el_find - col_indices); + int local_col_index = (int)(el_find - col_indices); // This is actually the only // difference to the el(i,j) @@ -850,8 +846,7 @@ namespace TrilinosWrappers { // Extract local indices in // the matrix. - TrilinosWrappers::types::int_type trilinos_i = - matrix->LRID(static_cast(i)), + int trilinos_i = matrix->LRID(static_cast(i)), trilinos_j = matrix->LCID(static_cast(j)); TrilinosScalar value = 0.; @@ -873,9 +868,9 @@ namespace TrilinosWrappers // Prepare pointers for extraction // of a view of the row. - TrilinosWrappers::types::int_type nnz_present = matrix->NumMyEntries(trilinos_i); - TrilinosWrappers::types::int_type nnz_extracted; - TrilinosWrappers::types::int_type *col_indices; + int nnz_present = matrix->NumMyEntries(trilinos_i); + int nnz_extracted; + int *col_indices; TrilinosScalar *values; // Generate the view and make @@ -891,11 +886,9 @@ namespace TrilinosWrappers // Search the index where we // look for the value, and then // finally get it. - TrilinosWrappers::types::int_type *el_find = std::find(col_indices, - col_indices + nnz_present, trilinos_j); + int *el_find = std::find(col_indices, col_indices + nnz_present, trilinos_j); - TrilinosWrappers::types::int_type local_col_index = - (TrilinosWrappers::types::int_type)(el_find - col_indices); + int local_col_index = (int)(el_find - col_indices); // This is actually the only @@ -944,9 +937,8 @@ namespace TrilinosWrappers // get a representation of the // present row - TrilinosWrappers::types::int_type ncols = -1; - TrilinosWrappers::types::int_type local_row = - matrix->LRID(static_cast(row)); + int ncols = -1; + int local_row = matrix->LRID(static_cast(row)); // on the processor who owns this // row, we'll have a non-negative @@ -1014,10 +1006,10 @@ namespace TrilinosWrappers ExcMessage ("Parallel distribution of matrix B and vector V " "does not match.")); - const TrilinosWrappers::types::int_type local_N = inputright.local_size(); - for (TrilinosWrappers::types::int_type i=0; iExtractMyRowView (i, N_entries, new_data); inputright.trilinos_matrix().ExtractMyRowView (i, N_entries, B_data); @@ -1055,9 +1047,9 @@ namespace TrilinosWrappers inputleft.range_partitioner()); Assert (inputleft.domain_partitioner().LinearMap() == true, ExcMessage("Matrix must be partitioned contiguously between procs.")); - for (size_type i=0; i= 0, ExcInternalError()); @@ -1069,9 +1061,9 @@ namespace TrilinosWrappers sparsity_transposed.compress(); transposed_mat.reinit (sparsity_transposed); - for (size_type i=0; iinvec_leng; getrow_comm = B_->getrow->pre_comm; if ( getrow_comm != NULL) @@ -1224,7 +1216,7 @@ namespace TrilinosWrappers const TrilinosWrappers::types::int_type row_local = matrix->RowMap().LID(static_cast(row)); - TrilinosWrappers::types::int_type n_entries, rhs_n_entries; + int n_entries, rhs_n_entries; TrilinosScalar *value_ptr, *rhs_value_ptr; // In debug mode, we want to check @@ -1236,7 +1228,7 @@ namespace TrilinosWrappers // indices is relatively slow compared to // just working with the values. #ifdef DEBUG - TrilinosWrappers::types::int_type *index_ptr, *rhs_index_ptr; + int *index_ptr, *rhs_index_ptr; ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries, rhs_value_ptr, rhs_index_ptr); Assert (ierr == 0, ExcTrilinosError(ierr)); @@ -1270,14 +1262,12 @@ namespace TrilinosWrappers // respective add() function. else { - size_type max_row_length = 0; + int max_row_length = 0; for (size_type row=local_range.first; row < local_range.second; ++row) max_row_length - = std::max (max_row_length, - static_cast(rhs.matrix->NumGlobalEntries(row))); + = std::max (max_row_length,rhs.matrix->NumGlobalEntries(row)); - std::vector column_indices (max_row_length); std::vector values (max_row_length); if (matrix->Filled() == true && rhs.matrix->Filled() == true && @@ -1285,9 +1275,10 @@ namespace TrilinosWrappers for (size_type row=local_range.first; row < local_range.second; ++row) { - const TrilinosWrappers::types::int_type row_local = + std::vector column_indices (max_row_length); + const int row_local = matrix->RowMap().LID(static_cast(row)); - TrilinosWrappers::types::int_type n_entries; + int n_entries; ierr = rhs.matrix->ExtractMyRowCopy (row_local, max_row_length, n_entries, @@ -1306,10 +1297,14 @@ namespace TrilinosWrappers } else { + //TODO check that is normal that column_indices in the if is an + //int while the column_indices in the else is a + //TrilinosWrappers::types::int_type + std::vector column_indices (max_row_length); for (size_type row=local_range.first; row < local_range.second; ++row) { - TrilinosWrappers::types::int_type n_entries; + int n_entries; ierr = rhs.matrix->Epetra_CrsMatrix::ExtractGlobalRowCopy ((TrilinosWrappers::types::int_type)row, max_row_length, n_entries, &values[0], &column_indices[0]); @@ -1375,10 +1370,10 @@ namespace TrilinosWrappers else { double *values; - TrilinosWrappers::types::int_type *indices; - TrilinosWrappers::types::int_type num_entries; + int *indices; + int num_entries; - for (TrilinosWrappers::types::int_type i=0; iNumMyRows(); ++i) + for (int i=0; iNumMyRows(); ++i) { matrix->ExtractMyRowView (i, num_entries, values, indices); for (TrilinosWrappers::types::int_type j=0; jn_cols(); + int ncols; + int colnums = sparsity_pattern->n_cols(); int ierr; ierr = sparsity_pattern->graph->ExtractGlobalRowCopy((TrilinosWrappers::types::int_type)this->a_row, @@ -325,7 +325,7 @@ namespace TrilinosWrappers const size_type first_row = input_row_map.MinMyGID(), last_row = input_row_map.MaxMyGID()+1; - std::vector n_entries_per_row(last_row - first_row); + std::vector n_entries_per_row(last_row - first_row); for (size_type row=first_row; rowFilled() == false) { - TrilinosWrappers::types::int_type nnz_present = graph->NumGlobalIndices(i); - TrilinosWrappers::types::int_type nnz_extracted; + int nnz_present = graph->NumGlobalIndices(i); + int nnz_extracted; TrilinosWrappers::types::int_type *col_indices; // Generate the view and make @@ -488,26 +488,26 @@ namespace TrilinosWrappers { // Prepare pointers for extraction // of a view of the row. - TrilinosWrappers::types::int_type nnz_present = graph->NumGlobalIndices(i); - TrilinosWrappers::types::int_type nnz_extracted; - TrilinosWrappers::types::int_type *col_indices; + int nnz_present = graph->NumGlobalIndices( + static_cast(i)); + int nnz_extracted; + int *col_indices; // Generate the view and make // sure that we have not generated // an error. - int ierr = graph->ExtractMyRowView(trilinos_i, nnz_extracted, - col_indices); + int ierr = graph->ExtractMyRowView(static_cast(trilinos_i), + nnz_extracted, col_indices); Assert (ierr==0, ExcTrilinosError(ierr)); Assert (nnz_present == nnz_extracted, ExcDimensionMismatch(nnz_present, nnz_extracted)); // Search the index - TrilinosWrappers::types::int_type *el_find = std::find(col_indices, - col_indices + nnz_present, trilinos_j); + int *el_find = std::find(col_indices, col_indices + nnz_present, + static_cast(trilinos_j)); - TrilinosWrappers::types::int_type local_col_index = - (TrilinosWrappers::types::int_type)(el_find - col_indices); + int local_col_index = (int)(el_find - col_indices); if (local_col_index == nnz_present) return false; @@ -524,11 +524,11 @@ namespace TrilinosWrappers { size_type local_b=0; TrilinosWrappers::types::int_type global_b=0; - for (size_type i=0; iExtractMyRowView(i, num_entries, indices); + int *indices; + int num_entries; + graph->ExtractMyRowView(static_cast(i), num_entries, indices); for (size_type j=0; j<(size_type)num_entries; ++j) { if (static_cast(std::abs(static_cast(i-indices[j]))) > local_b) @@ -564,10 +564,10 @@ namespace TrilinosWrappers - SparsityPattern::size_type + int SparsityPattern::local_size () const { - TrilinosWrappers::types::int_type n_rows = graph -> NumMyRows(); + int n_rows = graph -> NumMyRows(); return n_rows; } @@ -647,10 +647,10 @@ namespace TrilinosWrappers out << *graph; else { - TrilinosWrappers::types::int_type *indices; - TrilinosWrappers::types::int_type num_entries; + int *indices; + int num_entries; - for (TrilinosWrappers::types::int_type i=0; iNumMyRows(); ++i) + for (int i=0; iNumMyRows(); ++i) { graph->ExtractMyRowView (i, num_entries, indices); for (TrilinosWrappers::types::int_type j=0; jFilled() == true, ExcInternalError()); - for (size_type row=0; rowExtractMyRowView (row, num_entries, indices); for (size_type j=0; j<(size_type)num_entries; ++j) diff --git a/deal.II/source/lac/trilinos_vector.cc b/deal.II/source/lac/trilinos_vector.cc index 3085659ecd..807e73630f 100644 --- a/deal.II/source/lac/trilinos_vector.cc +++ b/deal.II/source/lac/trilinos_vector.cc @@ -235,7 +235,7 @@ namespace TrilinosWrappers for (size_type block=0; block