[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: C++ optimization help with the creation of temporaries
From: |
edA-qa mort-ora-y |
Subject: |
Re: C++ optimization help with the creation of temporaries |
Date: |
Tue, 29 Mar 2005 10:27:00 +0200 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
Ulrich Eckhardt wrote:
Two things here: I personally prefer implementing binary operators where
there is no main or principal object involved as unbound function instead
of member function. That's a matter of taste though.
Well, I'll try that and see if it helps the optimizer.
for( unsigned i=0; i < dim; i++ )
Ideomatic (but I don't think it's faster here) would be to use 'i!=dim' and
'++i'. Should be in any beginners introduction to iterators and for loops.
The beginner's book was probably different 15 years ago when I learned
the loop. ;)
Finally, one things you could try is to apply (partial) specialisation for
this, unrolling the loop for some cases. Maybe the boost metaprogramming
library might help you in that task, but I'm no expert in that field.
I had tried many variations on that already, and strangely everything I
did by hand (unrolling, specialization, etc.) ended up making it slower.
A last thing I noticed is that sometimes float is faster than double. This
strongly depends on the processor though, so never hard-wire either choice
into your program.
The "rtype" is either a double or long double in my program, and
although I know the float is faster in our program (from testing), it
doesn't have the precision we need (we're borderline needing long double).
--
edA-qa mort-ora-y
Idea Architect
http://disemia.com/