11#ifndef CUBBYFLOW_CUDA_STD_VECTOR_HPP
12#define CUBBYFLOW_CUDA_STD_VECTOR_HPP
14#ifdef CUBBYFLOW_USE_CUDA
28 using ConstReference =
const T&;
29 using Pointer = ValueType*;
30 using ConstPointer =
const ValueType*;
35 CUBBYFLOW_CUDA_HOST_DEVICE ReferenceType(Pointer p) : m_ptr(p)
40 CUBBYFLOW_CUDA_HOST_DEVICE ReferenceType(
const ReferenceType& other)
46 CUBBYFLOW_CUDA_HOST_DEVICE ReferenceType(ReferenceType&& other) noexcept
47 : m_ptr(std::move(other.m_ptr))
52 ~ReferenceType() =
default;
54 CUBBYFLOW_CUDA_HOST_DEVICE ReferenceType& operator=(
55 const ReferenceType& other)
61 CUBBYFLOW_CUDA_HOST_DEVICE ReferenceType& operator=(
62 ReferenceType&& other)
noexcept
64 m_ptr = std::move(other.m_ptr);
69 __device__ ReferenceType& operator=(
const ValueType& val)
75 __device__
operator ValueType()
const
80 CUBBYFLOW_CUDA_HOST ReferenceType& operator=(
const ValueType& val)
82 CUDACopyHostToDevice(&val, 1, m_ptr);
86 CUBBYFLOW_CUDA_HOST
operator ValueType()
const
88 std::remove_const_t<ValueType> tmp{};
89 CUDACopyDeviceToHost(m_ptr, 1, &tmp);
102 template <
typename A>
111 template <
typename A>
120 ConstPointer data()
const;
136 void Fill(
const ValueType&
val);
138 void Resize(
size_t n,
const ValueType&
initVal = ValueType{});
146 void Append(
const ValueType&
val);
150 template <
typename A>
151 void CopyFrom(
const std::vector<T, A>&
other);
155 template <
typename A>
159 Reference operator[](
size_t i);
161 ConstReference operator[](
size_t i)
const;
165 T operator[](
size_t i)
const;
169 Pointer m_ptr =
nullptr;
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
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738