On 31/10/2012 04:59 p.m., Eric Niebler wrote:
Proto expressions build and optimization times are not taken into
>account. There is a considerable number of expression copies made by the
>expression optimization that cannot be avoided by the compiler.
>
Expression copies ... during expression evaluation? I wonder why that's
necessary.

Not during expression evaluation, but during expression optimization. My optimization transform unrolls vector expressions into their component-wise expression equivalents; that generates a number of expressions that have to be held by value and hence copied.

>I will
>continue my research by implementing a custom evaluation context that
>does this optimization 'on the fly', without actually modifying the
>expression.
>
Evaluation contexts are weaker than transforms. If it can't be done with
a transform, it can't be done with a context. I can't tell from the code
fragment what exactly you're doing with the transforms you've written,
or whether they can be improved.

Quoting from my original mail, what I want is to replace the following geometric vector expression:

    p = q + r;

by

    p[0] = q[0] + r[0],
    p[1] = q[1] + r[1],
    ...,
    p[N] = q[N] + r[N],
    p;

It **can** be done with a transform and that's what I did. The optimized proto expression evaluates ~33% faster than the original proto expression.

I believe it can also be done with an evaluation context, that evaluates an expression N times with a component-wise evaluation context. A component-wise evaluation context would be a default context evaluation except that vector terminals are evaluated to one of its scalar components.

Now that my transform finally works as intended, I will clean up the code and upload it somewhere for you and anyone interested to see it.

Agustín K-ballo Bergé.-
http://fusionfenix.com

_______________________________________________
proto mailing list
proto@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/proto

Reply via email to