]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Portable MatrixFree: Allow initializing host vector
authorDaniel Arndt <arndtd@ornl.gov>
Tue, 20 Aug 2024 19:19:39 +0000 (15:19 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Tue, 20 Aug 2024 20:50:32 +0000 (16:50 -0400)
include/deal.II/matrix_free/portable_matrix_free.h
include/deal.II/matrix_free/portable_matrix_free.templates.h
source/matrix_free/portable_matrix_free.cc
tests/matrix_free_kokkos/matrix_free_device_initialize_vector.cc
tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.mpirun=1.output [moved from tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.with_cuda=on.mpirun=1.output with 100% similarity]
tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.mpirun=2.output
tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.with_cuda=off.mpirun=1.output [deleted file]

index e336c662b50c1e1f6f1c735f4ba8b5678c158923..bd631563edb079462b451e14ca2aa0eff94330af 100644 (file)
@@ -380,10 +380,10 @@ namespace Portable
      * locally owned degrees of freedom and the ghost elements correspond to the
      * (additional) locally relevant dofs.
      */
+    template <typename MemorySpace>
     void
     initialize_dof_vector(
-      LinearAlgebra::distributed::Vector<Number, MemorySpace::Default> &vec)
-      const;
+      LinearAlgebra::distributed::Vector<Number, MemorySpace> &vec) const;
 
     /**
      * Return the colored graph of locally owned active cells.
index f4475662a190d4d3501193bd789bfe0e428af4a2..b782081a8ce23919201986caed1f0a0eda72367e 100644 (file)
@@ -566,9 +566,10 @@ namespace Portable
 
 
   template <int dim, typename Number>
+  template <typename MemorySpace>
   void
   MatrixFree<dim, Number>::initialize_dof_vector(
-    LinearAlgebra::distributed::Vector<Number, MemorySpace::Default> &vec) const
+    LinearAlgebra::distributed::Vector<Number, MemorySpace> &vec) const
   {
     if (partitioner)
       vec.reinit(partitioner);
index 8422260e60367269070645d751762a61836be4bd..4290c2587669b466e6ad880ef6092f888d777195 100644 (file)
@@ -16,7 +16,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
-
+#ifndef DOXYGEN
 
 namespace Portable
 {
@@ -25,6 +25,36 @@ namespace Portable
   template class MatrixFree<2, double>;
   template class MatrixFree<3, float>;
   template class MatrixFree<3, double>;
+
+  template void
+  MatrixFree<2, float>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<float, MemorySpace::Host> &vec) const;
+  template void
+  MatrixFree<2, float>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<float, MemorySpace::Default> &vec) const;
+  template void
+  MatrixFree<2, double>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<double, MemorySpace::Host> &vec) const;
+  template void
+  MatrixFree<2, double>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<double, MemorySpace::Default> &vec)
+    const;
+  template void
+  MatrixFree<3, float>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<float, MemorySpace::Host> &vec) const;
+  template void
+  MatrixFree<3, float>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<float, MemorySpace::Default> &vec) const;
+  template void
+  MatrixFree<3, double>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<double, MemorySpace::Host> &vec) const;
+  template void
+  MatrixFree<3, double>::initialize_dof_vector(
+    LinearAlgebra::distributed::Vector<double, MemorySpace::Default> &vec)
+    const;
+
 } // namespace Portable
 
+#endif
+
 DEAL_II_NAMESPACE_CLOSE
index f7e82faadf99fbca934bd8eda5791f02f7f7320e..d9389e4ce5d572f2293a42069711e289a4f996fe 100644 (file)
 #include "../tests.h"
 
 
-template <typename Number>
+template <typename Number, typename MemorySpace>
 void
-check(const LinearAlgebra::distributed::Vector<Number, MemorySpace::Default>
-                                        &vector,
+check(const LinearAlgebra::distributed::Vector<Number, MemorySpace> &vector,
       const Utilities::MPI::Partitioner &reference_partitioner)
 {
   Assert(vector.get_partitioner()->locally_owned_range() ==
@@ -103,6 +102,8 @@ main(int argc, char **argv)
 
   MPILogInitAll mpi_inilog;
 
+  test<2, 1, LinearAlgebra::distributed::Vector<double, MemorySpace::Host>>();
+
   test<2,
        1,
        LinearAlgebra::distributed::Vector<double, MemorySpace::Default>>();
index 50a6f812215d33bbf6f3e386c42cd956c6760623..5110052051f4e29e42b5e20fd9d65864fce22ada 100644 (file)
@@ -1,4 +1,9 @@
 
+DEAL:0:0::locally owned dofs :
+{[0,14]}
+DEAL:0:0::locally relevant dofs :
+{[0,17], [21,22]}
+DEAL:0:0::OK
 DEAL:0:0::locally owned dofs :
 {[0,14]}
 DEAL:0:0::locally relevant dofs :
@@ -10,4 +15,9 @@ DEAL:1:1::locally owned dofs :
 DEAL:1:1::locally relevant dofs :
 {[2,3], [5,8], 10, [12,24]}
 DEAL:1:1::OK
+DEAL:1:1::locally owned dofs :
+{[15,24]}
+DEAL:1:1::locally relevant dofs :
+{[2,3], [5,8], 10, [12,24]}
+DEAL:1:1::OK
 
diff --git a/tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.with_cuda=off.mpirun=1.output b/tests/matrix_free_kokkos/matrix_free_device_initialize_vector.with_mpi=on.with_p4est=on.with_cuda=off.mpirun=1.output
deleted file mode 100644 (file)
index 274361d..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-DEAL:0:0::locally owned dofs :
-{[0,24]}
-DEAL:0:0::locally relevant dofs :
-{[0,24]}
-DEAL:0:0::OK

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.