]> https://gitweb.dealii.org/ - dealii.git/commitdiff
add vectorizable type trait
authorDenis Davydov <davydden@gmail.com>
Sat, 23 Feb 2019 18:26:36 +0000 (19:26 +0100)
committerDenis Davydov <davydden@gmail.com>
Sat, 23 Feb 2019 18:26:36 +0000 (19:26 +0100)
include/deal.II/matrix_free/fe_evaluation.h
tests/matrix_free/fe_evaluation_type_traits.cc
tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output

index 4b088f977d17bb6b022898310b8c9979d14ccb4c..3b498f167a64521d7c91caadf48cdc7492bf401f 100644 (file)
@@ -3471,8 +3471,24 @@ namespace internal
   };
 
 
+  // type trait for vector T and Number to see if
+  // we can do vectorized load/save.
+  // for VectorReader and VectorDistributorLocalToGlobal we assume that
+  // if both begin() and local_element()
+  // exist, then begin() + offset == local_element(offset)
+  template <typename T, typename Number>
+  struct vectorizable
+  {
+    static constexpr bool value =
+      has_begin<T>::value && has_local_element<T>::value &&
+      std::is_same<typename T::value_type, Number>::value;
+  };
+
+
+
   // access to generic vectors that have operator ().
   // FIXME: this is wrong for Trilinos/Petsc MPI vectors
+  // where we should first do Partitioner::local_to_global()
   template <typename VectorType,
             typename std::enable_if<!has_local_element<VectorType>::value,
                                     VectorType>::type * = nullptr>
index d3363649aa1864815118cb3c1f19143e658355a3..3655a18f2fad6bb942a081c41889b38a3f312d93 100644 (file)
@@ -129,7 +129,7 @@ main()
                TrilinosWrappers::MPI::Vector>::value
           << std::endl;
 
-  // check has_begin():
+  // check has_begin:
   deallog
     << "has_begin:" << std::endl
     << "LinearAlgebra::distributed::Vector = "
@@ -137,6 +137,20 @@ main()
     << std::endl
     << "TrilinosWrappers::MPI::Vector = "
     << internal::has_begin<TrilinosWrappers::MPI::Vector>::value << std::endl;
+  // check vectorizable:
+  deallog
+    << "vectorizable:" << std::endl
+    << "LinearAlgebra::distributed::Vector<double> && double = "
+    << internal::vectorizable<LinearAlgebra::distributed::Vector<double>,
+                              double>::value
+    << std::endl
+    << "LinearAlgebra::distributed::Vector<double> && float = "
+    << internal::vectorizable<LinearAlgebra::distributed::Vector<double>,
+                              float>::value
+    << std::endl
+    << "TrilinosWrappers::MPI::Vector && double = "
+    << internal::vectorizable<TrilinosWrappers::MPI::Vector, double>::value
+    << std::endl;
 
   deallog << "OK" << std::endl;
 }
index 71bac87207dc316dc26a23a270da2cf1732cb6cb..d514ab7eea0673611143de3d2a9ec59ab1f4ed17 100644 (file)
@@ -13,4 +13,8 @@ DEAL::TrilinosWrappers::MPI::Vector = 0
 DEAL::has_begin:
 DEAL::LinearAlgebra::distributed::Vector = 1
 DEAL::TrilinosWrappers::MPI::Vector = 1
+DEAL::vectorizable:
+DEAL::LinearAlgebra::distributed::Vector<double> && double = 1
+DEAL::LinearAlgebra::distributed::Vector<double> && float = 0
+DEAL::TrilinosWrappers::MPI::Vector && double = 0
 DEAL::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.