A compiler should be able to recognize the hot path (perhaps using profile run data) and reorder the code
so that the branch prediction for the size check chooses the hot path. The penalty for the check in the majority
of cases will therefore only be 1 cycle.

Erik Charlebois
Compiler Development, IBM Toronto Lab
Email: erikc@ca.ibm.com



Toon Knapen <toon.knapen@fft.be>
Sent by: glas-bounces@lists.boost.org

02/04/2005 07:44 AM
Please respond to
Generic Linear Algorithm Software

To
Generic Linear Algorithm Software <glas@lists.boost.org>
cc
Subject
[glas] summary: auto-resizing vectors in assignment





The discussion on auto-resizing (or not) vectors in an assignment are
very intense so I tried to summarize the discussion on following page:

http://www.femtown.org/glas/doc/auto_resizing_vector_on_assignment.html

Please let me know if there are some points that I did not cover (we had
some discussions in circles and the same argument was given in different
forms and thus finally the total list of pro's for one or the other
approach are still limited). I will add additional arguments to this
page (so that you don't have to go through the archives the whole time).

Additionally, performance was mentioned a few times and David
(correctly) argumented that the effect on performance was not proven
yet. So I tried a to verify the performance-hit using a very simple test
which copies a large number of vectors. Once the test first verifies the
size before copying the vector, once it directly copies the vector
without verifying the sizes. And the test repeats this a few times.
Although the if test costs a few instructions, it is not certain that
this has an effect on the execution _time_ on intelligent processors
(like they all are now). However I think my test showed that there is
indeed a measureable (albeit small) difference. But actually such things
are exactly why I also invited compiler- and machine-vendors to this
list because they will certainly be able to clarify this issue (using
the knowledge on how their machine/cpu works internally and how the
compiler can optimise the scheduling). Vendors?

toon
_______________________________________________
glas mailing list
glas@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/glas