]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use pinned memory when MPI is not GPU aware 15571/head
authorBruno Turcksin <bruno.turcksin@gmail.com>
Sat, 1 Jul 2023 20:44:40 +0000 (20:44 +0000)
committerBruno Turcksin <bruno.turcksin@gmail.com>
Sat, 1 Jul 2023 20:44:40 +0000 (20:44 +0000)
include/deal.II/base/memory_space_data.h
include/deal.II/lac/la_parallel_vector.templates.h

index 82fd3472b19330dcd6e4eb01fb29391382026833..932e076483d5434550490727197f9733a606a8f8 100644 (file)
@@ -64,7 +64,11 @@ namespace MemorySpace
      * Kokkos View owning a host buffer used for MPI communication.
      */
     // FIXME Should we move this somewhere else?
+#if KOKKOS_VERSION < 40000
     Kokkos::View<T *, Kokkos::HostSpace> values_host_buffer;
+#else
+    Kokkos::View<T *, Kokkos::SharedHostPinnedSpace> values_host_buffer;
+#endif
 
     /**
      * Kokkos View owning the data on the @ref GlossDevice "device" (unless @p values_sm_ptr is used).
@@ -105,7 +109,12 @@ namespace MemorySpace
   MemorySpaceData<T, MemorySpace>::MemorySpaceData()
     : values_host_buffer(
         (dealii::internal::ensure_kokkos_initialized(),
+#  if KOKKOS_VERSION < 40000
          Kokkos::View<T *, Kokkos::HostSpace>("host buffer", 0)))
+#  else
+         Kokkos::View<T *, Kokkos::SharedHostPinnedSpace>("host pinned buffer",
+                                                          0)))
+#  endif
     , values(Kokkos::View<T *, typename MemorySpace::kokkos_space>(
         "memoryspace data",
         0))
index 848aa0446a8f67e7fbee49c9691c2b4ea951e935..2b9a2c05290db7f3471c4d28b0fd4af19e47671b 100644 (file)
@@ -963,8 +963,6 @@ namespace LinearAlgebra
       Kokkos::pair<size_type, size_type> range(
         partitioner->locally_owned_size(),
         partitioner->locally_owned_size() + partitioner->n_ghost_indices());
-      if (data.values_host_buffer.size() > 0)
-        Kokkos::deep_copy(Kokkos::subview(data.values_host_buffer, range), 0);
       if (data.values.size() > 0)
         Kokkos::deep_copy(Kokkos::subview(data.values, range), 0);
 
@@ -1015,8 +1013,13 @@ namespace LinearAlgebra
           // uses a view of the array and thus we need the data on the host to
           // outlive the scope of the function.
           data.values_host_buffer =
+#    if KOKKOS_VERSION < 40000
             Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
                                                 data.values);
+#    else
+            Kokkos::create_mirror_view_and_copy(Kokkos::SharedHostPinnedSpace{},
+                                                data.values);
+#    endif
           partitioner->import_from_ghosted_array_start(
             operation,
             communication_channel,
@@ -1158,8 +1161,13 @@ namespace LinearAlgebra
           // uses a view of the array and thus we need the data on the host to
           // outlive the scope of the function.
           data.values_host_buffer =
+#    if KOKKOS_VERSION < 40000
             Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace{},
                                                 data.values);
+#    else
+            Kokkos::create_mirror_view_and_copy(Kokkos::SharedHostPinnedSpace{},
+                                                data.values);
+#    endif
 
           partitioner->export_to_ghosted_array_start<Number, MemorySpace::Host>(
             communication_channel,

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.