-
Notifications
You must be signed in to change notification settings - Fork 87
[Core][Modes] New buffer object to track underlying mode allocations … #490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## main #490 +/- ##
========================================
Coverage 76.24% 76.24%
========================================
Files 261 256 -5
Lines 19399 19275 -124
========================================
- Hits 14790 14696 -94
+ Misses 4609 4579 -30
|
7a1911f
to
4db9957
Compare
…and how many times they are sliced.
4db9957
to
6fbdf29
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is freaking great, glad we're making memory slices safer ❤️
I have a few comments but overall it looks great!
Co-authored-by: David Medina <[email protected]>
Description
This PR slightly changes how reference to backend memory allocations are counted so they can be more reliably destroyed, and prevent memory access violations via invalidated pointers.
The changes are entirely internal to OCCA and do not change the public API, or alter current behavior of OCCA applications.
Summary of issue:
Currently
modeMemory_t
objects do not track whether they were created by slicing anothermodeMemory_t
object. Consequently, only the originalmodeMemory_t
object can free the underlying device memory allocation, and will do so even if there still existmodeMemory_t
objects referencing the device memory. This results in dangling references.E.g.
This PR addresses this behavior. The new
buffer
objects wrap device memory allocations and track theirmodeMemory_t
references, created via slicing. Thebuffer
and wrapped device allocation are destroyed once their reference count reaches zero.