From d6ca6ec8fe3bcf07aca179fe997c7e0dd3a98506 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Fri, 1 Oct 2004 15:28:03 +0000 Subject: [PATCH] Some profiling shows that loops over dim are not always unrolled. Do so by hand for the two most often called functions in Tensor<1,dim>: operator= and operator* (the latter is most often called during matrix assembly). git-svn-id: https://svn.dealii.org/trunk@9687 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/tensor_base.h | 118 +++++++++++++++++++++--- 1 file changed, 106 insertions(+), 12 deletions(-) diff --git a/deal.II/base/include/base/tensor_base.h b/deal.II/base/include/base/tensor_base.h index 7e04a5cf6b..de3535d9c7 100644 --- a/deal.II/base/include/base/tensor_base.h +++ b/deal.II/base/include/base/tensor_base.h @@ -397,17 +397,6 @@ double & Tensor<1,dim>::operator [] (const unsigned int index) -template -inline -Tensor<1,dim> & Tensor<1,dim>::operator = (const Tensor<1,dim> &p) -{ - for (unsigned int i=0; i inline Tensor<1,0> & Tensor<1,0>::operator = (const Tensor<1,0> &) @@ -427,12 +416,72 @@ Tensor<1,0> & Tensor<1,0>::operator = (const Tensor<1,0> &) +template <> +inline +Tensor<1,1> & Tensor<1,1>::operator = (const Tensor<1,1> &p) +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + values[0] = p.values[0]; + return *this; +} + + + +template <> +inline +Tensor<1,2> & Tensor<1,2>::operator = (const Tensor<1,2> &p) +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + values[0] = p.values[0]; + values[1] = p.values[1]; + return *this; +} + + + +template <> +inline +Tensor<1,3> & Tensor<1,3>::operator = (const Tensor<1,3> &p) +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + values[0] = p.values[0]; + values[1] = p.values[1]; + values[2] = p.values[2]; + return *this; +} + + + +template +inline +Tensor<1,dim> & Tensor<1,dim>::operator = (const Tensor<1,dim> &p) +{ + for (unsigned int i=0; i inline bool Tensor<1,dim>::operator == (const Tensor<1,dim> &p) const { for (unsigned int i=0; i & Tensor<1,dim>::operator /= (const double &s) +template <> +inline +double Tensor<1,1>::operator * (const Tensor<1,1> &p) const +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + return (values[0] * p.values[0]); +} + + + +template <> +inline +double Tensor<1,2>::operator * (const Tensor<1,2> &p) const +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + return (values[0] * p.values[0] + + values[1] * p.values[1]); +} + + + +template <> +inline +double Tensor<1,3>::operator * (const Tensor<1,3> &p) const +{ + // unroll by hand since this is a + // frequently called function and + // some compilers don't want to + // always unroll the loop in the + // general template + return (values[0] * p.values[0] + + values[1] * p.values[1] + + values[2] * p.values[2]); +} + + + template inline double Tensor<1,dim>::operator * (const Tensor<1,dim> &p) const -- 2.39.5