Question about CPU caches and D context pointers
Dicebot
public at dicebot.lv
Tue Feb 18 12:44:05 PST 2014
On Tuesday, 18 February 2014 at 19:55:20 UTC, Etienne wrote:
> On 2014-02-18 1:13 PM, "Casper Færgemand"
> <shorttail at hotmail.com>" wrote:
>> On Tuesday, 18 February 2014 at 08:11:04 UTC, Dicebot wrote:
>> I tested some prime sieves both in C++ and D. They worked
>> fastest with
>> dynamic arrays with a size matching the L1 cache. I presume the
>> instructions are located elsewhere in the CPU.
>
> Does that mean ubyte[] = new ubyte[4092] is more likely to end
> up in the CPU cache than ubyte[4092] or the inverse ?
It is irrelevant. If data is used continiously it will end up in
cache anyway (assuming it fits), location does not matter. What
is important is if it is already prefetched upon first access,
which is more likely for static arrays as they reside in the same
memory page as their aggregator. Then it will save you from cache
miss upon changing the buffer context frequently.
But if you use the same buffer all the time during continious
code flow it shouldn't impact where exactly it is located as it
simply won't be removed from cache by newer data.
More information about the Digitalmars-d-learn
mailing list