Last active
October 31, 2017 13:26
-
-
Save mbianco/8a508c9b0f9098238b46deebcc796777 to your computer and use it in GitHub Desktop.
tuple_cat gives errors with nvcc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "./tuple_cat.cpp" |
Maybe not, since double_pack
compiles
It looks like the problem is tupls_cat
with 3 or more tuples... A fix is to recursively cat
two tuples at the time
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
seems related to the double parameter pack in
_S_do(_Tp&& __tp, _Tpls&&... __tps, _Us&&... __us)