I am trying to measure L1 cache miss for a code segment using papi_start and stop. I her my ave two issues:

1. After the execution of the program segment, i counted the values by calling read.

papi_start()

do domething()

after read();

papi_stop();

after stop()

the after stop() values are slightly higher that after read() values. What might be the reason here? I am not performing any other task in between.

2. If someone else is also running some other code (and not using papi), will it effect the cache miss count? Will PAPI only count misses for my code segment or all cache misses happened during that time interval?

1. PAPI code is still code that continues to affect the caches. It's natural to see a small increase in cache misses when PAPI code is executing. PAPI_read leaves the counters on, so cache misses can still occur. You shouldn't need to do another read in the after_stop call, because PAPI does an implicit read when it stops the counters. The values from PAPI_stop and after_stop should be the same.2. Yes, if other code is executing, whether or not it is using PAPI, it can affect the cache footprint for your application and causes changes in the measured cache miss value. the counter values themselves are saved between context switches, but that doesn't prevent one application from polluting the cache of another.

2. I should clarify: PAPI will only count L1 cache misses for your code, but the number of cache misses can be affected by what other code is doing. If you are measuring code in process A and get task-switched out while process B does something data intensive that completely flushes L1 cache, the cache will need to be reloaded for process A when it is switched back in, causing a significant increase in misses.