Commit 84bbb63e authored by Chao Liu's avatar Chao Liu
Browse files

refactoring Array, Tuple

parent 3bc39592
...@@ -9,20 +9,12 @@ namespace ck { ...@@ -9,20 +9,12 @@ namespace ck {
template <index_t N> template <index_t N>
using MultiIndex = Array<index_t, N>; using MultiIndex = Array<index_t, N>;
#if 1 // debug
template <typename... Xs> template <typename... Xs>
__host__ __device__ constexpr auto make_multi_index(Xs... xs) __host__ __device__ constexpr auto make_multi_index(Xs... xs)
{ {
return make_array<index_t>(xs...); return make_array<index_t>(xs...);
} }
#else #else
template <typename... Xs>
__host__ __device__ constexpr auto make_multi_index(const Xs&... xs)
{
return make_array(xs...);
}
#endif
#else
template <index_t N> template <index_t N>
using MultiIndex = StaticallyIndexedArray<index_t, N>; using MultiIndex = StaticallyIndexedArray<index_t, N>;
......
...@@ -12,7 +12,7 @@ struct Array ...@@ -12,7 +12,7 @@ struct Array
using type = Array; using type = Array;
using data_type = TData; using data_type = TData;
TData mData[NSize] = {0}; TData mData[NSize];
__host__ __device__ static constexpr index_t Size() { return NSize; } __host__ __device__ static constexpr index_t Size() { return NSize; }
......
...@@ -20,7 +20,7 @@ struct TupleElement ...@@ -20,7 +20,7 @@ struct TupleElement
__host__ __device__ explicit constexpr TupleElement() : mData() {} __host__ __device__ explicit constexpr TupleElement() : mData() {}
template <typename T> template <typename T>
__host__ __device__ explicit constexpr TupleElement(T&& v) : mData(static_cast<T&&>(v)) __host__ __device__ explicit constexpr TupleElement(T&& v) : mData(std::forward<T>(v))
{ {
} }
...@@ -57,7 +57,7 @@ struct TupleImpl<Sequence<Is...>, Xs...> : TupleElement<TupleElementKey<Is>, Xs> ...@@ -57,7 +57,7 @@ struct TupleImpl<Sequence<Is...>, Xs...> : TupleElement<TupleElementKey<Is>, Xs>
template <typename... Ys> template <typename... Ys>
__host__ __device__ explicit constexpr TupleImpl(Ys&&... ys) __host__ __device__ explicit constexpr TupleImpl(Ys&&... ys)
: TupleElement<TupleElementKey<Is>, Xs>(static_cast<Ys&&>(ys))... : TupleElement<TupleElementKey<Is>, Xs>(std::forward<Ys>(ys))...
{ {
} }
...@@ -85,7 +85,7 @@ struct Tuple : detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(X ...@@ -85,7 +85,7 @@ struct Tuple : detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(X
detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(Xs), 1>::type, Xs...>; detail::TupleImpl<typename arithmetic_sequence_gen<0, sizeof...(Xs), 1>::type, Xs...>;
template <typename... Ys> template <typename... Ys>
__host__ __device__ explicit constexpr Tuple(Ys&&... ys) : base(static_cast<Ys&&>(ys)...) __host__ __device__ explicit constexpr Tuple(Ys&&... ys) : base(std::forward<Ys>(ys)...)
{ {
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment