
On Mon, 8 May 2006, Brian Budge wrote:
Thanks for the ideas guys.
Compile options are like so: g++ -O3 -msse -mfpmath=sse
I tried the metaprogramming technique (which is pretty nifty :) ), and got interesting results.
Basically, it made my += operator run twice as SLOW, while making my + operator run twice as FAST.
I have a feeling that this is all due to the different optimizations that gcc is doing at multiple stages of compilation. For example, it may be doing autovectorization of the simple loop case of +=, which it can't figure out with the metaprogramming technique. I'm still stumped as to why I'm roughly an order of magnitude slower with + than with +=.
Any more insights?
Did you try with -funroll-loops ? I once did a few tests with vectors, one
version with loops and the other with manually unrolled loops, and with
options -O3 -funroll-loops, the generated code was identical. But then
again, that was with g++-3.3.
As for the use of boost::operators, I don't know, I did a small test using
the following, and the generated code with g++-4.0 and g++-4.1 (with
option -O3 -msse -mfpmath=sse and with and without -DUSE_OP) is identical
(diff reports no difference).
#ifdef USE_OP
#include