]> https://gitweb.dealii.org/ - dealii.git/commitdiff
just copy the content if the layout is the same 16558/head
authorSebastian Kinnewig <kinnewig@ifam.uni-hannover.de>
Mon, 29 Jan 2024 20:12:33 +0000 (21:12 +0100)
committerSebastian Kinnewig <kinnewig@ifam.uni-hannover.de>
Tue, 30 Jan 2024 10:34:07 +0000 (11:34 +0100)
include/deal.II/lac/trilinos_tpetra_vector.templates.h

index d9d9519cb201de80669c6fdff349a1c36a1a2e6a..f1c5a0cc6980b85c0cb5ff2f6c9031b426ef5929 100644 (file)
@@ -289,7 +289,43 @@ namespace LinearAlgebra
       //  - Third case: the vectors have different size.
       if (vector->getMap()->isSameAs(*V.vector->getMap()))
         {
-          *vector = Tpetra::createCopy(*V.vector);
+          // Create a read-only Kokkos view from the source vector
+#  if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+          auto source_vector_2d =
+            V.vector->template getLocalView<Kokkos::HostSpace>(
+              Tpetra::Access::ReadOnly);
+#  else
+          auto source_vector_2d =
+            V.vector->template getLocalView<Kokkos::HostSpace>();
+#  endif
+          auto source_vector_1d =
+            Kokkos::subview(source_vector_2d, Kokkos::ALL(), 0);
+
+          // Create a read/write Kokkos view from the target vector
+#  if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+          auto target_vector_2d =
+            vector->template getLocalView<Kokkos::HostSpace>(
+              Tpetra::Access::ReadWrite);
+#  else
+          vector->template sync<Kokkos::HostSpace>();
+          auto target_vector_2d =
+            vector->template getLocalView<Kokkos::HostSpace>();
+#  endif
+          auto target_vector_1d =
+            Kokkos::subview(target_vector_2d, Kokkos::ALL(), 0);
+#  if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+          vector->template modify<Kokkos::HostSpace>();
+#  endif
+
+          // Copy the data
+          Kokkos::deep_copy(target_vector_1d, source_vector_1d);
+
+#  if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+          vector->template sync<typename Tpetra::Vector<
+            Number,
+            int,
+            types::signed_global_dof_index>::device_type::memory_space>();
+#  endif
         }
       else if (size() == V.size())
         {

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.