- changed title to Slow evaluation of vector-shaped Expressions
- edited description
Slow evaluation of vector-shaped Expressions
Issue #939
invalid
In master (today's dev
docker image), interpolation of vector shape Expression
s is significantly slower than with 2017.1.0.r3.
MWE1:
from dolfin import *
mesh = UnitCubeMesh(16, 16, 16)
V = VectorFunctionSpace(mesh, 'CG', 1)
exp = Expression(('1', '2', '3'), degree=1)
t0 = Timer('Zi interpolate')
interpolate(exp, V)
print(t0.stop())
on master: 0.007603146 on stable: 0.004061956
Evaluating a subclassed Expression
with shape (3, 3) on a large mesh, this difference was clearly noticeable. Placing a Timer
inside the eval()
reveals that this function is called dim
times as often on master
as on stable
, while the solution is the same.
MWE2:
from dolfin import *
class TensorExpr(Expression):
def eval(self, values, x):
t0 = Timer('Z call eval')
for i in range(9):
values[i] = i
del t0
def value_shape(self):
return (3, 3)
G = TensorExpr(degree=1) mesh = UnitCubeMesh(16, 16, 16)
V = TensorFunctionSpace(mesh, 'CG', 1)
t0 = Timer('Z interpolate')
u = interpolate(G, V)
del t0
list_timings(TimingClear_keep, [TimingType_wall])
Output stable
:
Z call eval | 98304 3.6987e-06 0.3636
Z interpolate | 1 1.2807 1.2807
Output master
:
Z call eval | 884736 3.8758e-06 3.4291
Z interpolate | 1 11.965 11.965
9x more calls of eval
and time in interpolation
.
Best wishes
Comments (2)
-
reporter -
- changed status to invalid
Thanks for the report. Marking as invalid as this is a FFC issue: https://bitbucket.org/fenics-project/ffc/issues/52.
- Log in to comment