Re: Attribute propagation vs. Semantic actions

"Hartmut Kaiser" <[email protected]> Tue, 16 Mar 2010 13:29:13 -0500
Newsgroups gmane.comp.parsers.spirit.devel
Message-ID <[email protected]>
Joel,

> > I've been looking into attribute propagation vs. semantic actions
> > lately. It has come to my attention that attribute propagation is
> > not as efficient as we thought it would be (perhaps due to some
> recent
> > changes and strategies we have incorporated). Here's a test case
> > that does the same thing with attribute propagation and with semantic
> > actions. Just define ATTR_PROPAGATE to choose the former, or undefine
> > for the latter. Here's the printout with attribute propagation:
> 
> [snip]
> >
> > Obviously, the one with semantic actions win. Notice though that
> > on both cases, there's way too much copying. I suspect unwanted
> > copying of the vector. Man, this is unacceptable. We have to fix
> this!
> 
> More info...
> 
> The excessive copying  involves resizing of the vector(attribute).
> Adding a result.reserve(20); at the start gives me:
> 
> Case with semantic actions:
> 
>      construct from char
>      copy construct
>      construct from char
>      copy construct
>      construct from char
>      copy construct
>      construct from char
>      copy construct
>      construct from char
>      copy construct
> 
> The case with attributes just a tad bit more efficient
> than before :-(:
> 
>      default construct
>      construct from char
>      assign
>      copy construct
>      copy construct
>      default construct
>      construct from char
>      assign
>      copy construct
>      copy construct
>      default construct
>      assign
>      construct from char
>      assign
>      copy construct
>      copy construct
>      default construct
>      assign
>      construct from char
>      assign
>      copy construct
>      copy construct
>      default construct
>      assign
>      construct from char
>      assign
>      copy construct
>      copy construct
>      default construct
>      assign

After two simple fixes the attribute version now prints (with a pre-reserved
vector):

construct from char
construct from char
construct from char
construct from char
construct from char

which is absolutely optimal, while the semantic action still prints:

construct from char
copy construct
construct from char
copy construct
construct from char
copy construct
construct from char
copy construct
construct from char
copy construct

Better?

(here are the results without the result.reverse(5):

Attributes:
construct from char
copy construct
copy construct
construct from char
copy construct
copy construct
copy construct
construct from char
copy construct
copy construct
copy construct
copy construct
construct from char
copy construct
copy construct
copy construct
copy construct
copy construct

Semantic actions:
construct from char
copy construct
construct from char
copy construct
copy construct
construct from char
copy construct
copy construct
copy construct
construct from char
copy construct
copy construct
copy construct
copy construct
construct from char

in which case the semantic actions are a tad better). 

Regards Hartmut

---------------
Meet me at BoostCon
www.boostcon.com



> 
> Regards,
> --
> Joel de Guzman
> http://www.boostpro.com
> http://spirit.sf.net
> http://www.facebook.com/djowel
> 
> Meet me at BoostCon
> http://www.boostcon.com/home
> http://www.facebook.com/boostcon
> 
> 
> 
> 
> -----------------------------------------------------------------------
> -------
> Download Intel&#174; Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Spirit-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spirit-devel


------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev