Fix read/reset for topdown component #504
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Description
I found that the topdown component does not handle
PAPI_resetandPAPI_readcorrectly. This PR fixes that.I'm developing Caliper, an instrumentation-based profiler. We call
PAPI_readandPAPI_resetat each instrumentation point so that we can properly associate events with the instrumented code region. I noticed that the reset did not appear to work for the topdown events, and looking at the code I found that it was indeed a no-op. I managed to restructure the code so that reset works now, but I'm no expert so please check if I missed anything. Here's what I did:_topdown_startresetted the counters and_topdown_resetwas a no-op. Also,_topdown_readwould just call_topdown_stop, which in turn would close the file descriptors necessary to reset the counters._topdown_read, and_topdown_stopcalls_topdown_read(and closes the FD's)._topdown_reset, and_topdown_startcalls_topdown_reset.That does seem to do the trick for me. Here's example output with a code that alternates STREAM triad and matrix multiply in a loop, which have wildly different topdown stats. Before, the events would not reset and the topdown stats just converge to an overall program average:
With the changes, we now get distinct and reasonable topdown stats for each kernel:
We really want to have individual topdown values for each instrumented code region, so it would be great to get the reset fixed. We're aware that the topdown values can be unreliable for very short regions but that's something we can live with.
I'd appreciate it if we can get this in.
Author Checklist
Why this PR exists. Reference all relevant information, including background, issues, test failures, etc
Commits are self contained and only do one thing
Commits have a header of the form:
module: short descriptionCommits have a body (whenever relevant) containing a detailed description of the addressed problem and its solution
The PR needs to pass all the tests