Boost logo

Boost Users :

From: Istvan Buki (istvan.buki_at_[hidden])
Date: 2004-08-04 12:32:58


I modified my sample code to take advantage of your suggestion to calculate
the index at compile time. It works perfectly well and the code generated is
faster than my previous version but I still have questions:

1) I'm not sure if this is the right place to ask, if not somebody will
certainly be able to point me into the right direction.
In the assembly code generated (file attached to this mail), there are two
'call' instructions that seem useless to me. Why not inline the single 'movl'
instruction executed as the result of the call?
I'm using g++ 3.3.3 with O2 optimization flag and it is probably a very
compiler-specific question but perhaps I'm missing something obvious here.
 
2) By now you probably guessed that my goal is to produce code for embedded
use. In this environment standard libraries would not be available. Could you
give me some idea how hard it would be to modify the mpl library not to rely
on any standard include and lib? Any pointer on where to start are welcome.

Thank you for your help,
Istvan

On Tuesday 03 August 2004 13:56, David Abrahams wrote:
> Istvan Buki <istvan.buki_at_[hidden]> writes:
> > Hello David,
> >
> > thanks for your clean and simple answer. I also thought about
> > something similar to your answer but I was wondering if there exist
> > some way to calculate that index at compile-time.
>
> Yes there is.
>
> > Looking at the
> > assembly code generated, it doesn't make a big difference to my
> > version where the index values are hard-coded but still... In fact,
> > the question I'm really trying to answer is: what is the price to
> > pay (in term of performance and space) for using an mpl based
> > solution compared to have my array elements initialized by a totally
> > hard-coded function? Up to now what I've found is that my executable
> > is 10% larger and the code is about 4 times slower (again by looking
> > at the assembly code generated).
>
> Have you got all optimizations enabled with full inlining?
> What compiler are you using?
>
> > So, if you can think of a more efficient solution I'm still
> > interested.
>
> You could use
>
> mpl::zip_view<
> mpl::vector2<
> mpl::range_c<0, mpl::size<Descriptors>::value>
> , Descriptors
>
>
>
> as the sequence in your for_each; then each element would contain a
> compile-time index and a descriptor.
>
> HTH,





Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net