Subject: [FFC-dev] [HG FFC] Use loop to reset element tensor. Bug fix in regression test.py when same file fails for both representations.

From: [email-masked] (FFC)
Date: Fri, 21 Aug 2009 12:49:27 +0200 (CEST)

One or more new changesets pushed to the primary ffc repository.
A short summary of the last three changesets is included below.

changeset:   1621:96ac3d15dc2c4dbbb5c4fdaefbc8581684c43cf2
tag:         tip
user:        "Kristian Oelgaard <[email-masked]>"
date:        Fri Aug 21 11:49:02 2009 +0100
files:       ffc/compiler/compiler.py ffc/compiler/integrals.py ffc/compiler/tensor/tensorgenerator.py ffc/compiler/ufcformat.py test/regression/reference/quadrature/Biharmonic.h test/regression/reference/quadrature/Constant.h test/regression/reference/quadrature/Elasticity.h test/regression/reference/quadrature/Equation.h test/regression/reference/quadrature/FacetIntegrals.h test/regression/reference/quadrature/FunctionOperators.h test/regression/reference/quadrature/Heat.h test/regression/reference/quadrature/Mass.h test/regression/reference/quadrature/MixedPoisson.h test/regression/reference/quadrature/NavierStokes.h test/regression/reference/quadrature/NeumannProblem.h test/regression/reference/quadrature/Optimization.h test/regression/reference/quadrature/Poisson.h test/regression/reference/quadrature/PoissonDG.h test/regression/reference/quadrature/PoissonSystem.h test/regression/reference/quadrature/QuadratureElement.h test/regression/reference/quadrature/ReactionDiffusion.h test/regression/reference/quadrature/StabilisedStokes.h test/regression/reference/quadrature/Stokes.h test/regression/reference/quadrature/SubDomains.h test/regression/reference/quadrature/TensorWeightedPoisson.h test/regression/reference/quadrature/VectorLaplaceGradCurl.h test/regression/reference/tensor/Constant.h test/regression/reference/tensor/Elasticity.h test/regression/reference/tensor/Equation.h test/regression/reference/tensor/FacetIntegrals.h test/regression/reference/tensor/Heat.h test/regression/reference/tensor/Mass.h test/regression/reference/tensor/MixedPoisson.h test/regression/reference/tensor/NavierStokes.h test/regression/reference/tensor/NeumannProblem.h test/regression/reference/tensor/Optimization.h test/regression/reference/tensor/Poisson.h test/regression/reference/tensor/PoissonSystem.h test/regression/reference/tensor/ReactionDiffusion.h test/regression/reference/tensor/StabilisedStokes.h test/regression/reference/tensor/Stokes.h test/regression/reference/tensor/SubDomains.h test/regression/reference/tensor/VectorLaplaceGradCurl.h test/regression/test.py test/unit/test_reduce_operations2.py
description:
Use loop to reset element tensor. Bug fix in regression test.py when same file fails for both representations.

changeset:   1620:d717a46398a7f43ae41bbceee72f19029c2b02ba
user:        "Kristian Oelgaard <[email-masked]>"
date:        Thu Aug 20 15:35:09 2009 +0100
files:       ffc/compiler/quadrature/fraction.py ffc/compiler/quadrature/optimisedquadraturetransformer.py test/unit/test_symbolics.py
description:
Implement __div__ for fractions (quadrature optimisations).

changeset:   1619:235921dd98b9b0322ccf6ec2be1b31c6e77c41b0
user:        "Kristian Oelgaard <[email-masked]>"
date:        Wed Aug 19 15:48:09 2009 +0100
files:       doc/man/man1/ffc.1.gz doc/manual/chapters/manpagecopy.tex doc/manual/ffc-user-manual.pdf
description:
Some updates to the man page.

----------------------------------------------------------------------
For more details, visit http://www.fenics.org/hg/ffc

---

From: Kristian Oelgaard <[email-masked]>
Date: Fri, 21 Aug 2009 12:56:32 +0200

Quoting FFC <[email-masked]>:

> files:       ffc/compiler/compiler.py ffc/compiler/integrals.py
> ffc/compiler/tensor/tensorgenerator.py ffc/compiler/ufcformat.py
> test/regression/reference/quadrature/Biharmonic.h
> test/regression/reference/quadrature/Constant.h
> test/regression/reference/quadrature/Elasticity.h
> test/regression/reference/quadrature/Equation.h
> test/regression/reference/quadrature/FacetIntegrals.h
> test/regression/reference/quadrature/FunctionOperators.h
> test/regression/reference/quadrature/Heat.h
> test/regression/reference/quadrature/Mass.h
> test/regression/reference/quadrature/MixedPoisson.h
> test/regression/reference/quadrature/NavierStokes.h
> test/regression/reference/quadrature/NeumannProblem.h
> test/regression/reference/quadrature/Optimization.h
> test/regression/reference/quadrature/Poisson.h
> test/regression/reference/quadrature/PoissonDG.h
> test/regression/reference/quadrature/PoissonSystem.h
> test/regression/reference/quadrature/QuadratureElement.h
> test/regression/reference/quadrature/ReactionDiffu
>  sion.h test/regression/reference/quadrature/StabilisedStokes.h
> test/regression/reference/quadrature/Stokes.h
> test/regression/reference/quadrature/SubDomains.h
> test/regression/reference/quadrature/TensorWeightedPoisson.h
> test/regression/reference/quadrature/VectorLaplaceGradCurl.h
> test/regression/reference/tensor/Constant.h
> test/regression/reference/tensor/Elasticity.h
> test/regression/reference/tensor/Equation.h
> test/regression/reference/tensor/FacetIntegrals.h
> test/regression/reference/tensor/Heat.h
> test/regression/reference/tensor/Mass.h
> test/regression/reference/tensor/MixedPoisson.h
> test/regression/reference/tensor/NavierStokes.h
> test/regression/reference/tensor/NeumannProblem.h
> test/regression/reference/tensor/Optimization.h
> test/regression/reference/tensor/Poisson.h
> test/regression/reference/tensor/PoissonSystem.h
> test/regression/reference/tensor/ReactionDiffusion.h
> test/regression/reference/tensor/StabilisedStokes.h
> test/regression/reference/tensor/Stokes.h test/regres
>  sion/reference/tensor/SubDomains.h
> test/regression/reference/tensor/VectorLaplaceGradCurl.h
> test/regression/test.py test/unit/test_reduce_operations2.py
> description:

I changed the generated code inside the tabulate_tensor() function, such that we
use a loop:

// Reset values of the element tensor block
for (unsigned int j = 0; j < 10000; j++)
  A[j] = 0;

instead of:

A[0] = 0;
...
A[9999] = 0;

which saves an awful lot of lines for higher order elements.

No loop is generated if the tensor only has one entry e.g., functional:

A[0] = 0;

We can set the limit for when to use one or the other reset method to whatever
we like of course, but most compiler should be able to figure the simple loop
out with no overhead.

Kristian

> files:       ffc/compiler/quadrature/fraction.py
> ffc/compiler/quadrature/optimisedquadraturetransformer.py
> test/unit/test_symbolics.py
> description:
> _______________________________________________
> FFC-dev mailing list
> [email-masked]
> http://www.fenics.org/mailman/listinfo/ffc-dev
>

---

From: "Garth N. Wells" <[email-masked]>
Date: Fri, 21 Aug 2009 12:08:09 +0100

> we like of course, but most compiler should be able to figure the simple loop

I would suggest always using a loop for simple problems. Compilers are 
pretty good with simple loops.

Garth

---

From: Anders Logg <[email-masked]>
Date: Fri, 28 Aug 2009 23:09:13 +0200

> we like of course, but most compiler should be able to figure the simple loop

Would it be good to use std::fill for this?

--
Anders

---

From: Kristian Oelgaard <[email-masked]>
Date: Sat, 29 Aug 2009 14:49:42 +0200

> Would it be good to use std::fill for this?

I don't know how the efficiency between this function and the loop compares, but
it shouldn't be hard to change of course.

Kristian

---

From: Anders Logg <[email-masked]>
Date: Sat, 29 Aug 2009 15:03:22 +0200

> it shouldn't be hard to change of course.

I think GCC will pick the best option (loop, unroll, or other methods)
depending on the size of the array. At least this page claims that is
the case for memset which is the C equivalent of std::fill. I would
think the same is true for std::fill.

http://gcc.gnu.org/gcc-4.3/changes.html

--
Anders