-
Notifications
You must be signed in to change notification settings - Fork 32
Use cudf::pack with pinned mr in TableChunk::copy
#966
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
base: main
Are you sure you want to change the base?
Changes from all commits
d7051d4
a2a27c9
3e593a0
b4fc954
9412778
0b00c6e
634c903
6371c76
5fe889b
7769d1f
53d7fe7
aa7668d
a01e7d1
5a9ef07
10c2a53
879662d
e49fe94
ff2b6f8
4b42195
0616180
9661bd0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,4 +16,45 @@ using any_device_resource = cuda::mr::any_resource<cuda::mr::device_accessible>; | |
| using any_host_device_resource = | ||
| cuda::mr::any_resource<cuda::mr::host_accessible, cuda::mr::device_accessible>; | ||
|
|
||
| /** | ||
| * @brief Check whether a type-erased memory resource is host-accessible. | ||
| * | ||
| * Queries the resource's `dynamic_accessibility_property` and returns true if | ||
| * the reported accessibility is host-only or host-and-device. | ||
| * | ||
| * @tparam Properties The property pack of the resource reference. | ||
| * @param mr The memory resource reference to query. | ||
| * @return True if the resource is host-accessible, false otherwise. | ||
| */ | ||
| template <typename... Properties> | ||
| [[nodiscard]] bool is_host_accessible( | ||
| cuda::mr::resource_ref<Properties...> const& mr | ||
| ) noexcept { | ||
| auto const accessibility = | ||
| get_property(mr, cuda::mr::dynamic_accessibility_property{}); | ||
| return accessibility == cuda::mr::__memory_accessibility::__host | ||
| || accessibility == cuda::mr::__memory_accessibility::__host_device; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Check whether a type-erased memory resource is device-accessible. | ||
| * | ||
| * Queries the resource's `dynamic_accessibility_property` and returns true if | ||
| * the reported accessibility is device-only or host-and-device. | ||
| * | ||
| * @tparam Properties The property pack of the resource reference. | ||
| * @param mr The memory resource reference to query. | ||
| * @return True if the resource is device-accessible, false otherwise. | ||
| */ | ||
| template <typename... Properties> | ||
| [[nodiscard]] bool is_device_accessible( | ||
| cuda::mr::resource_ref<Properties...> const& mr | ||
| ) noexcept { | ||
| // See `is_host_accessible` for why the call is unqualified (ADL). | ||
| auto const accessibility = | ||
| get_property(mr, cuda::mr::dynamic_accessibility_property{}); | ||
| return accessibility == cuda::mr::__memory_accessibility::__device | ||
| || accessibility == cuda::mr::__memory_accessibility::__host_device; | ||
| } | ||
|
Contributor
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. You can avoid the dynamic lookup if you
Contributor
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. I think |
||
|
|
||
| } // namespace rapidsmpf | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * SPDX-FileCopyrightText: Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| #include <vector> | ||
|
|
||
| #include <gtest/gtest.h> | ||
|
|
||
| #include <cuda/memory_resource> | ||
|
|
||
| #include <rmm/mr/cuda_async_memory_resource.hpp> | ||
| #include <rmm/mr/cuda_memory_resource.hpp> | ||
|
|
||
| #include <rapidsmpf/memory/host_memory_resource.hpp> | ||
| #include <rapidsmpf/memory/pinned_memory_resource.hpp> | ||
| #include <rapidsmpf/memory/resource_types.hpp> | ||
|
|
||
| namespace { | ||
|
|
||
| std::vector<cuda::mr::any_resource<cuda::mr::host_accessible>> make_host_resources() { | ||
| std::vector<cuda::mr::any_resource<cuda::mr::host_accessible>> resources; | ||
| resources.emplace_back(rapidsmpf::HostMemoryResource{}); | ||
| if (rapidsmpf::is_pinned_memory_resources_supported()) { | ||
| resources.emplace_back(*rapidsmpf::PinnedMemoryResource::make_if_available()); | ||
| } | ||
| return resources; | ||
| } | ||
|
|
||
| std::vector<cuda::mr::any_resource<cuda::mr::device_accessible>> make_device_resources() { | ||
| std::vector<cuda::mr::any_resource<cuda::mr::device_accessible>> resources; | ||
| resources.emplace_back(rmm::mr::cuda_memory_resource{}); | ||
| resources.emplace_back(rmm::mr::cuda_async_memory_resource{}); | ||
| if (rapidsmpf::is_pinned_memory_resources_supported()) { | ||
| resources.emplace_back(*rapidsmpf::PinnedMemoryResource::make_if_available()); | ||
| } | ||
| return resources; | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| TEST(MemoryResourceAccessibility, IsHostAccessible) { | ||
| auto resources = make_host_resources(); | ||
| for (auto& mr : resources) { | ||
| cuda::mr::resource_ref<cuda::mr::host_accessible> ref{mr}; | ||
| EXPECT_TRUE(rapidsmpf::is_host_accessible(ref)); | ||
| // PinnedMemoryResource is host- and device-accessible; the rest are host-only. | ||
| if (cuda::mr::resource_cast<rapidsmpf::PinnedMemoryResource>(&mr) == nullptr) { | ||
| EXPECT_FALSE(rapidsmpf::is_device_accessible(ref)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| TEST(MemoryResourceAccessibility, IsDeviceAccessible) { | ||
| auto resources = make_device_resources(); | ||
| for (auto& mr : resources) { | ||
| cuda::mr::resource_ref<cuda::mr::device_accessible> ref{mr}; | ||
| EXPECT_TRUE(rapidsmpf::is_device_accessible(ref)); | ||
| // PinnedMemoryResource is host- and device-accessible; the rest are device-only. | ||
| if (cuda::mr::resource_cast<rapidsmpf::PinnedMemoryResource>(&mr) == nullptr) { | ||
| EXPECT_FALSE(rapidsmpf::is_host_accessible(ref)); | ||
| } | ||
| } | ||
| } |
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.
Is there really no public way to do this?
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.
Unfortunately no (at least not that I know of)