serac icon indicating copy to clipboard operation
serac copied to clipboard

Use camp tuple and methods

Open adayton1 opened this issue 2 years ago • 3 comments

  • Replaces the following in serac with camp implementations that are fully variadic: ** tuple ** tuple_size ** tuple_element ** several methods relating to tuples

adayton1 avatar Jun 08 '22 17:06 adayton1

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.

adayton1 avatar Jun 08 '22 18:06 adayton1

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?

adayton1 avatar Jun 08 '22 18:06 adayton1

I ran the build_tpls script. @white238, do I need to run something else to update the host configs?

adayton1 avatar Jun 14 '22 18:06 adayton1

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;
}

adayton1 avatar Oct 24 '22 20:10 adayton1

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;
}

adayton1 avatar Oct 24 '22 21:10 adayton1

~~Data point from @trws, removing all CTAD from camp::tuple should allow this to compile.~~ Correction below

white238 avatar Nov 22 '22 00:11 white238

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.

trws avatar Nov 22 '22 00:11 trws

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 !

white238 avatar Nov 22 '22 00:11 white238

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

white238 avatar Jan 05 '23 22:01 white238

Closing as significant refactoring is happening. This PR will be used as reference once the refactoring is complete.

jamiebramwell avatar Oct 31 '23 20:10 jamiebramwell