From: peterrum Date: Tue, 9 Jul 2019 04:54:01 +0000 (+0200) Subject: Automated template instantiation for VectorizedArray X-Git-Tag: v9.2.0-rc1~1347^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F8383%2Fhead;p=dealii.git Automated template instantiation for VectorizedArray --- diff --git a/cmake/config/template-arguments.in b/cmake/config/template-arguments.in index 3370a92a6c..c968be136e 100644 --- a/cmake/config/template-arguments.in +++ b/cmake/config/template-arguments.in @@ -8,6 +8,10 @@ BOOL := { true; false } // real scalar floating point types REAL_SCALARS := { double; float } +// real scalar floating point types (vectorized) +REAL_SCALARS_VECTORIZED := { @DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED@; } +FLOAT_VECTORIZED := { @DEAL_II_EXPAND_FLOAT_VECTORIZED@; } + // complex scalar types COMPLEX_SCALARS := { @DEAL_II_EXPAND_COMPLEX_SCALARS@; diff --git a/cmake/configure/configure_vectorization.cmake b/cmake/configure/configure_vectorization.cmake new file mode 100644 index 0000000000..aa17a02dba --- /dev/null +++ b/cmake/configure/configure_vectorization.cmake @@ -0,0 +1,40 @@ +## --------------------------------------------------------------------- +## +## Copyright (C) 2019 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE.md at +## the top level directory of deal.II. +## +## --------------------------------------------------------------------- + +# +# Configuration for real scalar vectorization +# + + +SET(DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED "VectorizedArray" "VectorizedArray") +SET(DEAL_II_EXPAND_FLOAT_VECTORIZED "VectorizedArray") + +IF(${DEAL_II_COMPILER_VECTORIZATION_LEVEL} GREATER 0) + SET(DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED + "${DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED}" "VectorizedArray" "VectorizedArray") + SET(DEAL_II_EXPAND_FLOAT_VECTORIZED "${DEAL_II_EXPAND_FLOAT_VECTORIZED}" "VectorizedArray") +ENDIF() + +IF((${DEAL_II_COMPILER_VECTORIZATION_LEVEL} GREATER 1) AND ( DEAL_II_HAVE_AVX OR DEAL_II_HAVE_ALTIVEC)) + SET(DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED + "${DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED}" "VectorizedArray" "VectorizedArray") + SET(DEAL_II_EXPAND_FLOAT_VECTORIZED "${DEAL_II_EXPAND_FLOAT_VECTORIZED}" "VectorizedArray") +ENDIF() + +IF((${DEAL_II_COMPILER_VECTORIZATION_LEVEL} GREATER 2) AND DEAL_II_HAVE_AVX512) + SET(DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED + "${DEAL_II_EXPAND_REAL_SCALARS_VECTORIZED}" "VectorizedArray" "VectorizedArray") + SET(DEAL_II_EXPAND_FLOAT_VECTORIZED "${DEAL_II_EXPAND_FLOAT_VECTORIZED}" "VectorizedArray") +ENDIF() diff --git a/doc/news/changes/minor/20190713PeterMunch b/doc/news/changes/minor/20190713PeterMunch new file mode 100644 index 0000000000..661ec87162 --- /dev/null +++ b/doc/news/changes/minor/20190713PeterMunch @@ -0,0 +1,4 @@ +New: Provide a list of all possible VectorizedArray instances for a given +hardware and optimization level. The list can be used during template instantiation. +
+(Peter Munch, 2019/07/13) diff --git a/source/matrix_free/mapping_info.inst.in b/source/matrix_free/mapping_info.inst.in index 2adf59c3f6..fe47a54bb7 100644 --- a/source/matrix_free/mapping_info.inst.in +++ b/source/matrix_free/mapping_info.inst.in @@ -14,202 +14,38 @@ // --------------------------------------------------------------------- -for (deal_II_dimension : DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; + deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) { - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - float, - VectorizedArray>; -#if deal_II_dimension > 1 - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, + template struct internal::MatrixFreeFunctions::MappingInfo< deal_II_dimension, - float, - VectorizedArray>; -#endif - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>; - - -#if (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)) || \ - (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__ALTIVEC__)) - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - double, - VectorizedArray>; template struct internal::MatrixFreeFunctions::MappingInfoStorage< deal_II_dimension, deal_II_dimension, - float, - VectorizedArray>; -# if deal_II_dimension > 1 - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - float, - VectorizedArray>; -# endif - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; -#endif + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>; - - -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__) - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - float, - VectorizedArray>; -# if deal_II_dimension > 1 - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - double, - VectorizedArray>; +#if deal_II_dimension > 1 template struct internal::MatrixFreeFunctions::MappingInfoStorage< deal_II_dimension - 1, deal_II_dimension, - float, - VectorizedArray>; -# endif - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>; #endif - - -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__) - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - template struct internal::MatrixFreeFunctions:: - MappingInfo>; - - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< + template void internal::MatrixFreeFunctions::MappingInfo< deal_II_dimension, + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>:: + print_memory_consumption(std::ostream &, const TaskInfo &) + const; + template void internal::MatrixFreeFunctions::MappingInfo< deal_II_dimension, - float, - VectorizedArray>; -# if deal_II_dimension > 1 - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - double, - VectorizedArray>; - template struct internal::MatrixFreeFunctions::MappingInfoStorage< - deal_II_dimension - 1, - deal_II_dimension, - float, - VectorizedArray>; -# endif - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; - - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(std::ostream &, const TaskInfo &) - const; - template void internal::MatrixFreeFunctions:: - MappingInfo>:: - print_memory_consumption(ConditionalOStream &, - const TaskInfo &) const; -#endif + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>:: + print_memory_consumption(ConditionalOStream &, + const TaskInfo &) const; } diff --git a/source/matrix_free/matrix_free.inst.in b/source/matrix_free/matrix_free.inst.in index 73b00dcaef..9fe8f0f8fb 100644 --- a/source/matrix_free/matrix_free.inst.in +++ b/source/matrix_free/matrix_free.inst.in @@ -14,412 +14,72 @@ // --------------------------------------------------------------------- -for (deal_II_dimension : DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; deal_II_scalar : REAL_SCALARS) { - template void - internal::MatrixFreeFunctions::ShapeInfo::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - - template void - internal::MatrixFreeFunctions::ShapeInfo::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - } - - - -for (deal_II_dimension : DIMENSIONS) - { - template class MatrixFree>; - template class MatrixFree>; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - } - - - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) - { -#if deal_II_dimension <= deal_II_space_dimension - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); - - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); -#endif - } - - - -for (deal_II_dimension : DIMENSIONS) - { -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__) - template class MatrixFree>; - template class MatrixFree>; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( + template void internal::MatrixFreeFunctions::ShapeInfo:: + reinit( const Quadrature<1> &, const FiniteElement &, const unsigned int); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); -#endif - } - - - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) - { -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__) -# if deal_II_dimension <= deal_II_space_dimension - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); - - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); -# endif -#endif } -for (deal_II_dimension : DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; + deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) { -#if (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)) || \ - (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__ALTIVEC__)) - template class MatrixFree>; template class MatrixFree>; + deal_II_scalar_vectorized::value_type, + deal_II_scalar_vectorized>; - template void - MatrixFree>:: + template void MatrixFree:: print_memory_consumption(std::ostream &) const; - template void - MatrixFree>:: + template void MatrixFree:: print_memory_consumption(ConditionalOStream &) const; - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( + template void MatrixFree:: + internal_reinit( const Mapping &, const std::vector *> &, - const std::vector *> &, + const std::vector< + const AffineConstraints *> &, const std::vector &, const std::vector> &, const AdditionalData &); - template void - MatrixFree>:: - internal_reinit( + template void MatrixFree:: + internal_reinit( const Mapping &, const std::vector *> &, - const std::vector *> &, + const std::vector< + const AffineConstraints *> &, const std::vector &, const std::vector> &, const AdditionalData &); template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( + ShapeInfo::reinit( const Quadrature<1> &, const FiniteElement &, const unsigned int); -#endif } - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; + deal_II_float_vectorized : FLOAT_VECTORIZED) { -#if (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__)) || \ - (DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__ALTIVEC__)) -# if deal_II_dimension <= deal_II_space_dimension - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); - - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); -# endif -#endif - } - - - -for (deal_II_dimension : DIMENSIONS) - { -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__) - template class MatrixFree>; - template class MatrixFree>; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: - print_memory_consumption(std::ostream &) const; - - template void - MatrixFree>:: - print_memory_consumption(ConditionalOStream &) const; - - template void - MatrixFree>:: + template void MatrixFree:: internal_reinit( const Mapping &, const std::vector *> &, @@ -428,8 +88,9 @@ for (deal_II_dimension : DIMENSIONS) const std::vector> &, const AdditionalData &); - template void - MatrixFree>:: + template void MatrixFree:: internal_reinit( const Mapping &, const std::vector *> &, @@ -437,76 +98,17 @@ for (deal_II_dimension : DIMENSIONS) const std::vector &, const std::vector> &, const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void - MatrixFree>:: - internal_reinit( - const Mapping &, - const std::vector *> &, - const std::vector *> &, - const std::vector &, - const std::vector> &, - const AdditionalData &); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); - - template void internal::MatrixFreeFunctions:: - ShapeInfo>::reinit( - const Quadrature<1> &, - const FiniteElement &, - const unsigned int); -#endif } - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS) +for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : SPACE_DIMENSIONS; + deal_II_scalar_vectorized : REAL_SCALARS_VECTORIZED) { -#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__) -# if deal_II_dimension <= deal_II_space_dimension - template bool - MatrixFree>:: - is_supported( - const FiniteElement &); - - template bool - MatrixFree>:: +#if deal_II_dimension <= deal_II_space_dimension + template bool MatrixFree:: is_supported( const FiniteElement &); -# endif #endif }