DRAFT : GPU memory validity backtrace #4845
Draft
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.
This is for discussion for now. I'm not sure where is the best place to put something like this.
@camierjs This adds a debug tool specifically to be used in conjunction with the
debug
memory backend. The idea is that if you get anMmuError
while running your program with thedebug
backend, you can preload this library to find why that happens. The debug backend usesmprotect
to enforce validity of memory between host and device which this library intercepts and tracks. The backend has some false positives currently, but as they are fixed I think a tool like this could make thedebug
backend even more useful for debugging GPU code. As far as I am aware, there aren't existing tools for this. Tools like nvidia'scompute-sanitizer
probably aren't useful in this case because it's just going to detect access to unallocated or uninitialized memory, not whether or not values got out of sync between host and device.To use, set
LD_PRELOAD=/path/to/mprotect_trace.so
before executing your program.If it is in the same directory as your present directory, you may need to use
LD_PRELOAD=./mprotect_trace.so
It may be possible to rewrite this using libunwind, but I found it easier to get informative traces with libbacktrace.
Limitations: