-
Notifications
You must be signed in to change notification settings - Fork 162
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
[FEA]: CUDA vector types should implement the C++ tuple protocol #1406
Labels
feature request
New feature or request.
Comments
miscco
added a commit
to miscco/cccl
that referenced
this issue
Feb 20, 2024
This specializes the `std::tuple_size` and `std::tuple_element` traits so that they are usable with cuda vector types. We also provide overloads for `std::get`, which together enables structured bindings support in C++17 onwards. Fixes NVIDIA#1406
I have opened a PR that enables full support for the various cuda vector types. That said, there is a significant cost in code size that this carries. We will discuss this in our next team meeting |
miscco
added a commit
to miscco/cccl
that referenced
this issue
Feb 20, 2024
This specializes the `std::tuple_size` and `std::tuple_element` traits so that they are usable with cuda vector types. We also provide overloads for `std::get`, which together enables structured bindings support in C++17 onwards. Fixes NVIDIA#1406
miscco
added a commit
to miscco/cccl
that referenced
this issue
Feb 21, 2024
This specializes the `std::tuple_size` and `std::tuple_element` traits so that they are usable with cuda vector types. We also provide overloads for `std::get`, which together enables structured bindings support in C++17 onwards. Fixes NVIDIA#1406
miscco
added a commit
to miscco/cccl
that referenced
this issue
Apr 2, 2024
This specializes the `std::tuple_size` and `std::tuple_element` traits so that they are usable with cuda vector types. We also provide overloads for `std::get`, which together enables structured bindings support in C++17 onwards. Fixes NVIDIA#1406
miscco
added a commit
that referenced
this issue
Apr 9, 2024
* Implement tuple interface for cuda vector types This specializes the `std::tuple_size` and `std::tuple_element` traits so that they are usable with cuda vector types. We also provide overloads for `std::get`, which together enables structured bindings support in C++17 onwards. Fixes #1406
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this a duplicate?
Area
Not sure
Is your feature request related to a problem? Please describe.
The CUDA types like
int3
defined in<vector_types.h>
represent points. They are definitions in the global namespace and are automatically defined in every CUDA C++ program. There is no way for a CUDA C++ program to prevent their definition because these types participate in fundamental CUDA functionality like kernel launch and built-in variables. These are broadly-useful types with nice names and we are stuck with them in the global namespace.The CUDA vector types are essentially tuples and they should behave like tuples. At the moment, they don't behave like tuples, because CUDA vector types don't implement the tuple protocol [1].
It's possible for third party libraries to implement the tuple protocol for these types themselves, but they must not do so. Firstly, because it is not their responsibility, but more importantly, because these implementations would inevitably collide when such libraries are combined.
CUDA has enhanced C++ support for these vector types in the past when constructors for these types were introduced. Making these types full-fledged tuples that can transparently participate in tuple-based libraries like CuTE and similar also makes sense.
[1] https://en.cppreference.com/w/cpp/utility/tuple/tuple-like
Describe the solution you'd like
I believe that three things are necessary for CUDA vector types to implement the tuple protocol:
get
std::tuple_element
std::tuple_size
.Describe alternatives you've considered
It's possible for third party libraries to implement the solution described above, but they cannot coexist when those libraries are combined in a single program.
Additional context
Many libraries, including the C++ Standard Library, present interfaces for tuple-like types. It's inconvenient for users that the CUDA vector types do not conform to these interfaces.
The text was updated successfully, but these errors were encountered: