1#include <muda/buffer/buffer_launch.h>
2#include <muda/launch/memory.h>
7DeviceVar<T>::DeviceVar()
9 Memory().alloc(&m_data,
sizeof(T)).wait();
12DeviceVar<T>::DeviceVar(
const T& value)
14 Memory().alloc(&m_data,
sizeof(T));
15 view().copy_from(&value);
19DeviceVar<T>::DeviceVar(
const DeviceVar& other)
21 Memory().alloc(&m_data,
sizeof(T)).wait();
22 view().copy_from(other.view());
26DeviceVar<T>& DeviceVar<T>::operator=(
const DeviceVar<T>& other)
30 view().copy_from(other.view());
35DeviceVar<T>& DeviceVar<T>::operator=(DeviceVar<T>&& other)
41 Memory().free(m_data).wait();
43 m_data = other.m_data;
45 other.m_data =
nullptr;
51DeviceVar<T>& DeviceVar<T>::operator=(CVarView<T> other)
53 view().copy_from(other);
58void DeviceVar<T>::copy_from(CVarView<T> other)
60 view().copy_from(other);
64DeviceVar<T>& DeviceVar<T>::operator=(
const T& val)
66 view().copy_from(&val);
71DeviceVar<T>::DeviceVar(DeviceVar&& other) MUDA_NOEXCEPT : m_data(other.m_data)
73 other.m_data =
nullptr;
77DeviceVar<T>::operator T()
const
85Dense<T> DeviceVar<T>::viewer() MUDA_NOEXCEPT
87 return Dense<T>(m_data);
91CDense<T> DeviceVar<T>::cviewer() const MUDA_NOEXCEPT
93 return CDense<T>(m_data);
97DeviceVar<T>::~DeviceVar()
100 Memory().free(m_data).wait();