Sign in with
Sign up | Sign in
Your question

How to access CPU Cache Data

Tags:
  • Memory
  • Cache
  • CPUs
Last response: in Memory
Share
January 6, 2009 5:10:54 AM

Hi All,
I am working on CPU Memory Cache. I need to implement following operation on CPU Cache memory(i.e. L1 L2 L3 and memory)

1. How to access the data present on Caches like L1, L2 ...
2. How to switch from L1 to L2, L2 to L3 and so on.
3. How to set data on Caches L1, L2 and so on..

Does any API is exist which can be used for performing above operations?
And also for switching any data patterns are there for efficient access the Cache memories?
Waiting for earlist response!

Thanks in advance.

Reagrds,
Suraj

More about : access cpu cache data

January 6, 2009 5:57:35 AM

Not... Exactly. Cache management for L1 (and L2 caches since the Pentium Pro) is usually done by the CPU itself; "accessing data" inside a cache can't be done directly for that reason, and "switching" from a cache level to another is often useless - when it's even possible or relevant (Pentium 4's L2 cache duplicated L1 data). Some data management on caches can be done on some very modern OSes (I think Vista does provide some tools to do so, and Linux too; I don't know how public, stable and/or efficient these APIs are, but they are certainly not something that user-space programs should access).

Distributing data on caches requires assembly programming or OS support, and is very architecture-dependent (a Core2 won't work the same way a P4 did, and an Athlon64 and a Phenom will certainly not work like, say, an Athlon K7).

That's what I could gather, if somebody more experienced knows better...
m
0
l
January 6, 2009 6:48:19 AM

Perhaps you could provide some details on what you are trying to achieve and why that requires manipulating the cache.
m
0
l
January 6, 2009 7:25:36 AM

Hi Mondoman,
Thanks for your reply.

I need to perform following operations on CPU

1) FPU and Integer opeartions on Lx(L1, L2,L3) and Main memory data for ensuring performance of CPU.
2) If you have any idea regarding about data pattern for access/ switching between L1, L2, L3, main memory then please let me know.

Thanks in advance..

Reagrds,
Suraj
m
0
l
January 6, 2009 7:49:33 AM

Hi Mondoman,
Thanks for your reply.

We are trying to forcibly put data into the cache(L1, L2, L3) and then perform different arithmatic operations by accessing data present in the cache.
During this we want to measure the performance of CPU.

I have identified the __mm_prefetch CPU Cache intrinsic, which fetches the line of data from memory that contains the byte specified with the source operand to a location in the cache hierarchy.

please refer to this site for details-

http://www.lrz-muenchen.de/services/software/programmie...

Is this the correct way to access the Cache.

Please let me know if you have any idea regarding the same.

Reagrds,
Suraj
m
0
l
January 6, 2009 10:30:19 PM

Nevermind. The more i read this thread, the less I think I know what I'm talking about. Good luck regardless.
m
0
l
!