std.mixins

dsimcha dsimcha at yahoo.com
Tue Aug 31 13:00:14 PDT 2010


== Quote from Lutger (lutger.blijdestijn at gmail.com)'s article
> Nick Sabalausky wrote:
> > "Lutger" <lutger.blijdestijn at gmail.com> wrote in message
> > news:i5jiap$rvb$1 at digitalmars.com...
> >> dsimcha wrote:
> >>
> >> ...
> >>>> My suggestion is to include a mixin for unrolling loops.
> >>>
> >>> I thought about this.  Simple loop unrolling doesn't seem like a very
> >>> useful
> >>> optimization on modern hardware because branch prediction and pipelining
> >>> have
> >>> gotten so good.
> >
> > We shouldn't forget, D is supposed to be a systems language, so it needs to
> > work well for a variety of embedded systems. We can't assume all CPUs are
> > going to be just as advanced as a modern desktop CPU. Plus, as a systems
> > language, we shouldn't rule out people who have a reason to optimize for
> > lower-end hardware.
> >
> >
> >>>It can still be useful if you also change the loop body a
> >>> little, for example using multiple accumulators to increase instruction
> >>> level
> >>> parallelism,
> >>> but this is hard to write generically.  I can't think of a way to write
> >>> such a
> >>> mixin such that it would be both generic and useful.
> >>
> >> Probably not for performance, but as a utility for metaprogramming I find
> >> it
> >> sometimes convenient.
> >
> > Isn't performance the whole point of loop unrolling? What other use could
> > there be?
> I should have called it 'static foreach'

Ok, now we're talking, so its use would be more for metaprogramming than for
performance optimization?


More information about the Digitalmars-d mailing list