- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Does the intel compiler supports NRVO (Named Return Value Optimization)? i.e. cheaply returning big objects by value in function signatures, if so are there examples of how this works?
For example I have a type matrix and I favor the following design and signature for obvious performance reasons:
if NRVO is suported then I can rely on the following alternative without any big memory copying performance penalty:
TIA,
Best regards,
Giovanni
Does the intel compiler supports NRVO (Named Return Value Optimization)? i.e. cheaply returning big objects by value in function signatures, if so are there examples of how this works?
For example I have a type matrix and I favor the following design and signature for obvious performance reasons:
[cpp]templateclass tmatrix { void tmatrix::multiply(const tmatrix & b, tmatrix & c) const; // confusing and very unreadable }; // client code tmatrix a, b, c; // ... a.multiply(b, c); // meaning c = a*b[/cpp]
if NRVO is suported then I can rely on the following alternative without any big memory copying performance penalty:
[cpp]templateclass tmatrix { tmatrix tmatrix::operator=(const tmatrix & b) const; // note that returned object is by value! }; // client code tmatrix a, b, c; // ... c = a*b[/cpp]
TIA,
Best regards,
Giovanni
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Giovanni,
(Named) Return Value Optimization (RVO) will be done by Intel® C++ Compiler. There are various examples that demonstrate the omission of the copy-ctor, e.g.:
http://msdn.microsoft.com/en-us/library/ms364057%28v=vs.80%29.aspx
http://en.wikipedia.org/wiki/Return_value_optimization
AFAIK it's on per default and there's no option to turn it off for our compiler. So, it's not possible to make a comparison between turned on RVO an turned off RVO.
The easiest way to verify is to use a debugger and set a break-point on the copy-ctor.
Best regards,
Georg Zitzlsberger
(Named) Return Value Optimization (RVO) will be done by Intel® C++ Compiler. There are various examples that demonstrate the omission of the copy-ctor, e.g.:
http://msdn.microsoft.com/en-us/library/ms364057%28v=vs.80%29.aspx
http://en.wikipedia.org/wiki/Return_value_optimization
AFAIK it's on per default and there's no option to turn it off for our compiler. So, it's not possible to make a comparison between turned on RVO an turned off RVO.
The easiest way to verify is to use a debugger and set a break-point on the copy-ctor.
Best regards,
Georg Zitzlsberger

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page