-
Notifications
You must be signed in to change notification settings - Fork 185
CUDA Tuple Structured Binding Declaration Broken #316
Comments
Hm, confirmed: https://godbolt.org/z/YPdYdaGTW @wmaxey is this a known problem? It looks like our structured binding tests for Lines 49 to 67 in 4b1a1df
The comment indicates a possible compiler bug as well. @miscco you've been looking at |
Interesting, I've been running into general template <typename T>
class TestTupleMember
{
public:
// remove constexpr to fail compile on nvcc >= 11.7)
constexpr __host__ __device__ TestTupleMember(T _data)
{
data = _data;
}
T data;
};
__global__ void make_tuple_kernel()
{
auto my_tup = std::make_tuple(TestTupleMember(1), TestTupleMember(2));
auto [first, second] = my_tup;
printf("Structured binding: %d, %d\n", first.data, second.data);
} The above code fails to compile unless I add a |
Note that this succeeds if I use |
So this is a "I should consider gardening" moment. The issue at hand is that structured bindings only work when the respective tuple machinery is declared in namespace std. You can have a look at this here https://godbolt.org/z/h438MMfhM |
Currently structured bindings for `cuda::std::tuple` and `cuda::std::array` was broken. The reason for that is that the standard requires, that the specializations of `tuple_size` and `tuple_element` reside in namespace std. whereas our specializations resided in namespace `cuda::std` Work around that by pulling those specializations into namespace std too. Fixes CUDA Tuple Structured Binding Declaration Broken NVIDIA#316
Currently structured bindings for `cuda::std::tuple` and `cuda::std::array` was broken. The reason for that is that the standard requires, that the specializations of `tuple_size` and `tuple_element` reside in namespace std. whereas our specializations resided in namespace `cuda::std` Work around that by pulling those specializations into namespace std too. Fixes CUDA Tuple Structured Binding Declaration Broken NVIDIA#316
Currently structured bindings for `cuda::std::tuple` and `cuda::std::array` was broken. The reason for that is that the standard requires, that the specializations of `tuple_size` and `tuple_element` reside in namespace std. whereas our specializations resided in namespace `cuda::std` Work around that by pulling those specializations into namespace std too. Fixes CUDA Tuple Structured Binding Declaration Broken NVIDIA#316
Currently structured bindings for `cuda::std::tuple` and `cuda::std::array` was broken. The reason for that is that the standard requires, that the specializations of `tuple_size` and `tuple_element` reside in namespace std. whereas our specializations resided in namespace `cuda::std` Work around that by pulling those specializations into namespace std too. Fixes CUDA Tuple Structured Binding Declaration Broken NVIDIA#316
I'm running into issues where
cuda::std::tuple
does not seem to support structured binding declarations. Is this a feature that should work but is broken? Is this unsupported forcuda::std::tuple
specifically?Note that the normal
std::tuple
supports this cpp17 feature, even in device code. If I comment out thecuda_tuple_kernel
and its calls in themain()
function, the code compiles without issues.Code:
Compile command:
Compile error:
System Info:
GPU: A100
nvcc: 11.7.64
g++: 9.4.0
OS: Ubuntu 20 LTS
The text was updated successfully, but these errors were encountered: