MUDA
Loading...
Searching...
No Matches
var_view.inl
1#include <muda/buffer/buffer_launch.h>
2
3namespace muda
4{
5template <bool IsConst, typename T>
6MUDA_GENERIC VarViewT<IsConst, T>::VarViewT(auto_const_t<T>* data) MUDA_NOEXCEPT
7 : m_data(data)
8{
9}
10
11template <bool IsConst, typename T>
12template <bool OtherIsConst>
13MUDA_GENERIC VarViewT<IsConst, T>::VarViewT(const VarViewT<OtherIsConst, T>& other) MUDA_NOEXCEPT
14 : m_data(other.m_data)
15{
16}
17
18template <bool IsConst, typename T>
19MUDA_GENERIC auto VarViewT<IsConst, T>::data() const MUDA_NOEXCEPT->auto_const_t<T>*
20{
21 return m_data;
22}
23
24template <bool IsConst, typename T>
25MUDA_GENERIC auto VarViewT<IsConst, T>::cviewer() const MUDA_NOEXCEPT->ConstViewer
26{
27 return ConstViewer{m_data};
28}
29
30template <bool IsConst, typename T>
31MUDA_GENERIC auto VarViewT<IsConst, T>::viewer() const MUDA_NOEXCEPT->ThisViewer
32{
33 return ThisViewer{m_data};
34}
35
36template <bool IsConst, typename T>
37MUDA_GENERIC auto VarViewT<IsConst, T>::as_const() const MUDA_NOEXCEPT->ConstView
38{
39 return ConstView{*this};
40}
41
42template <bool IsConst, typename T>
43void VarViewT<IsConst, T>::copy_from(const T* val) const MUDA_REQUIRES(!IsConst)
44{
45 static_assert(!IsConst, "Cannot copy to const var");
46
47 BufferLaunch()
48 .template copy<T>(*this, val) //
49 .wait();
50}
51
52template <bool IsConst, typename T>
53void VarViewT<IsConst, T>::copy_to(T* val) const
54{
55 BufferLaunch()
56 .template copy<T>(val, *this) //
57 .wait();
58}
59
60template <bool IsConst, typename T>
61void VarViewT<IsConst, T>::copy_from(const ConstView& val) const MUDA_REQUIRES(!IsConst)
62{
63 static_assert(!IsConst, "Cannot copy to const var");
64
65 BufferLaunch()
66 .template copy<T>(*this, val) //
67 .wait();
68}
69
70template <bool IsConst, typename T>
71void VarViewT<IsConst, T>::fill(const T& val) const MUDA_REQUIRES(!IsConst)
72{
73 static_assert(!IsConst, "Cannot fill const var");
74
75 BufferLaunch()
76 .template fill<T>(*this, val) //
77 .wait();
78}
79} // namespace muda