Skip to content

Instantly share code, notes, and snippets.

@mbianco
Last active October 31, 2017 13:26
Show Gist options
  • Save mbianco/8a508c9b0f9098238b46deebcc796777 to your computer and use it in GitHub Desktop.
Save mbianco/8a508c9b0f9098238b46deebcc796777 to your computer and use it in GitHub Desktop.
tuple_cat gives errors with nvcc
// This Compiles
#include <tuple>
template <typename ...T>
struct A {
template <typename ...U>
std::tuple<T..., U...>
make(T... x, U... y) {
return std::tuple<T..., U...>(x..., y...);
}
};
int main() {
A<int, char> x;
x.make(3, '3', 5.6, 4.f);
}
#include <tuple>
template <typename ...T>
struct A {
std::tuple<T...> x;
A(T... v) : x(v...) {}
};
template <typename ...T>
std::tuple<T...> transform(A<T...> a) {
return a.x;
}
template <typename T>
std::tuple<T> transform(T x) {
return std::tuple<T>(x);
}
template <typename ...Tuples>
auto cat(Tuples && ...tuples) -> decltype(std::tuple_cat(transform(tuples)...))
{
return std::tuple_cat(transform(tuples)...);
}
int main() {
A<int, char, float> x(3,'c',4.5f);
cat(5, x, 6.7);
}
#include "./tuple_cat.cpp"
@anstaf
Copy link

anstaf commented Oct 31, 2017

for the record:
this is the minimal setup to reproduce the issue

#include <tuple>
int main() {
  auto x = std::make_tuple(42);
  std::tuple_cat(x, x, x);
}

boost configuration code explicitly disables the usage of variadics if the cuda version is < 7.5 or is between 8.0 and 8.1 (I wonder what 8.1 is?)
and there is link in the comments explaining why: https://svn.boost.org/trac10/ticket/11897
I am not sure if it is the same issue as in our case though.
This issue is not reproduced on my mac laptop with the same cuda version as on daint and the clang version 3.8. It looks like tuple_cat is implemented differently here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment