Wednesday, 20 July 2016

c++ - How to test main memory access time?



Looking for a C/C++ program to test how long it takes to access a fixed piece of memory, specifically in RAM.



How do I ensure testing access time is not of cache or TLB data?



For example, can I "disable" all cache/TLB?



Or can I specify a specific address in RAM to write/read only?




On the other hand, how would I ensure I am only testing cache?



Are there ways to tell the compiler where to save and read from, cache/ram?



For example, is there a well know standard program (in one of these books?) that is know for this test?



I did see this but I do not understand how adjusting the size of the list, you can control whether the memory accesses hit L1 cache, L2 cache, or main memory: measuring latencies of memory



How can one correctly program this test?


Answer




Basically, as the list grows you'll see the performance worsen in steps as another layer of caching is overwhelmed. The idea is simple... if the cache holds the last N units of memory you've accessed, then looping around a buffer of even N+1 units should ensure constant cache misses. (There're more details/caveats in the "measuring latencies of memory" answer you link to in your question).



You should be able to get some idea of the potential size of the the largest cache that might front your RAM from hardware documentation - as long as you operate on more memory than that you should be measuring physical RAM times.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...