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

Replace thrust::tuple implementation with cuda::std::tuple #262

Merged
merged 5 commits into from
Oct 20, 2023

Conversation

miscco
Copy link
Collaborator

@miscco miscco commented Jul 24, 2023

Our old implementation of tuple has a lot of limitations.

So rather than using the old homegrown version reuse cuda::std::tuple

@miscco miscco requested review from a team as code owners July 24, 2023 14:46
@miscco miscco requested review from alliepiper and gevtushenko and removed request for a team July 24, 2023 14:46
@miscco miscco added feature request New feature or request. thrust For all items related to Thrust. libcu++ For all items related to libcu++ labels Jul 24, 2023
Copy link
Collaborator

@gevtushenko gevtushenko left a comment

Choose a reason for hiding this comment

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

I've noticed a few changes. I haven't finished the review, will continue once the CI is green.

thrust/thrust/tuple.h Show resolved Hide resolved
thrust/thrust/tuple.h Show resolved Hide resolved
thrust/thrust/pair.h Show resolved Hide resolved
thrust/thrust/tuple.h Show resolved Hide resolved
thrust/testing/tuple_transform.cu Outdated Show resolved Hide resolved
@miscco miscco force-pushed the replace_thrust_tuple branch from 4211273 to 2af6a61 Compare September 29, 2023 08:55
@miscco miscco force-pushed the replace_thrust_tuple branch 4 times, most recently from 4aadf81 to 1472180 Compare October 12, 2023 08:12
@miscco miscco requested a review from a team as a code owner October 12, 2023 11:32
@miscco miscco requested review from griwes and removed request for a team October 12, 2023 11:32
@miscco miscco force-pushed the replace_thrust_tuple branch from 0cb8648 to fea0a59 Compare October 13, 2023 18:10
Copy link
Collaborator

@griwes griwes left a comment

Choose a reason for hiding this comment

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

This is great, Thrust's tuple implementation was such an ancient piece of history.

thrust/thrust/tuple.h Show resolved Hide resolved
@miscco miscco force-pushed the replace_thrust_tuple branch 3 times, most recently from 5a93a81 to 93b0eec Compare October 17, 2023 07:33
@miscco miscco requested a review from gevtushenko October 17, 2023 12:39
thrust/thrust/tuple.h Show resolved Hide resolved
@miscco miscco force-pushed the replace_thrust_tuple branch 4 times, most recently from dccc4ec to 9d0ff36 Compare October 19, 2023 08:20
Comment on lines 177 to 178
template<class T0, class T1, class T2, class T3, class T4, class T5, class T6, class T7>
struct tuple_size<tuple<T0, T1, T2, T3, T4, T5, T6, T7, THRUST_NS_QUALIFIER::null_type>> : tuple_size<tuple<T0, T1, T2, T3, T4, T5, T6, T7>> {};
Copy link

@runer112 runer112 Mar 8, 2024

Choose a reason for hiding this comment

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

A bit late to the party, but: why does this only go up to 8 non-null elements (0-7)? Shouldn't this go up to 9 (0-8)? AFAICT the old tuple implementation supported up to 10 items, so shouldn't 9 non-null types plus 1 null type be handled here?

If true, I think this was unfortunately hidden by the testing added in 471b220 falling one element short, as well. There's no test for the case of 9 non-null types followed by thrust::null_type having a tuple size of 9. I believe this would currently (incorrectly) produce the standard tuple size of 10.

Copy link

@runer112 runer112 Mar 8, 2024

Choose a reason for hiding this comment

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

Thinking further, I'm guessing that these specializations were added for compatibility with existing code that fully parameterizes tuple? In that case, since they would be specifiying all 10 parameters and all of these specializations only specify 9, none these specializations would match.

When I made my initial comment, I thought that, while only specifying 9 parameters for all of these specializations seemed odd, it must have been ok because the template parameter defaults specified for tuple would provide thrust::null_type for the 10th. But that was only true of the old tuple definition, in which case this compatibility layer wouldn't be necessary anyway.

tl;dr: In addition to adding the 9 + 1 specialization, I think that all existing specializations (and tests) should be extended from 9 to 10 template parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

😱 Seems like some of them did not make it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But I believe the analysis is not correct, we only need to pass 10 - 1 == 9 arguments.

Note that we always append a null_type which is the missing one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request. libcu++ For all items related to libcu++ thrust For all items related to Thrust.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants