serac
serac copied to clipboard
Use camp tuple and methods
- Replaces the following in serac with camp implementations that are fully variadic: ** tuple ** tuple_size ** tuple_element ** several methods relating to tuples
It appears that the issue I was running into comes from using camp::make_tuple instead of serac::make_tuple. Rather than holding this merge request up, I decided to continue using serac::make_tuple and determine how to replace it in a follow on pull request.
I think the failures are from using public packages without the patch I have for camp. @white238, do I need to run the build tpls script without any arguments to install new public packages?
I ran the build_tpls script. @white238, do I need to run something else to update the host configs?
nvcc is crashing when trying to compile the following code. A compiler bug has been submitted through LC.
#include "camp/tuple.hpp"
#include <utility>
template <typename... S, typename... T, int... i>
CAMP_HOST_DEVICE constexpr auto plus_helper(const camp::tuple<S...>& x,
const camp::tuple<T...>& y,
std::integer_sequence<int, i...>)
{
return camp::tuple{camp::get<i>(x) + camp::get<i>(y)...};
}
template <typename... S, typename... T>
CAMP_HOST_DEVICE constexpr auto operator+(const camp::tuple<S...>& x,
const camp::tuple<T...>& y)
{
static_assert(sizeof...(S) == sizeof...(T));
return plus_helper(x, y, std::make_integer_sequence<int, static_cast<int>(sizeof...(S))>());
}
int main(int argc, char* argv[]) {
camp::tuple a{0};
camp::tuple b{1};
camp::tuple c = a + b;
(void) c;
return 0;
}
I have another data point. I tried using camp functionality instead of std::integer_sequence and std::make_integer_sequence, but nvcc still crashes.
#include "camp/tuple.hpp"
#include <utility>
template <typename... S, typename... T, camp::idx_t... i>
CAMP_HOST_DEVICE constexpr auto plus_helper(const camp::tuple<S...>& x,
const camp::tuple<T...>& y,
camp::idx_seq<i...>)
{
return camp::tuple{camp::get<i>(x) + camp::get<i>(y)...};
}
template <typename... S, typename... T>
CAMP_HOST_DEVICE constexpr auto operator+(const camp::tuple<S...>& x,
const camp::tuple<T...>& y)
{
static_assert(sizeof...(S) == sizeof...(T));
return plus_helper(x, y, camp::make_idx_seq_t<sizeof...(S)>{});
}
int main(int argc, char* argv[]) {
camp::tuple a{0};
camp::tuple b{1};
camp::tuple c = a + b;
(void) c;
return 0;
}
~~Data point from @trws, removing all CTAD from camp::tuple
should allow this to compile.~~ Correction below
Small clarification, the CTAD is mostly fine, it's just in copy deduction that we have problems. In this example it's specifically the camp::tuple c = a + b;
line. Changing that out for auto should let it work.
Small clarification, the CTAD is mostly fine, it's just in copy deduction that we have problems. In this example it's specifically the
camp::tuple c = a + b;
line. Changing that out for auto should let it work.
Apparently my reading comprehension is low today. Thanks for the correction @trws !
Hi Chris,
Just heard back from the Nvidia guy at the lab. The fix for the CAMP tuple bug is slated for the CUDA 12.1 release.
Thanks, Alan Dayton
Closing as significant refactoring is happening. This PR will be used as reference once the refactoring is complete.