MUDA
Loading...
Searching...
No Matches
var.h
1#pragma once
2//#include <muda/tools/version.h>
3//#include <vector>
4//#include <thrust/device_allocator.h>
5//
6//#include <thrust/detail/raw_pointer_cast.h>
7//#include <thrust/fill.h>
8//#include <thrust/copy.h>
9//#include <muda/muda_def.h>
10//#include <muda/buffer/var_view.h>
11//#include <muda/viewer/dense.h>
12//
13//namespace muda
14//{
15//namespace details
16//{
17// template <typename T, typename Allocator>
18// class VarBase
19// {
20// public:
21// //using T = int;
22// //using Allocator = thrust::device_allocator<int>;
23// using pointer = typename Allocator::pointer;
24// using const_pointer = typename Allocator::const_pointer;
25//
26// VarBase() MUDA_NOEXCEPT : m_data(Allocator().allocate(1)) {}
27//
28// VarBase(const T& value) MUDA_NOEXCEPT : m_data(Allocator().allocate(1))
29// {
30// this->operator=(value);
31// }
32//
33// ~VarBase() MUDA_NOEXCEPT { Allocator().deallocate(m_data, 1); }
34//
35// pointer data() { return m_data; }
36// const_pointer data() const { return m_data; }
37//
38// // copy value from host to device
39// VarBase& operator=(const T& rhs)
40// {
41// thrust::fill_n(data(), 1, rhs);
42// return *this;
43// }
44//
45// // copy value from device to host
46// operator T()
47// {
48// T t;
49// thrust::copy_n(data(), 1, &t);
50// return t;
51// }
52//
53// private:
54// pointer m_data;
55// };
56//} // namespace details
57//
58//template <typename T>
59//class DeviceVar : public details::VarBase<T, thrust::device_allocator<T>>
60//{
61// public:
62// using Base = details::VarBase<T, thrust::device_allocator<T>>;
63// using Base::Base;
64// using Base::operator=;
65//
66// const T* data() const { return thrust::raw_pointer_cast(Base::data()); }
67// T* data() { return thrust::raw_pointer_cast(Base::data()); }
68//
69// DeviceVar& operator=(DeviceVar<T> other)
70// {
71// view().copy_from(other.view());
72// return *this;
73// }
74//
75// DeviceVar& operator=(VarView other)
76// {
77// view().copy_from(other);
78// return *this;
79// }
80//
81// auto viewer() { return Dense<T>(this->data()); }
82// auto cviewer() const { return CDense<T>(this->data()); }
83// auto view() const { return VarView<T>{m_data}; }
84// operator VarView<T>() { return view(); }
85//};
86//} // namespace muda
87
88#include <muda/buffer/device_var.h>