Subject: [FFC-dev] FFC now supports FErari optimizations

From: Anders Logg <[email-masked]>
Date: Sat, 1 Apr 2006 09:10:46 -0600

As you may have noticed, Rob and I finally got around to hooking up
FFC with FErari. FErari now functions as an optimizing backend for FFC
so all you need to do to take advantage of the optimizations is to add
the flag -O.

Note that it may take a while to compute the optimization for
complicated forms.

Here's an example for first-degree Lagrange on Triangles for Poisson.

Default code generated by FFC:

  block[0] = 0.5*G0_0_0 + 0.5*G0_0_1 + 0.5*G0_1_0 + 0.5*G0_1_1;
  block[1] = -0.5*G0_0_0 - 0.5*G0_1_0;
  block[2] = -0.5*G0_0_1 - 0.5*G0_1_1;
  block[3] = -0.5*G0_0_0 - 0.5*G0_0_1;
  block[4] = 0.5*G0_0_0;
  block[5] = 0.5*G0_0_1;
  block[6] = -0.5*G0_1_0 - 0.5*G0_1_1;
  block[7] = 0.5*G0_1_0;
  block[8] = 0.5*G0_1_1;

Optimized code generated by FErari/FFC with flag -O:

  block[1] = -0.5*G0_0_0 - 0.5*G0_1_0;
  block[0] = -block[1] + 0.5*G0_0_1 + 0.5*G0_1_1;
  block[7] = -block[1] + -0.5*G0_0_0;
  block[4] = -block[1] + -0.5*G0_1_0;
  block[6] = -block[7] + -0.5*G0_1_1;
  block[8] = -block[6] + -0.5*G0_1_0;
  block[3] = -block[4] + -0.5*G0_0_1;
  block[5] = -block[3] + -0.5*G0_0_0;
  block[2] = -block[8] + -0.5*G0_0_1;

(I have rounded the numbers to get it more readable.)

Rob, shouldn't we also be able to recognize that 0.5*G0_0_0 etc is
computed many times?

/Anders