Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I store data in the processor cache directly? [closed]

I was wondering if there is a way to store data in the data cache of a processor directly, rather than in main memory. I understand that the way caches work is to store the most frequently used data, however, it would make sense to have an assembly directive to do tell the processor, this is going to be a frequently used data. I am using the IA-32 assembly language.

Thanks!

like image 989
user1096294 Avatar asked Dec 13 '11 17:12

user1096294


2 Answers

Depending on the architecture, there are prefetching hints to move data directly into the cache. For ia32 this is the prefetch instruction, which may move data to L1, L2.

On the other hand there are instructions which tell the processor to avoid using the cache, like moventdq, which moves data directly from/to memory.

Edit: Additionally there are instructions to setup memory ranges for specific types of caching algorithms, like write back, write through, write combine or uncachable. See http://en.wikipedia.org/wiki/Memory_type_range_register.

like image 105
Gunther Piez Avatar answered Sep 24 '22 14:09

Gunther Piez


No, you can't access the cache directly in assembly level. Because the cache is "hidden" (L1 and L2) in processor and maybe there's no cache at all.

like image 34
n0p Avatar answered Sep 25 '22 14:09

n0p