Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C > determine cache size

Status
Not open for further replies.

CH

Newbie level 6
Newbie level 6
Joined
Feb 8, 2002
Messages
13
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
33
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.
 

linux determine cache size

It is not part of C language. What you are looking for is some dirty low level function. Which RTOS or OS are you using?

Tom
 

linux get dcache icache size

I'll be using w2k and rh linux.

I've found two pieces of C code that do some of what I want, but the first piece is too complex for me to understand correctly. The second is simpler but it breaks into macros written in asm (which i dont understand) to count the number of clock ticks that have passed for a number of read/writes to cache.
 

determining cache size linux

I do not know for w2k, but for RedHat /proc/cpuinfo is a way to go. Do not reinvent the wheel - just use info from /proc file system.

BTW, enter "linux L1 cache size" as keywords in google.

Tom
 

how to calculate cache size using a c program

thx tom. for anyone else interesed in this, look here for a quick tutorial on how to go about coding the solution to this problem.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top