11 #ifndef CUBBYFLOW_CUDA_ARRAY_HPP 12 #define CUBBYFLOW_CUDA_ARRAY_HPP 14 #ifdef CUBBYFLOW_USE_CUDA 21 template <
typename T,
size_t N>
24 template <
typename T,
size_t N>
25 class CUDAArray final :
public CUDAArrayBase<T, N, Array<T, N>>
27 using Base = CUDAArrayBase<T, N, Array<T, N>>;
29 using Base::SetPtrAndSize;
30 using Base::SwapPtrAndSize;
34 using Base::ClearPtrAndSize;
40 CUDAArray(
const CUDAStdArray<size_t, N>& size,
const T& initVal = T{});
42 template <
typename... Args>
43 CUDAArray(
size_t nx, Args... args);
45 CUDAArray(NestedInitializerListsT<T, N> lst);
47 template <
size_t M = N>
48 CUDAArray(
const std::enable_if_t<(M == 1), std::vector<T>>& vec);
50 template <
typename OtherDerived>
51 CUDAArray(
const ArrayBase<T, N, OtherDerived>& other);
53 template <
typename OtherDerived>
54 CUDAArray(
const CUDAArrayBase<T, N, OtherDerived>& other);
56 CUDAArray(
const CUDAArray& other);
58 CUDAArray(CUDAArray&& other) noexcept;
60 ~CUDAArray() =
default;
62 template <
size_t M = N>
63 CUDAArray& operator=(
const std::enable_if_t<(M == 1), std::vector<T>>& vec);
65 template <
typename OtherDerived>
66 CUDAArray& operator=(
const ArrayBase<T, N, OtherDerived>& other);
68 template <
typename OtherDerived>
69 CUDAArray& operator=(
const ArrayBase<const T, N, OtherDerived>& other);
71 template <
typename OtherDerived>
72 CUDAArray& operator=(
const CUDAArrayBase<T, N, OtherDerived>& other);
74 template <
typename OtherDerived>
75 CUDAArray& operator=(
const CUDAArrayBase<const T, N, OtherDerived>& other);
77 CUDAArray& operator=(
const CUDAArray& other);
79 CUDAArray& operator=(CUDAArray&& other) noexcept;
81 template <
typename A,
size_t M = N>
82 std::enable_if_t<(M == 1), void> CopyFrom(
const std::vector<T, A>& vec);
84 template <
typename OtherDerived>
85 void CopyFrom(
const ArrayBase<T, N, OtherDerived>& other);
87 template <
typename OtherDerived>
88 void CopyFrom(
const ArrayBase<const T, N, OtherDerived>& other);
90 template <
typename OtherDerived>
91 void CopyFrom(
const CUDAArrayBase<T, N, OtherDerived>& other);
93 template <
typename OtherDerived>
94 void CopyFrom(
const CUDAArrayBase<const T, N, OtherDerived>& other);
96 template <
typename A,
size_t M = N>
97 std::enable_if_t<(M == 1), void> CopyTo(std::vector<T, A>& vec);
99 void CopyTo(Array<T, N>& other);
101 void CopyTo(ArrayView<T, N>& other);
103 void CopyTo(CUDAArray<T, N>& other);
105 void CopyTo(CUDAArrayView<T, N>& other);
107 void Fill(
const T& val);
109 void Resize(CUDAStdArray<size_t, N> size_,
const T& initVal = T{});
111 template <
typename... Args>
112 void Resize(
size_t nx, Args... args);
114 template <
size_t M = N>
115 std::enable_if_t<(M == 1), void> Append(
const T& val);
117 template <
typename A,
size_t M = N>
118 std::enable_if_t<(M == 1), void> Append(
const std::vector<T, A>& extra);
120 template <
typename OtherDerived,
size_t M = N>
121 std::enable_if_t<(M == 1), void> Append(
122 const ArrayBase<T, N, OtherDerived>& extra);
124 template <
typename OtherDerived,
size_t M = N>
125 std::enable_if_t<(M == 1), void> Append(
126 const CUDAArrayBase<T, N, OtherDerived>& extra);
130 void Swap(CUDAArray& other);
132 CUDAArrayView<T, N> View();
134 CUDAArrayView<const T, N> View()
const;
137 CUDAStdVector<T> m_data;
141 using CUDAArray1 = CUDAArray<T, 1>;
144 using CUDAArray2 = CUDAArray<T, 2>;
147 using CUDAArray3 = CUDAArray<T, 3>;
150 using CUDAArray4 = CUDAArray<T, 4>;
Definition: pybind11Utils.hpp:20
void Fill(ArrayView< T, N > a, const Vector< size_t, N > &begin, const Vector< size_t, N > &end, const T &val)
Definition: ArrayUtils-Impl.hpp:19