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

Provide memory_type enum #984

Merged
merged 6 commits into from
Nov 9, 2022
Merged

Conversation

wphicks
Copy link
Contributor

@wphicks wphicks commented Nov 3, 2022

This PR introduces an enum to specify a memory type (e.g. host, device, managed...). This allows us to provide a template parameter which always indicates a valid memory type, which is extensible for possible future memory types, and which is less verbose than alternatives.

The most serious shortcoming of existing alternatives is the possibility of indicating invalid memory states. E.g. by templating on is_device and is_host, we introduce the possible state is_host=false, is_device=false.

Provide an enum class used to distinguish among various memory types.
This allows decoupling of the concept of memory type from a specific
mdspan accessor policy and ensures that templates receive only a
logically-consistent memory type.
@wphicks wphicks requested review from a team as code owners November 3, 2022 18:41
@wphicks wphicks added feature request New feature or request non-breaking Non-breaking change labels Nov 3, 2022
Copy link

@rg20 rg20 left a comment

Choose a reason for hiding this comment

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

LGTM

wphicks added a commit to wphicks/raft that referenced this pull request Nov 3, 2022
As a follow-up to rapidsai#984 which introduces a memory_type enum, this PR
introduces a device_type enum with similar justifications.
@wphicks wphicks mentioned this pull request Nov 3, 2022
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
Copy link
Member

Choose a reason for hiding this comment

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

I really like consolidating the different memory variations into it's own enum. I'm wondering if we should integrate / consolidate this further into the raft::host_device_accessor here? or maybe there's no value in doing that quite yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's certainly worth doing as a follow-up.

@cjnolet
Copy link
Member

cjnolet commented Nov 8, 2022

I know we are all moving fast to try to get things merged in and get boxes checked but I'd like to make sure we don't lose sight of these types of things and end up with multiple strategies for handling different memory types that are somewhat similar but not quite the same across raft and consuming projects.

Unless you think it would be possible to consolidate this with the accessor immediately as a follow-up, can you create a GitHub issue for just to keep it on our radar?

@wphicks
Copy link
Contributor Author

wphicks commented Nov 8, 2022

Yep! Just posted: #994

Copy link
Member

@divyegala divyegala left a comment

Choose a reason for hiding this comment

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

The PR looks very good, but I'd much prefer if we consolidate this type everywhere (mdspan's accessors included). It's not a breaking change to do that since that is not directly exposed to the user, so it's nicer to consolidate new types in one go and not have disparity that adds on tech debt. I imagine the PR will still remain lean.

@wphicks wphicks requested a review from divyegala November 8, 2022 19:22
cpp/include/raft/core/memory_type.hpp Outdated Show resolved Hide resolved
@wphicks
Copy link
Contributor Author

wphicks commented Nov 8, 2022

@gpucibot merge

@rapids-bot rapids-bot bot merged commit e60cd1c into rapidsai:branch-22.12 Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CMake cpp feature request New feature or request non-breaking Non-breaking change
Projects
Development

Successfully merging this pull request may close these issues.

4 participants