Parallel

Performance Portable C++

Source Code Accompanies This Article. Download It Now.

Performance portability means that code can achieve good performance across a range of computer architectures while maintaining a single body of source code.

STL versus Naked Pointers

I initially ran the benchmarks for this article using STL vectors to store data, but was curious how the STL performance compared to using naked pointers. Listing Five (available online) uses the restrict keyword with pointers in place of STL vectors.

In Figures 5, 6, and 7, I plot the ratio of the Pointer time to the STL time for the Triangle, Quadrilateral, and Brick benchmarks, respectively (a value less than 1 means the naked pointers are faster). The Quadrilateral benchmark results show that the pathscale 3.0 compiler on the Opteron ran 32 percent faster on average when using restricted pointers instead of the STL. On the other hand, the g++ compiler ran slightly faster on every benchmark configuration when using the STL. I had to omit the XlC compiler from this comparison because of overly aggressive optimizations that occurred when using pointers.

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task.
However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Video

This month's Dr. Dobb's Journal

This month,
Dr. Dobb's Journal is devoted to mobile programming. We introduce you to Apple's new Swift programming language, discuss the perils of being the third-most-popular mobile platform, revisit SQLite on Android
, and much more!