Skip to content
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

Add resource_ref versions of get/set_current_device_resource #1598

Merged

Conversation

harrism
Copy link
Member

@harrism harrism commented Jun 27, 2024

Description

Fixes #1597

Adds new get_per_device_resource_ref(), set_per_device_resource_ref() and current_device versions of these, intended to replace get_per_device_resource(). The new functions deal in device_async_resource_ref, while the old functions deal in device_memory_resource pointers. Tests are updated to use the new functions.

Note that I have also added reset_per_device_resource_ref() and reset_current_device_resource_ref() which are necessary because previously we implemented the resetting behavior by passing nullptr to set_current_device_resource(), which doesn't work with resource_ref because it can't refer to nullptr (no such thing as a null reference).

Updates tests to cover the new functionality, and re-enables tests of set_current_device_resource_ref() which were disabled in #1589.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@github-actions github-actions bot added the cpp Pertains to C++ code label Jun 27, 2024
@harrism harrism added feature request New feature or request breaking Breaking change labels Jun 27, 2024
rapids-bot bot pushed a commit that referenced this pull request Jul 2, 2024
Fixes #1444

Refactors mr_ref_tests.hpp and the .cpp files that include it to use a hierarchy of factory classes in which the base class contains a `resource_ref` and the derived classes are templated on the actual resource type and own the MR under test to maintain its lifetime. This way the tests can still be value parameterized (by name) and the test machinery can be type erased. In the future, if CCCL adds an `any_resource` type-erased owning resource container, we can use that to simplify this machinery.

Note that until #1598 merges, this PR necessarily disables (comments out) tests of `set_current_device_resource()`. This is because the test only has a resource_ref, so it can't `set_current_device_resource(ref).` #1598 adds `set_current_device_resource_ref()` which reenables this testing.

Authors:
  - Mark Harris (https://github.com/harrism)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)
  - Bradley Dice (https://github.com/bdice)

URL: #1589
@github-actions github-actions bot added CMake Python Related to RMM Python API conda ci labels Aug 20, 2024
@harrism harrism force-pushed the fea-get_current_device_resource_ref branch from af5998e to a9555c5 Compare August 20, 2024 05:34
@harrism harrism changed the base branch from branch-24.08 to branch-24.10 August 20, 2024 05:35
@github-actions github-actions bot removed CMake Python Related to RMM Python API conda ci labels Aug 20, 2024
@harrism harrism marked this pull request as ready for review August 20, 2024 06:30
@harrism harrism requested a review from a team as a code owner August 20, 2024 06:30
@harrism harrism requested review from rongou and bdice August 20, 2024 06:30
@harrism harrism self-assigned this Aug 20, 2024
@harrism harrism added non-breaking Non-breaking change and removed breaking Breaking change labels Aug 20, 2024
include/rmm/mr/device/per_device_resource.hpp Outdated Show resolved Hide resolved
include/rmm/mr/device/per_device_resource.hpp Outdated Show resolved Hide resolved
include/rmm/mr/device/per_device_resource.hpp Outdated Show resolved Hide resolved
include/rmm/mr/device/per_device_resource.hpp Show resolved Hide resolved
include/rmm/mr/device/per_device_resource.hpp Show resolved Hide resolved
* `get_current_device_resource_ref`, `set_current_device_resource_ref`, and
* `reset_current_device_resource_ref` functions provide the same functionality as their
* `device_memory_resource` counterparts, but with `device_async_resource_ref` objects.
* The raw pointer versions are expected to be deprecated and removed in a future release.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I think, from my reading, that one should either exclusively use the resource_ref set of functions, or the old (to be deprecated) versions.

That is, if one library does set_per_device_resource and another calls get_per_device_resource_ref then the setting from set_per_device_resource is not observed.

Should we mention that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes! Coincidentally I thought of this when I stepped away for a while. Indeed they are completely separate. I could plausibly make set_per_device_resource() also update the ref_map but the other way is not possible.

Really, the intent is to deprecate it anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added mention of non-interchangeability.

include/rmm/mr/device/per_device_resource.hpp Show resolved Hide resolved
Co-authored-by: Lawrence Mitchell <wence@gmx.li>
Copy link
Contributor

@bdice bdice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great review @wence-. You covered all the topics I had in mind, aside from a couple small typos. I’ll approve and let @harrism / @wence- work out the remaining conversations.

include/rmm/mr/device/per_device_resource.hpp Outdated Show resolved Hide resolved
include/rmm/mr/device/per_device_resource.hpp Outdated Show resolved Hide resolved
@harrism harrism added the 5 - DO NOT MERGE Hold off on merging; see PR for details label Aug 21, 2024
@harrism
Copy link
Member Author

harrism commented Aug 21, 2024

Setting do not merge because we need to plan out the refactoring process better first.

@harrism
Copy link
Member Author

harrism commented Aug 28, 2024

/merge

@rapids-bot rapids-bot bot merged commit a42d36d into rapidsai:branch-24.10 Aug 28, 2024
49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cpp Pertains to C++ code feature request New feature or request non-breaking Non-breaking change
Projects
Status: Done
4 participants