|
Proto : |
Subject: Re: [proto] Grouping expressions
From: Eric Niebler (eric_at_[hidden])
Date: 2011-12-30 01:01:38
On 12/29/2011 10:07 AM, Bart Janssens wrote:
> Hi guys,
>
> Currently, we are using the proto operator() overload and grammars to
> "group" expressions together. The result is one big expression that
> consists of several sub-expressions. An example can be found here:
> https://github.com/coolfluid/coolfluid3/blob/master/plugins/UFEM/src/UFEM/NavierStokes.cpp#L93
>
> The problem with this approach is that for example the file above
> takes over 2GB of RAM to compile. I think this is due to the size of
> the expression (the group(...) call starting on line 93 is a single
> expression).
>
> I was wondering if it would be useful to find some other way to treat
> a group of expressions, maybe by using a fusion vector of expressions,
> or even using the new variadic templates of C++11? Could this have a
> significant impact in reducing the compiler memory usage? An extra
> complication is that the groups may be nested. In the example, there
> is a second sort of group inside the element_quadrature call.
Are you certain your problem is caused by using operator() for grouping?
I think this is just a very big expression template, and any syntax you
choose for grouping will result in long compile times and heavy memory
usage.
Can I ask, what version of Boost are you using? I see you #define
BOOST_PROTO_MAX_ARITY to 10 at the top. In recent versions of Proto, 10
is the default. And newer Proto versions already make use of variadic
templates for operator() if available.
Other things to think about: does this really need to be all one big
expression, or can parts of it be broken up and type-erased, as with
spirit::qi::rule?
-- Eric Niebler BoostPro Computing http://www.boostpro.com
Proto list run by eric at boostpro.com