Pointer usage in terms of cache-centric perspective

Dear experts,

I am now studying some techniques relating to cache-centric programming.

In traditional techniques in C++,
handling of pointers is efficient way to improve performance,
particularly for useful generation of existing objects.

But, pointers entails indirection reference to the objects,
I suppose that sometimes pointers hamper enhancement of performance in terms of cache-efficient programming.
(In this point, contiguous small objects should be created not by pointer reference, but copy?)

I understand that this is case-by-case, probably.
I hope that you give your opinions.

Kind regards

not sure what you are trying to ask.

If you are talking about using pointers as references -- use a reference instead if at all possible. The compiler will do a better job with them, in general.

if you are talking about dynamic memory, it just depends on what you want to accomplish. Pointing back to the first posts in this topic, your own memory manager (even a stupidly simple one) can keep things all in one page of memory (until you need 2 pages, etc, but its clustered for you). You can use a vector and 90% of the work is done for you.

and the captain obvious line just in case: an object with a dynamic memory component (including stl containers!) will not be ideal for the cache if the dynamic memory data is off in another page and the local variables are in the object's page. If you are trying to avoid having that happen, there are ways to do it, but the light memory manager keeps coming to my mind as one of the simplest ways. I am not sure how to force a vector to allocate its memory where you want it, or if it even can do that. I have not tried; when I am optimizing at this level I tend to have arrays instead.
Last edited on
Dear jonnin

I apologize for my ambiguous asking.

What you said in the last section is just my question.

It seems that optimization relating to this topic is technically complicated.
But, I would like to keep in mind that what you told me.

Kind regards
Topic archived. No new replies allowed.