-
Notifications
You must be signed in to change notification settings - Fork 206
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
[REVIEW] Allow construction of cuda_async_memory_resource from existing pool #889
[REVIEW] Allow construction of cuda_async_memory_resource from existing pool #889
Conversation
Can one of the admins verify this patch? |
1 similar comment
Can one of the admins verify this patch? |
This makes me uncomfortable. I don't like having a type that is "sometimes owning, sometimes not owning". I'd rather see a new resource for wrapping an existing |
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.
Mostly doc changes.
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.
Discussed this with @jrhemstad and we don't think we should have classes with unclear ownership of resources like this. Perhaps this class should always own its pool. So if you pass in an existing pool, this class should take ownership, and destroy the pool in its destructor. But we may still need a version of async_memory_resource
that does not own its pool, and if so, then maybe that should be a different class. I'm interested in discussion on this point.
I see, that's a good point. The owning resource could be the Do you have a name in mind for the non-owning class? How about |
Hm, in some sense a resource that wraps an existing The difference is the "upstream" isn't a So we could call it
Also, we should refactor the current
|
Another approach could be to have an owning |
I don't think that's the direction we want to go because that introduces another object that a caller would have to keep alive outside of the usual |
Implemented the idea of cuda_pool_wrapper. Do you think cuda_async_mr should check if the pool which should be owned is a default pool (since it cannot be destroyed), or leave it to the user? If yes, the current check will not be sufficient. It could still be a pool of a different device with access enabled for the current device. Should there be a requirement for the device location of the pool? Does it have to be the same device on which the memory resource is used? |
* @param valid_pool_handle Handle to a CUDA memory pool which will be used to | ||
* serve allocation requests. | ||
*/ | ||
cuda_async_memory_resource(cudaMemPool_t valid_pool_handle) |
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.
Do we still need this ctor with the cuda_pool_wrapper
?
This still feels clunky to me. I think it's mostly because of the name |
Due to open discussion, I'm moving this to the next release. @fkallen can you merge rapidsai:branch-22.02 into your branch in order to target the right branch? |
dffae07
to
2a03700
Compare
@harrism Sorry, I did not focus on this PR. Thanks for reminding me. I have more questions. At the moment I have added the constructor |
I agree, I think the view is sufficient. No need for the constructor that takes ownership. |
…ownership. Update tests
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.
Looks great! Just a few unnecessary blank lines.
Co-authored-by: Mark Harris <[email protected]>
This PR has been labeled |
ok to test |
@fkallen can you fix the style failures? Helps to run clang-format locally (e.g. enable format-on-save). |
I hope this fixes the issues. I could not use |
@fkallen we've merged some major changes from @robertmaynard which now load the symbols for cudaMallocAsync and related functions using |
I have merged your changes. In tests/mr/device/cuda_async_view_mr_tests.cpp I have disabled a test because |
Should probably add that API to the new mechanism and enable the test... |
Thanks @fkallen ! |
@gpucibot merge |
Adds a new MR type
cuda_async_view_memory_resource
which has a constructorcuda_async_view_memory_resource(cudaMemPool_t valid_pool_handle)
. The memory resource will use this pool for allocation and deallocation instead of managing its own pool.Refactors
cuda_async_memory_resource
to have an instance of the above and create it with acudaMemPool_t
that it owns.