]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix Tpetra for newer Trilinos 15235/head
authorDaniel Arndt <arndtd@ornl.gov>
Wed, 17 May 2023 20:55:21 +0000 (16:55 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Wed, 17 May 2023 20:56:28 +0000 (16:56 -0400)
include/deal.II/lac/trilinos_tpetra_vector.templates.h
include/deal.II/lac/vector_element_access.h

index c937f9292ad511de05d9b7852131477e42519cab..ca0c37c0d1d09142a724518e985a89c3b7d39cc0 100644 (file)
@@ -208,17 +208,26 @@ namespace LinearAlgebra
         tpetra_export.getSourceMap());
 
       {
+#  if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+        auto x_2d = source_vector.template getLocalView<Kokkos::HostSpace>(
+          Tpetra::Access::ReadWrite);
+#  else
         source_vector.template sync<Kokkos::HostSpace>();
         auto x_2d = source_vector.template getLocalView<Kokkos::HostSpace>();
+#  endif
         auto x_1d = Kokkos::subview(x_2d, Kokkos::ALL(), 0);
+#  if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
         source_vector.template modify<Kokkos::HostSpace>();
+#  endif
         const size_t localLength = source_vector.getLocalLength();
         auto         values_it   = V.begin();
         for (size_t k = 0; k < localLength; ++k)
           x_1d(k) = *values_it++;
+#  if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
         source_vector.template sync<
           typename Tpetra::Vector<Number, int, types::signed_global_dof_index>::
             device_type::memory_space>();
+#  endif
       }
       if (operation == VectorOperation::insert)
         vector->doExport(source_vector, tpetra_export, Tpetra::REPLACE);
@@ -331,18 +340,27 @@ namespace LinearAlgebra
     {
       AssertIsFinite(a);
 
+#  if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+      auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>(
+        Tpetra::Access::ReadWrite);
+#  else
       vector->template sync<Kokkos::HostSpace>();
       auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>();
+#  endif
       auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+#  if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
       vector->template modify<Kokkos::HostSpace>();
+#  endif
       const size_t localLength = vector->getLocalLength();
       for (size_t k = 0; k < localLength; ++k)
         {
           vector_1d(k) += a;
         }
+#  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
     }
 
 
@@ -643,9 +661,14 @@ namespace LinearAlgebra
       else
         out.setf(std::ios::fixed, std::ios::floatfield);
 
+#  if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+      auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>(
+        Tpetra::Access::ReadOnly);
+#  else
       vector->template sync<Kokkos::HostSpace>();
       auto vector_2d = vector->template getLocalView<Kokkos::HostSpace>();
-      auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+#  endif
+      auto         vector_1d    = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
       const size_t local_length = vector->getLocalLength();
 
       if (across)
index 62332e8a04d9771d18010206a0c432ddadd4bd3a..901d16b7153c39595891b4a20fff649676318c9b 100644 (file)
@@ -163,15 +163,24 @@ namespace internal
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
 
+#    if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+    auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>(
+      Tpetra::Access::ReadWrite);
+#    else
     vector.template sync<Kokkos::HostSpace>();
     auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>();
+#    endif
     auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
+#    if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
     // We're going to modify the data on host.
     vector.template modify<Kokkos::HostSpace>();
+#    endif
     vector_1d(trilinos_i) += value;
+#    if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
     vector.template sync<
       typename Tpetra::Vector<NumberType, int, types::signed_global_dof_index>::
         device_type::memory_space>();
+#    endif
   }
 
 
@@ -190,15 +199,24 @@ namespace internal
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
 
+#    if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+    auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>(
+      Tpetra::Access::ReadWrite);
+#    else
     vector.template sync<Kokkos::HostSpace>();
     auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>();
+#    endif
     auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
     // We're going to modify the data on host.
+#    if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
     vector.template modify<Kokkos::HostSpace>();
+#    endif
     vector_1d(trilinos_i) = value;
+#    if !DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
     vector.template sync<
       typename Tpetra::Vector<NumberType, int, types::signed_global_dof_index>::
         device_type::memory_space>();
+#    endif
   }
 
 
@@ -216,10 +234,14 @@ namespace internal
       vector.getMap()->getLocalElement(
         static_cast<TrilinosWrappers::types::int_type>(i));
 
+#    if DEAL_II_TRILINOS_VERSION_GTE(13, 2, 0)
+    auto vector_2d =
+      vector.template getLocalView<Kokkos::HostSpace>(Tpetra::Access::ReadOnly);
+#    else
     vector.template sync<Kokkos::HostSpace>();
     auto vector_2d = vector.template getLocalView<Kokkos::HostSpace>();
+#    endif
     auto vector_1d = Kokkos::subview(vector_2d, Kokkos::ALL(), 0);
-    // We're going to modify the data on host.
     return vector_1d(trilinos_i);
   }
 #  endif

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.