Loading...
Searching...
No Matches
CUDAStdArray.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_CUDA_STD_ARRAY_HPP
12#define CUBBYFLOW_CUDA_STD_ARRAY_HPP
13
14#ifdef CUBBYFLOW_USE_CUDA
15
17
18#include <array>
19
20namespace CubbyFlow
21{
22template <typename T, size_t N>
23class CUDAStdArray
24{
25 public:
26 using ValueType = T;
27 using Reference = T&;
28 using ConstReference = const T&;
29 using Pointer = T*;
30 using ConstPointer = const T*;
31 using Iterator = Pointer;
32 using ConstIterator = ConstPointer;
33
35
36 template <typename... Args>
38
39 CUBBYFLOW_CUDA_HOST CUDAStdArray(const std::array<T, N>& other);
40
42
43 ~CUDAStdArray() = default;
44
46
48
50 const CUDAStdArray& other);
51
53 CUDAStdArray&& other) noexcept;
54
55 CUBBYFLOW_CUDA_HOST_DEVICE void Fill(ConstReference val);
56
58
59 CUBBYFLOW_CUDA_HOST_DEVICE Reference operator[](size_t i);
60
61 CUBBYFLOW_CUDA_HOST_DEVICE ConstReference operator[](size_t i) const;
62
64
66
67 private:
68 template <typename... Args>
69 CUBBYFLOW_CUDA_HOST_DEVICE void SetAt(size_t i, ConstReference first,
70 Args... rest);
71
72 template <typename... Args>
73 CUBBYFLOW_CUDA_HOST_DEVICE void SetAt(size_t i, ConstReference first);
74
75 T m_elements[N];
76};
77} // namespace CubbyFlow
78
80
81#endif
82
83#endif
Definition pybind11Utils.hpp:21
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
constexpr std::enable_if_t< IsMatrixSizeStatic< Rows, Cols >(), bool > operator==(const MatrixExpression< T, Rows, Cols, M1 > &a, const MatrixExpression< T, Rows, Cols, M2 > &b)
Definition Matrix-Impl.hpp:1408
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
bool operator!=(const MatrixExpression< T, R1, C1, M1 > &a, const MatrixExpression< T, R2, C2, M2 > &b)
Definition Matrix-Impl.hpp:1443