CH
Newbie level 6
determine cache size
hello,
can anyone help me out in writing a C program to determine the size of L1 and L2 cache. I'd also like to be able to determine whether the L1 cache is 1-way, 2-way or 4-way.
What I've done up to now was create a large array, stride through the array many number of times, reading and writing to each location while timing it. Then I would the the exact same thing again without the reading and writing to memory... then use the difference between two results as a way of determining the sizes.
The method I'm using is very inaccurate, and I'm a litle confused on how the whole process of caching occurs ( e.g. the way cache pulls in only 32B lines at a time )
any advice will be much appreciated, thx.
hello,
can anyone help me out in writing a C program to determine the size of L1 and L2 cache. I'd also like to be able to determine whether the L1 cache is 1-way, 2-way or 4-way.
What I've done up to now was create a large array, stride through the array many number of times, reading and writing to each location while timing it. Then I would the the exact same thing again without the reading and writing to memory... then use the difference between two results as a way of determining the sizes.
The method I'm using is very inaccurate, and I'm a litle confused on how the whole process of caching occurs ( e.g. the way cache pulls in only 32B lines at a time )
any advice will be much appreciated, thx.