How does _mm_prefetch work?

The call _mm_prefetch, as indicated here , preloads the contents from the specified memory location into RAM into the cache line. But is the cache completely under hardware control? Based on which memory (based on spatial / temporal locations) is available for access, the hardware preloaded the contents from memory into the cache. I thought that programmers did not have control over the cache, and this is a completely hardware mechanism.

So, my understanding is wrong, and the cache can really be controlled by us, right?

If it _mm_prefetchcan control what can be cached,

  • Does this mean that it will never be removed from the cache when?

  • What is an equivalent assembly level instruction that works on cache mechanisms?

+4
source share
1 answer

We can always move data to the cache if it is active simply by accessing memory.
We can pre-select var, simply by “touching” it ahead of time, for this we do not need special instructions.

, " ", / , , HW.
.

, - , , : , , , ( X ).
, , , , CPU .

EDIT. @Mysticial , L3 Intel.


PREFETCHT0, PREFETCHT1, PREFETCHT2, PREFETCHTNTA PREFETCHWT1 , _mm_prefetch, , , 1.

3 , 2 .

, , .


1 (, ) .

2 ( ) , (, , ..).

3 , ( ), , prefetch .

+9

Source: https://habr.com/ru/post/1667422/


All Articles