0

I was wondering if I can see the continuous memory image of my system and the hit destination of every memory access while an application is running?

For instance, on a two-dimensional array, I want to see how it is stored in memory, how is it fetched to the caches, and how many accesses are hit in caches and at which level (L1/L2/L3).

Asif
  • 11
  • 5
  • 1
    A 2D array's layout is statically determined at compile time. (Unless you're talking about an array of pointers to arrays, where you `malloc` each row separately or something, but don't do that unless you need different rows to be different lengths, and not just simple triangular). Profiling load/store addresses is a separate problem from finding array layout. – Peter Cordes Mar 09 '18 at 10:07
  • 1
    What CPU architecture (x86? ARM? MIPS?), and what OS? Do you really care where on disk any hard page faults had to be loaded from? Like what sector of what swap partition / file? That's an OS thing, and totally separate from profiling CPU load/store addresses. – Peter Cordes Mar 09 '18 at 10:11
  • Possible duplicate of [Is it possible to know the address of a cache miss?](https://stackoverflow.com/questions/23736999/is-it-possible-to-know-the-address-of-a-cache-miss) (if you're talking about modern Intel x86-64 hardware) – Peter Cordes Mar 09 '18 at 10:15
  • Or wait a minute, you just want to know what level the access hit in, not the address? On Linux on a Skylake CPU, you could use `ocperf.py record mem_load_retired.l1_hit,mem_load_retired.l2_hit,mem_load_retired.l3_hit ./my_program` then `perf report -Mintel` for example, to get a statistical profile of l1/l2/l3 hits. (https://github.com/andikleen/pmu-tools). There are other hardware events for TLB hit/miss, but there aren't many events that track anything about store hit/misses, just loads. https://stackoverflow.com/questions/49042275/intel-pmu-event-for-l1-cache-hit-event. – Peter Cordes Mar 09 '18 at 10:21
  • 1
    may be this will help http://valgrind.org/info/tools.html#cachegrind – Isuru H Mar 09 '18 at 10:32
  • 1
    On a real system, one could write a whole book to answer just this question. I though about writing an answer but there is so much to write and I would probably miss some details. I suggest you either use an architectural simulator or ask a specific question. – Hadi Brais Mar 09 '18 at 18:13
  • Also why did you tag this with "pre-compilation"? This question has nothing to do with precompilation. – Hadi Brais Mar 09 '18 at 19:08

0 Answers0