Subject: Re: [ublas] Move Semantics
From: Nasos Iliopoulos (nasos_i_at_[hidden])
Date: 2009-09-12 16:33:06
I will do in the upcoming days. A great benefit that I see coming with this is the elimination of the need for noalias.
But there are some issues we must have in mind:
--Move semantics at this stage are done by copy elision and are NOT GUARANTEED to be implemented by compilers. Preprocessor condition and maybe a test suite will make it sure for everyone. Compiler checks will also do. So this may tern to be a non-issue.
--To take full advantage of move semantics you really need rvalues (&& reference). Those are in the c++0x standard and not fully supported yet by most compilers. It would be nice to keep an experimental implementation since they will eventually be available and will greatly benefit uBlas.
--My last point is that with move semantics, resource stealing, perfect forwarding etc., we might be able to get B = inv(A) + C; with absolutely no unecessary copies. But there may be issues with expression templates (maybe it will be feasible to not need e.ts for rvalue evaluation) and I don't really know if uBlasers want to go that way anytime in the future. I am pretty positive in doing so, but I don't quite feel the weight of such a decision.
Will post my patches in the near future for the copy elision and basic move semantics.
> Date: Sat, 12 Sep 2009 22:11:23 +0200
> From: guwi17_at_[hidden]
> To: ublas_at_[hidden]
> Subject: Re: [ublas] Move Semantics
> Hello Nasos,
> your explanation were very helpful. Could you provide an experimental
> patch and a small test program to demonstrate the effects?
> I suggest to add a preprocessor condition to enable/disable the move
> semantics. This way we could easily add this feature to uBLAS in the
> upcoming release without the risk of breaking someones code.
> Nasos Iliopoulos schrieb:
> > >Take the following:
> > [snip examples on move semantics]
> > So, one unnecssary temporary here. Of course you could do:
> > B=inv(0.5*A); B*=2.0;
> > Lastly note this:
> > matrix<double> B = 2 * inv( .5 * A); will call the copy constructor
> > (not move semantics friendly).
> > move semantics friendly: matrix<double> B ; B=....
> ublas mailing list
> Sent to: nasos_i_at_[hidden]
Bing brings you health info from trusted sources.