Wednesday, 7 August 2013

virtual member functions are good or bad for locality in modern CPUs?

virtual member functions are good or bad for locality in modern CPUs?

Considering the new CPUs with new instructions for moving and new memory
controllers, if in C++ I have a vector of Derived objects where Derived is
composed of virtual member functions, is this a good or a bad thing for
the locality ?
And what if I have a vector of pointers to the base class Base* where I
store references to derived objects that are 1-2-3 level up from Base ?
Basically dynamic typing applies to both cases, but which one is better
for caching and memory access ?
I have a preference between this 2 but I would like to see a complete
answer on the subject.
There is something new to consider as ground-braking from the hardware
industry in the last 2-3 years ?

No comments:

Post a Comment