]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Some profiling shows that loops over dim are not always unrolled. Do
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Oct 2004 15:28:03 +0000 (15:28 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Fri, 1 Oct 2004 15:28:03 +0000 (15:28 +0000)
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

index 7e04a5cf6b226849888b87bb9f8c26ee066809fd..de3535d9c711303075ce92639d36c8f98a0eb1d3 100644 (file)
@@ -397,17 +397,6 @@ double & Tensor<1,dim>::operator [] (const unsigned int index)
 
 
 
-template <int dim>
-inline
-Tensor<1,dim> & Tensor<1,dim>::operator = (const Tensor<1,dim> &p)
-{
-  for (unsigned int i=0; i<dim; ++i)
-    values[i] = p.values[i];
-  return *this;
-}
-
-
-
 template <>
 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 <int dim>
+inline
+Tensor<1,dim> & Tensor<1,dim>::operator = (const Tensor<1,dim> &p)
+{
+  for (unsigned int i=0; i<dim; ++i)
+    values[i] = p.values[i];
+  return *this;
+}
+
+
+
 template <int dim>
 inline
 bool Tensor<1,dim>::operator == (const Tensor<1,dim> &p) const
 {
   for (unsigned int i=0; i<dim; ++i)
-    if (values[i] != p.values[i]) return false;
+    if (values[i] != p.values[i])
+      return false;
   return true;
 }
 
@@ -491,6 +540,51 @@ Tensor<1,dim> & 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 <int dim>
 inline
 double Tensor<1,dim>::operator * (const Tensor<1,dim> &p) const

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.