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.
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
Callback memory resource #980
Callback memory resource #980
Changes from 34 commits
ea6f54c
ba5a43d
46c6507
eb8f9e1
8f1a62d
e7c8c88
1e2a10c
d2fca0d
63b9690
cdc53e7
e1014d7
f53ccf1
de221d6
e9221fa
f00084c
ecad57f
01e109f
eacaa27
ad46071
3cafa3a
4008617
8dc9eca
392572b
a776631
169fa1f
a647f99
fa22ecb
8d69937
ba3c1bd
c1ba187
9d94861
1933e9a
347dc9c
b32dfa2
02a05d6
f9e445b
d080157
5529ca1
3c73ca1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
AFAICT these methods are being added just for the purpose of the test. I'm not opposed to exposing these functions in the Python API, but that seems like it merits discussion beyond this largely unrelated PR.
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.
I'm also fine if you want to push back here and just get this done, but I wanted to at least have that discussion recorded if so.
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.
I think it's probably a good idea to expose these anyway for users that want to use RMM but not necessarily construct memory owning DeviceBuffers. Also see my comment below.
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.
I'm fine with that. Could we add some explicit tests of these APIs for other memory resources then? It seems awkward that the only test of the
allocate
function of memory allocators (which sounds like a pretty core feature...) would only be tested in this one callback test where we don't even actually validate the allocation.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.
I added a test for
allocate/deallocate
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.
Probably out of scope for this PR, but would it be possible to instead accept a
cdef
function as the allocator (as avoid *
pointer at that point) that wouldn't have these performance implications?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.
That would preclude passing Python functions as the callbacks, which is the primary motivation for the
CallbackMemoryResource
.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.
Correct. I'm not suggesting that we could do it with this same class or in this PR. I'm asking if this is a useful feature for future work and another class
CythonCallbackMemoryResource
(or if there's some way to make this signature polymorphic). Mostly asking if we should open a follow-up issue.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.
Could we actually check the total memory allocation here instead of just looking for printed output?
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.
Not for any arbitrary
base_mr
.My thought here is that this test doesn't need to check that
base_mr
is behaving correctly, or really test what happens inside the callbacks. This test should just ensure that the callbacks are indeed invoked as expected.Maybe there's a better way to do that I'm missing. Modifying a global is one approach I guess?
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.
I think that's a reasonable expectation for the test, but in that case why even have a base mr? The test could remove the actual allocation from the callback entirely. Is calling the allocate function really testing anything other than the fact that you can run arbitrary Python from the callback?
Setting a global would work, but I'm also OK with output capturing for this purpose.
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.
Mainly because it serves as a useful example of how to use
CallbackMemoryResource
, although I realized that probably belongs in the docstring, so I added it there.