Add support for __tuple_like for ::std::{array, pair, tuple}#7129
Add support for __tuple_like for ::std::{array, pair, tuple}#7129miscco wants to merge 3 commits intoNVIDIA:mainfrom
__tuple_like for ::std::{array, pair, tuple}#7129Conversation
| return __get_complex_impl<_Tp>::template get<_Index>(::cuda::std::move(__z)); | ||
| } | ||
|
|
||
| #if _CCCL_HAS_HOST_STD_LIB() |
There was a problem hiding this comment.
@davebayer do we want to centralize those into a single file?
There was a problem hiding this comment.
I would put them right next to the cuda::std:: variants
There was a problem hiding this comment.
I wrote the test and the issue with that is that we would need to include the right folder for that and not only just <cuda/std/tuple> but also <cuda/std/array>
davebayer
left a comment
There was a problem hiding this comment.
Shouldn't we add tests for
| [[nodiscard]] _CCCL_API constexpr decltype(auto) __get_slice_at(_Slices&&... __slices) noexcept | ||
| { | ||
| return ::cuda::std::get<_Index>(::cuda::std::forward_as_tuple(::cuda::std::forward<_Slices>(__slices)...)); | ||
| // Pull in `::std::get` via ADL for host library types |
There was a problem hiding this comment.
P3663 means that any type for which structured binding into two things, both convertible to index_type, is well-formed will work as a slice specifier. For example, the following type works.
struct Foo {
int bar;
int xyzzy;
};Note that this type is not tuple-like and that std::get does not work on it.
There was a problem hiding this comment.
I am not sure whether this is something we can easily implement in C++17 will for now just add this to make sure we can handle the standard types
There was a problem hiding this comment.
... just add this to make sure we can handle the standard types
That's not a complete fix for the bug.
If you go to the canonical-slice function definition and look at the implementation following paragraph 7 ("Effects: Equivalent to"), you can make it valid C++17 code by not using designated initializers.
The point of canonical-slice is to turn every "pair of indices" slice into strided_slice with compile-time stride of 1. The implementation shown in paragraph 7 implements the Mandates in paragraph 6 ("Mandates: S is a submdspan slice type for IndexType). It's certainly possible in C++17 to test whether some type T is a specialization of strided_slice.
There was a problem hiding this comment.
yeah I need to rewrite the commit message for github to not force close the issue
There was a problem hiding this comment.
I'll say more concisely: canonical-slice exists so that you don't need a tuple-like test.
There was a problem hiding this comment.
yeah, but that is a much larger change and I am not 100% sure we can emulate it in Cüü17, so I want this in because it is something we would want anyway
There was a problem hiding this comment.
@miscco That's fine; just please be aware that this is not a complete implementation of P3663, as the branch name might otherwise suggest. Thanks!
This comment has been minimized.
This comment has been minimized.
a59e722 to
16b3306
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| # if _CCCL_HOST_STD_LIB(STL) | ||
| template <class _Tp, size_t _Size> | ||
| class array; | ||
| # else // ^^^ _CCCL_HOST_STD_LIB(STL) ^^^ / vvv !_CCCL_HOST_STD_LIB(STL) vvv | ||
| template <class _Tp, size_t _Size> | ||
| struct array; | ||
| # endif // !_CCCL_HOST_STD_LIB(STL) |
There was a problem hiding this comment.
Yeah, why should anyone bother following the standard..
23a74ac to
c56c5c0
Compare
This comment has been minimized.
This comment has been minimized.
This allows us to use standard library types with submdspan
😬 CI Workflow Results🟥 Finished in 2h 53m: Pass: 91%/95 | Total: 3d 17h | Max: 2h 53m | Hits: 47%/249814See results here. |
This allows us to use standard library types with submdspan
Fixes [BUG]: CUDA 13.1 cuda::std::mdspan does not implement P3663 Fixes #7110