What's a memory latency program supposed to do anyway?
Measure the performance of various kinds of 'memory' in the system? Which ones would you choose?
- Primary level cache
- Secondary level cache
- Main memory
- Swap memory
Or are you talking about getting the DRAM timing information from the BIOS?
You're not being very clear about what you want to achieve.
--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
You do know that all memory access goes through the primary level cache right?
What I think you're after is
- if primary level cache is a miss, how much longer does it take to get it from secondary cache.
- if the secondary level cache is also a miss, how much longer does it take to get it from main memory.
- if the page in main memory is currently swapped out, how much longer does it take to load a page from disk.
This is going to be pretty hard to do without detailed knowledge of your system. It's also going to require some assembler knowledge IMO, since C doesn't care about caches or swap space (they're all taken care of by the hardware and the OS).
You're also going to need a very accurate clock, because L1 to L2 isn't going to be much.
What are you hoping to gain from knowing this information?
--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
even in assembler this is going to be horrid to do, because assembler doesn't care whether things are in the cache or not, either.
Michael Abrash wrote a lot about timing code, and fast performance code, back when the pentium was new. You could search for him and "Zen timer" for further information. But it's all a bit old now.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.