From: Denis Davydov Date: Sat, 23 Feb 2019 18:26:36 +0000 (+0100) Subject: add vectorizable type trait X-Git-Tag: v9.1.0-rc1~323^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=271769536678200e40d90d454d7dbd9bfad55326;p=dealii.git add vectorizable type trait --- diff --git a/include/deal.II/matrix_free/fe_evaluation.h b/include/deal.II/matrix_free/fe_evaluation.h index 4b088f977d..3b498f167a 100644 --- a/include/deal.II/matrix_free/fe_evaluation.h +++ b/include/deal.II/matrix_free/fe_evaluation.h @@ -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 + struct vectorizable + { + static constexpr bool value = + has_begin::value && has_local_element::value && + std::is_same::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 ::value, VectorType>::type * = nullptr> diff --git a/tests/matrix_free/fe_evaluation_type_traits.cc b/tests/matrix_free/fe_evaluation_type_traits.cc index d3363649aa..3655a18f2f 100644 --- a/tests/matrix_free/fe_evaluation_type_traits.cc +++ b/tests/matrix_free/fe_evaluation_type_traits.cc @@ -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::value << std::endl; + // check vectorizable: + deallog + << "vectorizable:" << std::endl + << "LinearAlgebra::distributed::Vector && double = " + << internal::vectorizable, + double>::value + << std::endl + << "LinearAlgebra::distributed::Vector && float = " + << internal::vectorizable, + float>::value + << std::endl + << "TrilinosWrappers::MPI::Vector && double = " + << internal::vectorizable::value + << std::endl; deallog << "OK" << std::endl; } diff --git a/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output b/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output index 71bac87207..d514ab7eea 100644 --- a/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output +++ b/tests/matrix_free/fe_evaluation_type_traits.with_trilinos=true.output @@ -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 = 1 +DEAL::LinearAlgebra::distributed::Vector && float = 0 +DEAL::TrilinosWrappers::MPI::Vector && double = 0 DEAL::OK