From a557e238cbe3b30ca12afb24b56bc1b8a977f6b5 Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Fri, 2 Nov 2018 19:59:37 +0100 Subject: [PATCH] Use correct template parameters also for 64bit-indices --- include/deal.II/base/index_set.h | 2 +- include/deal.II/lac/read_write_vector.h | 13 +++-- .../deal.II/lac/read_write_vector.templates.h | 14 +++-- .../trilinos_tpetra_communication_pattern.h | 10 ++-- include/deal.II/lac/trilinos_tpetra_vector.h | 7 ++- include/deal.II/lac/vector_element_access.h | 30 ++++++---- source/base/index_set.cc | 28 ++++----- .../trilinos_tpetra_communication_pattern.cc | 22 +++---- source/lac/trilinos_tpetra_vector.cc | 58 ++++++++++++------- 9 files changed, 109 insertions(+), 75 deletions(-) diff --git a/include/deal.II/base/index_set.h b/include/deal.II/base/index_set.h index 2e21fab644..afb90fe2d7 100644 --- a/include/deal.II/base/index_set.h +++ b/include/deal.II/base/index_set.h @@ -448,7 +448,7 @@ public: make_trilinos_map(const MPI_Comm &communicator = MPI_COMM_WORLD, const bool overlapping = false) const; - Tpetra::Map<> + Tpetra::Map make_tpetra_map(const MPI_Comm &communicator = MPI_COMM_WORLD, const bool overlapping = false) const; #endif diff --git a/include/deal.II/lac/read_write_vector.h b/include/deal.II/lac/read_write_vector.h index 0ed6f9d829..b72a95eae2 100644 --- a/include/deal.II/lac/read_write_vector.h +++ b/include/deal.II/lac/read_write_vector.h @@ -615,12 +615,13 @@ namespace LinearAlgebra * used directly. */ void - import(const Tpetra::Vector &tpetra_vector, - const IndexSet & locally_owned_elements, - VectorOperation::values operation, - const MPI_Comm & mpi_comm, - const std::shared_ptr - &communication_pattern); + import( + const Tpetra::Vector &tpetra_vector, + const IndexSet & locally_owned_elements, + VectorOperation::values operation, + const MPI_Comm & mpi_comm, + const std::shared_ptr + &communication_pattern); /** * Import all the elements present in the vector's IndexSet from the input diff --git a/include/deal.II/lac/read_write_vector.templates.h b/include/deal.II/lac/read_write_vector.templates.h index 9da3c32e68..572c28f1de 100644 --- a/include/deal.II/lac/read_write_vector.templates.h +++ b/include/deal.II/lac/read_write_vector.templates.h @@ -509,10 +509,10 @@ namespace LinearAlgebra template void ReadWriteVector::import( - const Tpetra::Vector &vector, - const IndexSet & source_elements, - VectorOperation::values operation, - const MPI_Comm & mpi_comm, + const Tpetra::Vector &vector, + const IndexSet & source_elements, + VectorOperation::values operation, + const MPI_Comm & mpi_comm, const std::shared_ptr &communication_pattern) { @@ -552,9 +552,11 @@ namespace LinearAlgebra "LinearAlgebra::TpetraWrappers::CommunicationPattern.")); } - Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export()); + Tpetra::Export tpetra_export( + tpetra_comm_pattern->get_tpetra_export()); - Tpetra::Vector target_vector(tpetra_export.getSourceMap()); + Tpetra::Vector target_vector( + tpetra_export.getSourceMap()); target_vector.doImport(vector, tpetra_export, Tpetra::REPLACE); const auto *new_values = target_vector.getData().get(); diff --git a/include/deal.II/lac/trilinos_tpetra_communication_pattern.h b/include/deal.II/lac/trilinos_tpetra_communication_pattern.h index a3a23726fe..fd3e074b2a 100644 --- a/include/deal.II/lac/trilinos_tpetra_communication_pattern.h +++ b/include/deal.II/lac/trilinos_tpetra_communication_pattern.h @@ -70,13 +70,13 @@ namespace LinearAlgebra /** * Return the underlying Tpetra::Import object. */ - const Tpetra::Import<> & + const Tpetra::Import & get_tpetra_import() const; /** * Return the underlying Tpetra::Export object. */ - const Tpetra::Export<> & + const Tpetra::Export & get_tpetra_export() const; private: @@ -88,12 +88,14 @@ namespace LinearAlgebra /** * Shared pointer to the Tpetra::Import object used. */ - std::unique_ptr> tpetra_import; + std::unique_ptr> + tpetra_import; /** * Shared pointer to the Tpetra::Export object used. */ - std::unique_ptr> tpetra_export; + std::unique_ptr> + tpetra_export; }; } // end of namespace TpetraWrappers } // end of namespace LinearAlgebra diff --git a/include/deal.II/lac/trilinos_tpetra_vector.h b/include/deal.II/lac/trilinos_tpetra_vector.h index 798248703a..911863c9d9 100644 --- a/include/deal.II/lac/trilinos_tpetra_vector.h +++ b/include/deal.II/lac/trilinos_tpetra_vector.h @@ -310,14 +310,14 @@ namespace LinearAlgebra * Return a const reference to the underlying Trilinos * Tpetra::Vector class. */ - const Tpetra::Vector & + const Tpetra::Vector & trilinos_vector() const; /** * Return a (modifyable) reference to the underlying Trilinos * Tpetra::Vector class. */ - Tpetra::Vector & + Tpetra::Vector & trilinos_vector(); /** @@ -371,7 +371,8 @@ namespace LinearAlgebra /** * Pointer to the actual Tpetra vector object. */ - std::unique_ptr> vector; + std::unique_ptr> + vector; /** * IndexSet of the elements of the last imported vector. diff --git a/include/deal.II/lac/vector_element_access.h b/include/deal.II/lac/vector_element_access.h index 22e541033c..4a81d97fdb 100644 --- a/include/deal.II/lac/vector_element_access.h +++ b/include/deal.II/lac/vector_element_access.h @@ -133,7 +133,8 @@ namespace internal LinearAlgebra::TpetraWrappers::Vector &V) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); @@ -144,7 +145,8 @@ namespace internal // We're going to modify the data on host. vector.modify(); vector_1d(trilinos_i) += value; - vector.sync::device_type::memory_space>(); + vector.sync:: + device_type::memory_space>(); } @@ -157,7 +159,8 @@ namespace internal LinearAlgebra::TpetraWrappers::Vector &V) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); @@ -168,7 +171,8 @@ namespace internal // We're going to modify the data on host. vector.modify(); vector_1d(trilinos_i) += value; - vector.sync::device_type::memory_space>(); + vector.sync:: + device_type::memory_space>(); } @@ -181,7 +185,8 @@ namespace internal LinearAlgebra::TpetraWrappers::Vector &V) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); @@ -192,7 +197,8 @@ namespace internal // We're going to modify the data on host. vector.modify(); vector_1d(trilinos_i) = value; - vector.sync::device_type::memory_space>(); + vector.sync:: + device_type::memory_space>(); } @@ -205,7 +211,8 @@ namespace internal LinearAlgebra::TpetraWrappers::Vector &V) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); @@ -216,7 +223,8 @@ namespace internal // We're going to modify the data on host. vector.modify(); vector_1d(trilinos_i) = value; - vector.sync::device_type::memory_space>(); + vector.sync:: + device_type::memory_space>(); } @@ -228,7 +236,8 @@ namespace internal const types::global_dof_index i) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); @@ -249,7 +258,8 @@ namespace internal const types::global_dof_index i) { // Extract local indices in the vector. - Tpetra::Vector vector = V.trilinos_vector(); + Tpetra::Vector vector = + V.trilinos_vector(); TrilinosWrappers::types::int_type trilinos_i = vector.getMap()->getLocalElement( static_cast(i)); diff --git a/source/base/index_set.cc b/source/base/index_set.cc index 143efc6dc6..d925745485 100644 --- a/source/base/index_set.cc +++ b/source/base/index_set.cc @@ -520,7 +520,7 @@ IndexSet::fill_index_vector(std::vector &indices) const #ifdef DEAL_II_WITH_TRILINOS -Tpetra::Map<> +Tpetra::Map IndexSet::make_tpetra_map(const MPI_Comm &communicator, const bool overlapping) const { @@ -556,29 +556,31 @@ IndexSet::make_tpetra_map(const MPI_Comm &communicator, const bool linear = overlapping ? false : is_ascending_and_one_to_one(communicator); if (linear) - return Tpetra::Map<>(size(), - n_elements(), - 0, + return Tpetra::Map( + size(), + n_elements(), + 0, # ifdef DEAL_II_WITH_MPI - Teuchos::rcp(new Teuchos::MpiComm(communicator)) + Teuchos::rcp(new Teuchos::MpiComm(communicator)) # else - Teuchos::rcp(new Teuchos::Comm()) + Teuchos::rcp(new Teuchos::Comm()) # endif ); else { std::vector indices; fill_index_vector(indices); - std::vector int_indices(indices.size()); + std::vector int_indices(indices.size()); std::copy(indices.begin(), indices.end(), int_indices.begin()); - const Teuchos::ArrayView arr_view(int_indices); - return Tpetra::Map<>(size(), - arr_view, - 0, + const Teuchos::ArrayView arr_view(int_indices); + return Tpetra::Map( + size(), + arr_view, + 0, # ifdef DEAL_II_WITH_MPI - Teuchos::rcp(new Teuchos::MpiComm(communicator)) + Teuchos::rcp(new Teuchos::MpiComm(communicator)) # else - Teuchos::rcp(new Teuchos::Comm()) + Teuchos::rcp(new Teuchos::Comm()) # endif ); } diff --git a/source/lac/trilinos_tpetra_communication_pattern.cc b/source/lac/trilinos_tpetra_communication_pattern.cc index e78dfda3d3..626622d49d 100644 --- a/source/lac/trilinos_tpetra_communication_pattern.cc +++ b/source/lac/trilinos_tpetra_communication_pattern.cc @@ -55,20 +55,22 @@ namespace LinearAlgebra { comm = std::make_shared(communicator); - auto vector_space_vector_map = Teuchos::rcp(new Tpetra::Map<>( - vector_space_vector_index_set.make_tpetra_map(*comm, false))); - auto read_write_vector_map = Teuchos::rcp(new Tpetra::Map<>( - read_write_vector_index_set.make_tpetra_map(*comm, true))); + auto vector_space_vector_map = + Teuchos::rcp(new Tpetra::Map( + vector_space_vector_index_set.make_tpetra_map(*comm, false))); + auto read_write_vector_map = + Teuchos::rcp(new Tpetra::Map( + read_write_vector_index_set.make_tpetra_map(*comm, true))); // Target map is read_write_vector_map // Source map is vector_space_vector_map. This map must have uniquely // owned GID. tpetra_import = - std_cxx14::make_unique>(read_write_vector_map, - vector_space_vector_map); + std_cxx14::make_unique>( + read_write_vector_map, vector_space_vector_map); tpetra_export = - std_cxx14::make_unique>(read_write_vector_map, - vector_space_vector_map); + std_cxx14::make_unique>( + read_write_vector_map, vector_space_vector_map); } @@ -81,7 +83,7 @@ namespace LinearAlgebra - const Tpetra::Import<> & + const Tpetra::Import & CommunicationPattern::get_tpetra_import() const { return *tpetra_import; @@ -89,7 +91,7 @@ namespace LinearAlgebra - const Tpetra::Export<> & + const Tpetra::Export & CommunicationPattern::get_tpetra_export() const { return *tpetra_export; diff --git a/source/lac/trilinos_tpetra_vector.cc b/source/lac/trilinos_tpetra_vector.cc index 264f21da77..f4e3686697 100644 --- a/source/lac/trilinos_tpetra_vector.cc +++ b/source/lac/trilinos_tpetra_vector.cc @@ -42,8 +42,12 @@ namespace LinearAlgebra { template Vector::Vector() - : vector(new Tpetra::Vector(Teuchos::RCP>( - new Tpetra::Map<>(0, 0, Utilities::Trilinos::tpetra_comm_self())))) + : vector(new Tpetra::Vector( + Teuchos::RCP>( + new Tpetra::Map( + 0, + 0, + Utilities::Trilinos::tpetra_comm_self())))) {} @@ -51,7 +55,9 @@ namespace LinearAlgebra template Vector::Vector(const Vector &V) : Subscriptor() - , vector(new Tpetra::Vector(V.trilinos_vector(), Teuchos::Copy)) + , vector(new Tpetra::Vector( + V.trilinos_vector(), + Teuchos::Copy)) {} @@ -59,8 +65,9 @@ namespace LinearAlgebra template Vector::Vector(const IndexSet ¶llel_partitioner, const MPI_Comm &communicator) - : vector(new Tpetra::Vector(Teuchos::rcp(new Tpetra::Map<>( - parallel_partitioner.make_tpetra_map(communicator, false))))) + : vector(new Tpetra::Vector( + Teuchos::rcp(new Tpetra::Map( + parallel_partitioner.make_tpetra_map(communicator, false))))) {} @@ -71,11 +78,12 @@ namespace LinearAlgebra const MPI_Comm &communicator, const bool omit_zeroing_entries) { - Tpetra::Map<> input_map = + Tpetra::Map input_map = parallel_partitioner.make_tpetra_map(communicator, false); if (vector->getMap()->isSameAs(input_map) == false) - vector = std_cxx14::make_unique>( - Teuchos::rcp(new Tpetra::Map<>(input_map))); + vector = std_cxx14::make_unique< + Tpetra::Vector>(Teuchos::rcp( + new Tpetra::Map(input_map))); else if (omit_zeroing_entries == false) { vector->putScalar(0.); @@ -117,15 +125,16 @@ namespace LinearAlgebra { if (size() == V.size()) { - Tpetra::Import<> data_exchange(vector->getMap(), - V.trilinos_vector().getMap()); + Tpetra::Import data_exchange( + vector->getMap(), V.trilinos_vector().getMap()); vector->doImport(V.trilinos_vector(), data_exchange, Tpetra::REPLACE); } else - vector = std_cxx14::make_unique>( + vector = std_cxx14::make_unique< + Tpetra::Vector>( V.trilinos_vector()); } @@ -185,8 +194,10 @@ namespace LinearAlgebra "LinearAlgebra::TpetraWrappers::CommunicationPattern.")); } - Tpetra::Export<> tpetra_export(tpetra_comm_pattern->get_tpetra_export()); - Tpetra::Vector source_vector(tpetra_export.getSourceMap()); + Tpetra::Export tpetra_export( + tpetra_comm_pattern->get_tpetra_export()); + Tpetra::Vector source_vector( + tpetra_export.getSourceMap()); source_vector.template sync(); auto x_2d = source_vector.template getLocalView(); @@ -197,7 +208,8 @@ namespace LinearAlgebra for (size_t k = 0; k < localLength; ++k) x_1d(k) = *values_it++; source_vector.template sync< - typename Tpetra::Vector::device_type::memory_space>(); + typename Tpetra::Vector:: + device_type::memory_space>(); if (operation == VectorOperation::insert) vector->doExport(source_vector, tpetra_export, Tpetra::REPLACE); else if (operation == VectorOperation::add) @@ -254,15 +266,16 @@ namespace LinearAlgebra ExcDimensionMismatch(this->size(), down_V.size())); // TODO: The code doesn't work as expected so we use a workaround. - /*Tpetra::Export<> data_exchange(vector->getMap(), - down_V.trilinos_vector().getMap()); + /*Tpetra::Export + data_exchange(vector->getMap(), down_V.trilinos_vector().getMap()); vector->doExport(down_V.trilinos_vector(), data_exchange, Tpetra::ADD);*/ - Tpetra::Vector dummy(vector->getMap(), false); - Tpetra::Import<> data_exchange(dummy.getMap(), - down_V.trilinos_vector().getMap()); + Tpetra::Vector dummy( + vector->getMap(), false); + Tpetra::Import data_exchange( + dummy.getMap(), down_V.trilinos_vector().getMap()); dummy.doExport(down_V.trilinos_vector(), data_exchange, @@ -322,7 +335,8 @@ namespace LinearAlgebra vector_1d(k) += a; } vector->template sync< - typename Tpetra::Vector::device_type::memory_space>(); + typename Tpetra::Vector:: + device_type::memory_space>(); } @@ -577,7 +591,7 @@ namespace LinearAlgebra template - const Tpetra::Vector & + const Tpetra::Vector & Vector::trilinos_vector() const { return *vector; @@ -586,7 +600,7 @@ namespace LinearAlgebra template - Tpetra::Vector & + Tpetra::Vector & Vector::trilinos_vector() { return *vector; -- 2.39.5