-
Notifications
You must be signed in to change notification settings - Fork 247
Store any_resource in device_buffer and device_uvector #2201
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fc0f3c0
Store any_resource in device-resource global mapping
bdice e791a1e
Use const&
bdice 1c3dad9
Revert "Use const&"
bdice 92193f8
Store any_resource in device_buffer
bdice 6e7e098
Add test
bdice 71ba0aa
Merge branch 'main' into containers-any-resource
bdice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: Copyright (c) 2023-2025, NVIDIA CORPORATION. | ||
| * SPDX-FileCopyrightText: Copyright (c) 2023-2026, NVIDIA CORPORATION. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
|
|
@@ -63,6 +63,34 @@ TEST(DefaultTest, GetCurrentDeviceResourceRef) | |
| EXPECT_EQ(mr, rmm::device_async_resource_ref{rmm::mr::detail::initial_resource()}); | ||
| } | ||
|
|
||
| TEST(DefaultTest, SetCurrentDeviceResourceRefFromPointer) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an extra test I wanted to add after #2200. Not buffer related. |
||
| { | ||
| // Construct a cuda_memory_resource | ||
| rmm::mr::cuda_memory_resource cuda_mr{}; | ||
|
|
||
| // Get a pointer to it (device_memory_resource*) | ||
| rmm::mr::device_memory_resource* mr_ptr = &cuda_mr; | ||
|
|
||
| // Set with set_current_device_resource_ref using the pointer | ||
| rmm::mr::set_current_device_resource_ref(mr_ptr); | ||
|
|
||
| // Get the ref with get_current_device_resource_ref | ||
| auto ref = rmm::mr::get_current_device_resource_ref(); | ||
|
|
||
| // Use that ref to allocate | ||
| constexpr std::size_t size{1024}; | ||
| void* ptr = ref.allocate_sync(size); | ||
| EXPECT_NE(ptr, nullptr); | ||
| EXPECT_TRUE(is_properly_aligned(ptr)); | ||
| EXPECT_TRUE(is_device_accessible_memory(ptr)); | ||
|
|
||
| // Deallocate | ||
| ref.deallocate_sync(ptr, size); | ||
|
|
||
| // Reset to initial resource | ||
| rmm::mr::reset_current_device_resource_ref(); | ||
| } | ||
|
|
||
| // Multi-threaded default resource tests | ||
|
|
||
| TEST(DefaultTest, UseCurrentDeviceResource_mt) { spawn(test_get_current_device_resource); } | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.
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 is a breaking change. Should we make the resource
mutableor make this method non-const? I discussed a bit with the CCCL team.The CCCL buffer returns
any_resource const&which requires a copy to be made before the resource (or ref) is usable (constructing a ref and making an allocation are not possible from aconstresource). I would consider that approach but I don’t want to alter the API in that way just yet. It might be better to handle that as we transition to the CCCL buffer type.Uh oh!
There was an error while loading. Please reload this page.
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.
After merging this, I decided to go the other way and use
mutablein PR #2208 to keep thisconst. That seems more aligned with the spirit of how we want to use memory resources. See commit here: 47d7bf4.