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

Allow cudf::type_to_id<T const>() #17831

Open
wants to merge 68 commits into
base: branch-25.02
Choose a base branch
from

Conversation

esoha-nvidia
Copy link
Contributor

Description

Currently, cudf::type_to_id<X> where X is a valid type for converting to a cudf::id only works if X is neither const nor volatile. However, if it has either of those "cv" qualifiers, the function returns type_id::EMPTY.

With this change, return the correct type id no matter the cv-qualifiers.

Checklist

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

raydouglass and others added 10 commits January 23, 2025 15:06
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
Forward-merge branch-25.02 into branch-25.04
@esoha-nvidia esoha-nvidia requested a review from a team as a code owner January 27, 2025 17:47
@esoha-nvidia esoha-nvidia requested review from bdice and shrshi January 27, 2025 17:47
@github-actions github-actions bot added the libcudf Affects libcudf (C++/CUDA) code. label Jan 27, 2025
Copy link

copy-pr-bot bot commented Jan 27, 2025

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@davidwendt davidwendt added 3 - Ready for Review Ready for review by team improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jan 27, 2025
@davidwendt
Copy link
Contributor

/ok to test

@esoha-nvidia
Copy link
Contributor Author

Please wait for CI to pass before merging this! I didn't check it much!

@davidwendt
Copy link
Contributor

/ok to test

@davidwendt
Copy link
Contributor

/ok to test

@davidwendt
Copy link
Contributor

Looks like many compile failures here. Example: https://github.com/rapidsai/cudf/actions/runs/12996716950/job/36246264687?pr=17831#step:8:3511
Looks to be centered on __int128_t but there may be others.
Since branch-25.02 is in burndown I would suggest moving this to 25.04 to give us more time to investigate a viable solution.

@davidwendt
Copy link
Contributor

Are there tests for this function? I would like to add some more!

Tests are in this file:

TYPED_TEST(TypedDoubleDispatcherTest, TypeToId)

This completes the migration to NVKS runners now that all libraries have been tested and rapidsai/shared-workflows#273 has been merged.

xref: rapidsai/build-infra#184

Authors:
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - James Lamb (https://github.com/jameslamb)

URL: rapidsai#17943
@esoha-nvidia
Copy link
Contributor Author

@davidwendt Thanks for the pointer. I've added tests.

Copy link
Contributor

@karthikeyann karthikeyann left a comment

Choose a reason for hiding this comment

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

LGTM 👍

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.

I'm approving this change, as the code looks fine. However, I think it's worth getting more context on the use cases that this solves and/or how it might affect user expectations of cv-qualified types.

This PR drops cv-qualifiers that the user might expect to carry some kind of meaning (though I feel it is unrealistic to assert any meaning for those qualifiers in the context of a libcudf column). Would users of type_to_id<T> expect that a column created with type_to_id<const int> is read-only, for instance? Or some kind of behavior change corresponding to volatile qualifiers? Today, we fail, and I think that's an acceptable position (we don't have type ids that correspond to cv-qualified types).

Does it make sense for cudf to be responsible for dropping cv-qualifiers in type_to_id<T>, or should that requirement fall upon the caller of type_to_id to instead use type_to_id<std::remove_cv_t<T>> if their type may be cv-qualified?

I could envision this PR being just a docs change to state that type_to_id requires non-cv-qualified types.

@davidwendt
Copy link
Contributor

I think this probably falls under
"few things in life are a result of conscious decision instead of a product of circumstance" -JH
I'm ok with this change until we have a reason to distinguish behavior based on cv-qualifiers.

Repeating my suggestion to rebase this on branch-25.04

@esoha-nvidia
Copy link
Contributor Author

@bdice A type id is just a enum value. it's an int. Would would it even mean for an integer literal to be const? All literals are already constants...

If I write a templated function with type T and I want to make it into a cudf column, I'm going to need to use type_to_id<T>. That new column will not be const, even if the type is.

Bikeshed moment here.

esoha-nvidia and others added 4 commits February 7, 2025 11:45
Currently, `cudf::type_to_id<X>` where X is a valid type for converting to a `cudf::id` only works if X is neither `const` nor `volatile`.  However, if it has either of those "cv" qualifiers, the function returns `type_id::EMPTY`.

With this change, return the correct type id no matter the cv-qualifiers.
@esoha-nvidia esoha-nvidia requested review from a team as code owners February 7, 2025 18:45
@github-actions github-actions bot added Python Affects Python cuDF API. CMake CMake build issue Java Affects Java cuDF API. cudf.pandas Issues specific to cudf.pandas cudf.polars Issues specific to cudf.polars pylibcudf Issues specific to the pylibcudf package labels Feb 7, 2025
@vyasr
Copy link
Contributor

vyasr commented Feb 7, 2025

/ok to test

@vyasr
Copy link
Contributor

vyasr commented Feb 8, 2025

Needs a style fix (and unfortunately not one of the fixes that our PR linter can push an autofix for). Please run pre-commit locally and then push up the changes.

@ttnghia
Copy link
Contributor

ttnghia commented Feb 8, 2025

Also need to rebase upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 - Ready for Review Ready for review by team CMake CMake build issue cudf.pandas Issues specific to cudf.pandas cudf.polars Issues specific to cudf.polars improvement Improvement / enhancement to an existing function Java Affects Java cuDF API. libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change pylibcudf Issues specific to the pylibcudf package Python Affects Python cuDF API.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.