I understand, that spatial and temporal locality have an enourmous impact on performance. What I don't understand is how my data structures are stored in these caches? For simplicity, assume the L1 cache has 8 bytes, the L2 16 and the L3 32 bytes. Does that mean that if we have:
std::array<double, 1> x = {1.};
std::array<double, 2> y = {1.,2.};
std::array<double, 4> z = {1.,2.,3.,4.};
And some function calls these arrays, will x be loaded in the L1 cache, y in L2 and z in L3? Or will y - for example be splitted over the L1 and L2 caches??
Will splitting these arrays manualy yield better cache localitly? If I do for example something like:
std::array<std::array<double,2>,2> z;
Will z be splitted across the cache levels when a function calls it?
What about cachelines? these are usualy 64 bytes long - Will splitting my arrays into arrays of arrays of 64 bytes yield better access speed?
std::array<std::array<double,8>,2> u;
I find this subject quite confusing and would appreciate any help